Documentation
¶
Index ¶
- Constants
- Variables
- func CloseClientConnection(connection *grpc.ClientConn)
- func ConcurrentExec[K any](items []K, f func(index int, item K) error) error
- func CountLbNodes(lb *spec.LBcluster) int
- func CountNodes(k *spec.K8Scluster) int
- func CreateDirectory(dir string) error
- func CreateHash(length int) string
- func CreateKeyFile(key string, outputPath string, keyName string) error
- func CreateKeysForDynamicNodePools(nps []*spec.NodePool, outputDirectory string) error
- func CreateKeysForStaticNodepools(nps []*spec.NodePool, outputDirectory string) error
- func CreateLoggerWithClusterName(clusterName string) zerolog.Logger
- func CreateLoggerWithProjectAndClusterName(projectName, clusterName string) zerolog.Logger
- func CreateLoggerWithProjectName(projectName string) zerolog.Logger
- func CreateNpsFromCommonControlPlaneNodes(currControlNps map[string]*spec.NodePool, desiredNp []*spec.NodePool) []*spec.NodePool
- func DirectoryExists(dir string) bool
- func ExtractTargetPorts(loadBalancers []*spec.LBcluster) []int
- func FindAPIEndpointNode(nodepools []*spec.NodePool) (*spec.Node, error)
- func FindControlNode(nodepools []*spec.NodePool) (*spec.Node, error)
- func FindControlNodepools(nodepools []*spec.NodePool) []*spec.NodePool
- func FindEndpointNode(np *spec.NodePool) (*spec.Node, error)
- func FindName(realNames []string, name string) string
- func FindNodepoolWithApiEndpointNode(nodepools []*spec.NodePool) (*spec.NodePool, *spec.Node, error)
- func GetAuthCredentials(provider *spec.Provider) string
- func GetClusterID(clusterInfo *spec.ClusterInfo) string
- func GetCommonDynamicControlPlaneNodes(currentNp, desiredNp []*spec.NodePool) []*spec.NodePool
- func GetCommonDynamicNodePools(nps []*spec.NodePool) []*spec.NodePool
- func GetCommonStaticControlPlaneNodes(currentNp, desiredNp []*spec.NodePool) []*spec.NodePool
- func GetCommonStaticNodePools(nps []*spec.NodePool) []*spec.NodePool
- func GetDynamicNodePools(nps []*spec.NodePool) []*spec.DynamicNodePool
- func GetDynamicNodePoolsFromCI(ci *spec.ClusterInfo) []*spec.DynamicNodePool
- func GetEnvDefault(envKey string, defaultVal string) string
- func GetLBClusterByName(name string, clusters []*spec.LBcluster) int
- func GetNodePoolByName(nodePoolName string, nodePools []*spec.NodePool) *spec.NodePool
- func GetRegions(nodepools []*spec.DynamicNodePool) []string
- func GetWatchNamespaceList(input string) []string
- func GroupNodepoolsByProviderRegion(clusterInfo *spec.ClusterInfo) map[string][]*spec.NodePool
- func GroupNodepoolsByProviderSpecName(clusterInfo *spec.ClusterInfo) map[string][]*spec.NodePool
- func GrpcDialWithRetryAndBackoff(serviceName, serviceURL string) (*grpc.ClientConn, error)
- func HasAPIServerRole(roles []*spec.Role) bool
- func InitLog(moduleName string)
- func Into[K, V any](k []K, f func(k K) *V) []*V
- func IsAutoscaled(cluster *spec.K8Scluster) bool
- func IsConnectionReady(c *grpc.ClientConn) error
- func IterateInOrder[M ~map[K]V, K inorder, V any](m M, f func(k K, v V) error) error
- func MatchNameAndHashWithTemplate(template, nodepoolName string) (name, hash string)
- func MergeMaps[M ~map[K]V, K comparable, V any](maps ...M) M
- func MustExtractNameAndHash(pool string) (name, hash string)
- func NewGRPCServer(opts ...grpc.ServerOption) *grpc.Server
- func PeerInfoInterceptor(logger *zerolog.Logger) grpc.UnaryServerInterceptor
- func PointerValEqual[K comparable](left, right *K) bool
- func RemoveDuplicates[K comparable](slice []K) []K
- func SanitiseKubeconfig(s string) string
- func SanitiseString(s string) string
- func SanitiseURI(s string) string
- func Sum[M ~map[K]V, K comparable, V constraints.Integer | constraints.Float](m M) int
Constants ¶
const HashLength = 7
HashLength is the length of the randomly generated "hash" that is used throughout claudie in different places. be CAUTIOUS when changing this value as this will break backwards compatibility and also invariants within claudie. Dynamic nodepools are assigned a randomly generated hash. Node pool names have a max constraint of 15 characters changing the hash length will invalidate this.
Variables ¶
var ErrConnectionNotReady = errors.New("unhealthy gRPC connection")
Functions ¶
func CloseClientConnection ¶
func CloseClientConnection(connection *grpc.ClientConn)
CloseClientConnection is a wrapper around grpc.ClientConn Close function
func CountLbNodes ¶ added in v0.6.3
func CountNodes ¶ added in v0.6.3
func CountNodes(k *spec.K8Scluster) int
func CreateDirectory ¶
func CreateHash ¶
func CreateKeyFile ¶
CreateKeyFile writes the given key to a file. The key filename is specified by its outputPath and KeyName operands.
func CreateKeysForDynamicNodePools ¶ added in v0.9.0
func CreateKeysForStaticNodepools ¶ added in v0.4.1
CreateKeysForStaticNodepools creates private keys files for all nodes in the provided static node pools in form of <node name>.pem.
func CreateLoggerWithClusterName ¶ added in v0.3.1
CreateLoggerWithClusterName creates a new logger aware of the cluster-name. Returns the new logger
func CreateLoggerWithProjectAndClusterName ¶ added in v0.3.1
CreateLoggerWithProjectAndClusterName creates a new logger aware of the project-name and cluster-name. Returns the new logger
func CreateLoggerWithProjectName ¶ added in v0.3.1
CreateLoggerWithProjectName creates a new logger aware of the project-name. Returns the new logger
func CreateNpsFromCommonControlPlaneNodes ¶ added in v0.9.0
func DirectoryExists ¶ added in v0.9.0
func ExtractTargetPorts ¶ added in v0.9.0
ExtractTargetPorts extracts target ports defined inside the role in the LoadBalancer.
func FindAPIEndpointNode ¶ added in v0.3.1
FindAPIEndpointNode searches the NodePools for a Node with type ApiEndpoint.
func FindControlNode ¶ added in v0.3.1
FindControlNode search the nodepools for a node with type Master.
func FindControlNodepools ¶ added in v0.7.2
FindControlNodepools returns control nodepools
func FindEndpointNode ¶ added in v0.3.1
FindEndpointNode searches the nodes of the nodepool for a node with type ApiEndpoint.
func FindName ¶
FindName will return a real node name based on the user defined one example: name defined in cloud provider: gcp-control-1 -> name defined in cluster : gcp-control-1
func FindNodepoolWithApiEndpointNode ¶ added in v0.4.0
func FindNodepoolWithApiEndpointNode(nodepools []*spec.NodePool) (*spec.NodePool, *spec.Node, error)
FindNodepoolWithApiEndpointNode searches for a nodepool that has the control node representing the Api endpoint of the cluster. Returns the control node if found and its corresponding nodepool.
func GetAuthCredentials ¶ added in v0.9.0
GetAuthCredentials extract the key for the provider to be used within terraform.
func GetClusterID ¶ added in v0.3.1
func GetClusterID(clusterInfo *spec.ClusterInfo) string
func GetCommonDynamicControlPlaneNodes ¶ added in v0.9.0
func GetCommonDynamicNodePools ¶ added in v0.4.0
GetCommonDynamicNodePools returns slice of common node pools, where every node pool is dynamic.
func GetCommonStaticControlPlaneNodes ¶ added in v0.9.0
func GetCommonStaticNodePools ¶ added in v0.4.0
GetCommonStaticNodePools returns slice of common node pools, where every node pool is static.
func GetDynamicNodePools ¶ added in v0.4.0
func GetDynamicNodePools(nps []*spec.NodePool) []*spec.DynamicNodePool
GetDynamicNodePools returns slice of dynamic node pools.
func GetDynamicNodePoolsFromCI ¶ added in v0.4.0
func GetDynamicNodePoolsFromCI(ci *spec.ClusterInfo) []*spec.DynamicNodePool
GetDynamicNodePoolsFromCI returns slice of dynamic node pools used in specified cluster info.
func GetEnvDefault ¶ added in v0.4.0
GetEnvDefault take a string representing environment variable as an argument, and a default value If the environment variable is not defined, it returns the provided default value.
func GetLBClusterByName ¶ added in v0.4.0
GetLBClusterByName will return index of Cluster that will have same name as specified in parameters If no name is found, return -1
func GetNodePoolByName ¶
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 []*spec.DynamicNodePool) []string
GetRegions will return a list of all regions used in list of nodepools
func GetWatchNamespaceList ¶ added in v0.8.0
watchNamespaceList takes a string input of the form "namespace1,namespace-2,namespace3" and splits it into a slice of strings based on the comma separator. It returns the slice containing individual namespace strings.
func GroupNodepoolsByProviderRegion ¶ added in v0.2.2
func GroupNodepoolsByProviderRegion(clusterInfo *spec.ClusterInfo) map[string][]*spec.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 *spec.ClusterInfo) map[string][]*spec.NodePool
GroupNodepoolsByProviderSpecName groups nodepool by provider spec name into the map[Provider Name][]*spec.Nodepool
func GrpcDialWithRetryAndBackoff ¶ added in v0.4.1
func GrpcDialWithRetryAndBackoff(serviceName, serviceURL string) (*grpc.ClientConn, error)
GrpcDialWithRetryAndBackoff creates an insecure gRPC connection to serviceURL After successfully connected, any RPC calls made from this connection also have a retry policy of ~10 minutes after which an error is returned that it couldn't connect to the service.
func HasAPIServerRole ¶ added in v0.3.1
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 Into ¶ added in v0.4.2
func Into[K, V any](k []K, f func(k K) *V) []*V
Into traverse the elements in k and calls the supplied function f to convert them into elements of type V.
func IsAutoscaled ¶ added in v0.2.2
func IsAutoscaled(cluster *spec.K8Scluster) bool
IsAutoscaled returns true, if cluster has at least one nodepool with autoscaler config.
func IsConnectionReady ¶ added in v0.4.2
func IsConnectionReady(c *grpc.ClientConn) error
func IterateInOrder ¶ added in v0.7.3
func MatchNameAndHashWithTemplate ¶ added in v0.9.0
func MergeMaps ¶ added in v0.4.1
func MergeMaps[M ~map[K]V, K comparable, V any](maps ...M) M
MergeMaps merges two or more maps together, into single map.
func MustExtractNameAndHash ¶ added in v0.9.0
func NewGRPCServer ¶ added in v0.4.1
func NewGRPCServer(opts ...grpc.ServerOption) *grpc.Server
func PeerInfoInterceptor ¶ added in v0.7.5
func PeerInfoInterceptor(logger *zerolog.Logger) grpc.UnaryServerInterceptor
func PointerValEqual ¶ added in v0.9.0
func PointerValEqual[K comparable](left, right *K) bool
func RemoveDuplicates ¶ added in v0.6.6
func RemoveDuplicates[K comparable](slice []K) []K
func SanitiseKubeconfig ¶
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 SanitiseString ¶ added in v0.4.1
sanitiseString replaces all white spaces and ":" in the string to "-", and converts everything to lower case.
func SanitiseURI ¶
SanitiseURI replaces passwords with '*****' in connection strings that are in the form of <scheme>://<username>:<password>@<domain>.<tld> or <scheme>://<username>:<password>@<pqdn>.
func Sum ¶ added in v0.6.3
func Sum[M ~map[K]V, K comparable, V constraints.Integer | constraints.Float](m M) int
Types ¶
This section is empty.