cluster

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingAPIVersion           = errors.New("apiVersion is required")
	ErrMissingKind                 = errors.New("kind is required")
	ErrMissingClusterEntry         = errors.New("at least one cluster entry is required")
	ErrMissingUserEntry            = errors.New("at least one user entry is required")
	ErrMissingClusterName          = errors.New("cluster name is required")
	ErrMissingClusterServer        = errors.New("cluster server is required")
	ErrMissingCertificateAuthority = errors.New("certificate-authority-data is required")
	ErrInvalidCertificateAuthority = errors.New("certificate-authority-data is invalid")
	ErrClusterServerConnectivity   = errors.New("cannot connect to the cluster server")
	ErrBuildClientConfig           = errors.New("failed to create client config from provided KubeConfig")
	ErrCreateClientSet             = errors.New("failed to create clientset")
	ErrGetServerVersion            = errors.New("failed to connect to the cluster")
)

Functions

func SanitizeUnstructuredCluster added in v0.2.11

func SanitizeUnstructuredCluster(ctx context.Context, cluster *unstructured.Unstructured) (*unstructured.Unstructured, error)

SanitizeUnstructuredCluster masks sensitive information within a Unstructured cluster object, such as user credentials and certificate data.

Types

type Cluster added in v0.2.6

type Cluster struct {
	Server                   string `yaml:"server"`
	CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty"`
}

Cluster contains the cluster information

type ClusterDetail

type ClusterDetail struct {
	NodeCount      int
	ServerVersion  string
	MemoryCapacity int64
	CPUCapacity    int64
	PodsCapacity   int64
}

type ClusterEntry added in v0.2.6

type ClusterEntry struct {
	Name    string  `yaml:"name"`
	Cluster Cluster `yaml:"cluster"`
}

ClusterEntry represents each cluster entry in kubeconfig

type ClusterManager

type ClusterManager struct {
	// contains filtered or unexported fields
}

func NewClusterManager

func NewClusterManager(config *Config) *ClusterManager

NewClusterManager returns a new ClusterManager object

func (*ClusterManager) ConvertGraphToMap

func (c *ClusterManager) ConvertGraphToMap(rg *relationship.RelationshipGraph) map[string]ClusterTopology

ConvertGraphToMap returns a map[string]ClusterTopology for a given relationship.RelationshipGraph

func (*ClusterManager) CreateCluster added in v0.2.8

func (c *ClusterManager) CreateCluster(ctx context.Context, client *multicluster.MultiClusterClient, name, displayName, description, kubeconfig string) (*unstructured.Unstructured, error)

CreateCluster creates a new Cluster resource in the hub cluster and returns the created unstructured Cluster object

func (*ClusterManager) DeleteCluster added in v0.2.8

func (c *ClusterManager) DeleteCluster(ctx context.Context, client *multicluster.MultiClusterClient, name string) error

DeleteCluster deletes the cluster by name

func (*ClusterManager) GetCluster

GetCluster returns the unstructured Cluster object for a given cluster

func (*ClusterManager) GetDetailsForCluster

func (c *ClusterManager) GetDetailsForCluster(ctx context.Context, client *multicluster.MultiClusterClient, name string) (*ClusterDetail, error)

GetDetailsForCluster returns ClusterDetail object for a given cluster

func (*ClusterManager) GetNamespaceForCluster

func (c *ClusterManager) GetNamespaceForCluster(ctx context.Context, client *multicluster.MultiClusterClient, cluster, namespace string) (*v1.Namespace, error)

GetYAMLForCluster returns the yaml byte array for a given cluster

func (*ClusterManager) GetTopologyForCluster

func (c *ClusterManager) GetTopologyForCluster(ctx context.Context, client *multicluster.MultiClusterClient, name string) (map[string]ClusterTopology, error)

GetTopologyForCluster returns a map that describes topology for a given cluster

func (*ClusterManager) GetTopologyForClusterNamespace

func (c *ClusterManager) GetTopologyForClusterNamespace(ctx context.Context, client *multicluster.MultiClusterClient, cluster, namespace string) (map[string]ClusterTopology, error)

GetTopologyForClusterNamespace returns a map that describes topology for a given namespace in a given cluster

func (*ClusterManager) GetYAMLForCluster

func (c *ClusterManager) GetYAMLForCluster(ctx context.Context, client *multicluster.MultiClusterClient, name string) ([]byte, error)

GetYAMLForCluster returns the yaml byte array for a given cluster

func (*ClusterManager) ListCluster added in v0.2.9

DeleteCluster deletes the cluster by name

func (*ClusterManager) SanitizeKubeConfigFor added in v0.2.6

func (c *ClusterManager) SanitizeKubeConfigFor(config *KubeConfig)

SanitizeKubeConfigFor masks sensitive information within a KubeConfig object, such as user credentials and certificate data.

func (*ClusterManager) SanitizeKubeConfigWithYAML added in v0.2.6

func (c *ClusterManager) SanitizeKubeConfigWithYAML(ctx context.Context, plain string) (sanitize string, err error)

SanitizeKubeConfigWithYAML takes a plain KubeConfig YAML string and returns a sanitized version with sensitive information masked.

func (*ClusterManager) UpdateCredential added in v0.2.8

func (c *ClusterManager) UpdateCredential(ctx context.Context, client *multicluster.MultiClusterClient, name, displayName, description, kubeconfig string) (*unstructured.Unstructured, error)

UpdateCredential updates cluster credential by name and a new kubeconfig

func (*ClusterManager) UpdateMetadata added in v0.2.8

func (c *ClusterManager) UpdateMetadata(ctx context.Context, client *multicluster.MultiClusterClient, name, displayName, description string) (*unstructured.Unstructured, error)

UpdateCluster updates cluster by name with a full payload

func (*ClusterManager) ValidateKubeConfigFor added in v0.2.8

func (c *ClusterManager) ValidateKubeConfigFor(ctx context.Context, config *KubeConfig) (string, error)

ValidateKubeConfigFor validates the provided KubeConfig.

func (*ClusterManager) ValidateKubeConfigWithYAML added in v0.2.8

func (c *ClusterManager) ValidateKubeConfigWithYAML(ctx context.Context, plain string) (string, error)

ValidateKubeConfigWithYAML unmarshals YAML content into KubeConfig and validates it.

type ClusterTopology

type ClusterTopology struct {
	GroupVersionKind string
	Count            int
	Relationship     map[string]string
}

type Config

type Config struct {
	Verbose bool `json:"verbose"`
}

type Context added in v0.2.6

type Context struct {
	Cluster string `yaml:"cluster"`
	User    string `yaml:"user"`
}

Context contains the context information

type ContextEntry added in v0.2.6

type ContextEntry struct {
	Name    string  `yaml:"name"`
	Context Context `yaml:"context"`
}

ContextEntry represents each context entry in kubeconfig

type KubeConfig added in v0.2.6

type KubeConfig struct {
	APIVersion     string         `yaml:"apiVersion"`
	Kind           string         `yaml:"kind"`
	Clusters       []ClusterEntry `yaml:"clusters"`
	Contexts       []ContextEntry `yaml:"contexts"`
	CurrentContext string         `yaml:"current-context"`
	Users          []UserEntry    `yaml:"users"`
}

KubeConfig represents the structure of a kubeconfig file

type User added in v0.2.6

type User struct {
	ClientCertificateData string `yaml:"client-certificate-data,omitempty"`
	ClientKeyData         string `yaml:"client-key-data,omitempty"`
	Token                 string `yaml:"token,omitempty"`
	Username              string `yaml:"username,omitempty"`
	Password              string `yaml:"password,omitempty"`
}

User contains the user information

type UserEntry added in v0.2.6

type UserEntry struct {
	Name string `yaml:"name"`
	User User   `yaml:"user"`
}

UserEntry represents each user entry in kubeconfig

Jump to

Keyboard shortcuts

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