utils

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const HashLength = 7

Variables

This section is empty.

Functions

func ChangedDNSProvider

func ChangedDNSProvider(currentDNS, desiredDNS *pb.DNS) bool

func CloseClientConnection

func CloseClientConnection(connection *grpc.ClientConn)

CloseClientConnection is a wrapper around grpc.ClientConn Close function

func ConcurrentExec

func ConcurrentExec[K any](items []K, f func(item K) error) error

func Contains added in v0.3.1

func Contains[K comparable](item K, items []K, cmp func(item K, other K) bool) bool

Contains checks if item is present in the list of items.

func CreateDirectory

func CreateDirectory(dir string) error

func CreateHash

func CreateHash(length int) string

func CreateKeyFile

func CreateKeyFile(key string, outputPath string, keyName string) error

CreateKeyFile writes the given key to a file. The key filename is specified by its outputPath and KeyName operands.

func CreateLoggerWithClusterName added in v0.3.1

func CreateLoggerWithClusterName(clusterName string) zerolog.Logger

CreateLoggerWithClusterName creates a new logger aware of the cluster-name. Returns the new logger

func CreateLoggerWithProjectAndClusterName added in v0.3.1

func CreateLoggerWithProjectAndClusterName(projectName, clusterName string) zerolog.Logger

CreateLoggerWithProjectAndClusterName creates a new logger aware of the project-name and cluster-name. Returns the new logger

func CreateLoggerWithProjectName added in v0.3.1

func CreateLoggerWithProjectName(projectName string) zerolog.Logger

CreateLoggerWithProjectName creates a new logger aware of the project-name. Returns the new logger

func FindAPIEndpointNode added in v0.3.1

func FindAPIEndpointNode(nodepools []*pb.NodePool) (*pb.Node, error)

FindAPIEndpointNode searches the NodePools for a Node with type ApiEndpoint.

func FindAPIEndpointNodePoolWithNode added in v0.3.1

func FindAPIEndpointNodePoolWithNode(nodepools []*pb.NodePool) (*pb.NodePool, *pb.Node, error)

FindAPIEndpointNodePoolWithNode searches for a nodepool that has a node with type ApiEndpoint.

func FindControlNode added in v0.3.1

func FindControlNode(nodepools []*pb.NodePool) (*pb.Node, error)

FindControlNode search the nodepools for a node with type Master.

func FindEndpointNode added in v0.3.1

func FindEndpointNode(nodepool *pb.NodePool) (*pb.Node, error)

FindEndpointNode searches the nodes of the nodepool for a node with type ApiEndpoint.

func FindLbAPIEndpoint added in v0.3.1

func FindLbAPIEndpoint(lbs []*pb.LBcluster) bool

FindLbAPIEndpoint searches for a role with ApiEndpoint among the LBcluster.

func FindName

func FindName(realNames []string, name string) string

FindName will return a real node name based on the user defined one example: name defined in cloud provider: gcp-cluster-jkshbdc-gcp-control-1 -> name defined in cluster : gcp-control-1

func GetClusterByName

func GetClusterByName(clusterName string, clusters []*pb.K8Scluster) *pb.K8Scluster

GetClusterByName will return Cluster that will have same name as specified in parameters If no name is found, return nil

func GetClusterID added in v0.3.1

func GetClusterID(clusterInfo *pb.ClusterInfo) string

func GetNodePoolByName

func GetNodePoolByName(nodePoolName string, nodePools []*pb.NodePool) *pb.NodePool

GetNodePoolByName will return first Nodepool that will have same name as specified in parameters If no name is found, return nil

func GetRegions

func GetRegions(nodepools []*pb.NodePool) []string

GetRegions will return a list of all regions used in list of nodepools

func GetenvOr

func GetenvOr(envKey string, defaultVal string) string

GetenvOr returns the value of the env variable argument if it exists. Otherwise it returns the provided default value.

func GroupNodepoolsByProvider

func GroupNodepoolsByProvider(clusterInfo *pb.ClusterInfo) map[string][]*pb.NodePool

GroupNodepoolsByProvider groups nodepool by cloud provider name into the map[Provider Name][]*pb.Nodepool

func GroupNodepoolsByProviderRegion added in v0.2.2

func GroupNodepoolsByProviderRegion(clusterInfo *pb.ClusterInfo) map[string][]*pb.NodePool

GroupNodepoolsByProviderRegion groups nodepool by cloud provider instance name and region into the map[<provider-instance-name>-<region>][]*pb.Nodepool

func GroupNodepoolsByProviderSpecName

func GroupNodepoolsByProviderSpecName(clusterInfo *pb.ClusterInfo) map[string][]*pb.NodePool

GroupNodepoolsByProviderSpecName groups nodepool by provider spec name into the map[Provider Name][]*pb.Nodepool

func GrpcDialWithInsecure

func GrpcDialWithInsecure(serviceName string, serviceURL string) (*grpc.ClientConn, error)

func HasAPIServerRole added in v0.3.1

func HasAPIServerRole(roles []*pb.Role) bool

HasAPIServerRole checks if there is an API server role.

func InitLog

func InitLog(moduleName string)

Initialize the logging framework. Inputs are the golang module name used as a logging prefix and the env variable with the logging level

func IsAutoscaled added in v0.2.2

func IsAutoscaled(cluster *pb.K8Scluster) bool

IsAutoscaled returns true, if cluster has at least one nodepool with autoscaler config.

func SanitiseKubeconfig

func SanitiseKubeconfig(s string) string

SanitiseKubeconfig replaces the entire kubeconfig found after the '--kubeconfig' flag with '*****'. This has been decided to be the superior option when compared to matching sensitive fields and obscuring just those.

func SanitiseURI

func SanitiseURI(s string) string

SanitiseURI replaces passwords with '*****' in connection strings that are in the form of <scheme>://<username>:<password>@<domain>.<tld> or <scheme>://<username>:<password>@<pqdn>.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL