Documentation ¶
Index ¶
- Variables
- func SanitizeUnstructuredCluster(ctx context.Context, cluster *unstructured.Unstructured) (*unstructured.Unstructured, error)
- func SortUnstructuredList(unList *unstructured.UnstructuredList, criteria SortCriteria, descending bool) (*unstructured.UnstructuredList, error)
- type Cluster
- type ClusterEntry
- type ClusterManager
- func (c *ClusterManager) CountCluster(ctx context.Context, client *multicluster.MultiClusterClient, ...) (*ClusterSummary, error)
- func (c *ClusterManager) CreateCluster(ctx context.Context, client *multicluster.MultiClusterClient, ...) (*unstructured.Unstructured, error)
- func (c *ClusterManager) DeleteCluster(ctx context.Context, client *multicluster.MultiClusterClient, name string) error
- func (c *ClusterManager) GetCluster(ctx context.Context, client *multicluster.MultiClusterClient, name string) (*unstructured.Unstructured, error)
- func (c *ClusterManager) GetNamespace(ctx context.Context, client *multicluster.MultiClusterClient, namespace string) (*unstructured.Unstructured, error)
- func (c *ClusterManager) GetNamespaceYAML(ctx context.Context, client *multicluster.MultiClusterClient, namespace string) ([]byte, error)
- func (c *ClusterManager) GetYAMLForCluster(ctx context.Context, client *multicluster.MultiClusterClient, name string) ([]byte, error)
- func (c *ClusterManager) ListCluster(ctx context.Context, client *multicluster.MultiClusterClient, ...) (*unstructured.UnstructuredList, error)
- func (c *ClusterManager) ListClusterName(ctx context.Context, client *multicluster.MultiClusterClient, ...) ([]string, error)
- func (c *ClusterManager) SanitizeKubeConfigFor(config *KubeConfig)
- func (c *ClusterManager) SanitizeKubeConfigWithYAML(ctx context.Context, plain string) (sanitize string, err error)
- func (c *ClusterManager) UpdateCredential(ctx context.Context, client *multicluster.MultiClusterClient, ...) (*unstructured.Unstructured, error)
- func (c *ClusterManager) UpdateMetadata(ctx context.Context, client *multicluster.MultiClusterClient, ...) (*unstructured.Unstructured, error)
- func (c *ClusterManager) ValidateKubeConfigFor(ctx context.Context, config *KubeConfig) (string, error)
- func (c *ClusterManager) ValidateKubeConfigWithYAML(ctx context.Context, plain string) (string, error)
- type ClusterSummary
- type Context
- type ContextEntry
- type KubeConfig
- type SortCriteria
- type User
- type UserEntry
Constants ¶
This section is empty.
Variables ¶
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 ¶
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.
func SortUnstructuredList ¶
func SortUnstructuredList( unList *unstructured.UnstructuredList, criteria SortCriteria, descending bool, ) (*unstructured.UnstructuredList, error)
SortUnstructuredList returns a sorted unstructured.UnstructuredList based on criteria
Types ¶
type Cluster ¶
type Cluster struct { Server string `yaml:"server"` CertificateAuthorityData string `yaml:"certificate-authority-data,omitempty"` }
Cluster contains the cluster information
type ClusterEntry ¶
ClusterEntry represents each cluster entry in kubeconfig
type ClusterManager ¶
type ClusterManager struct{}
func NewClusterManager ¶
func NewClusterManager() *ClusterManager
NewClusterManager returns a new ClusterManager object
func (*ClusterManager) CountCluster ¶
func (c *ClusterManager) CountCluster( ctx context.Context, client *multicluster.MultiClusterClient, config *rest.Config, ) (*ClusterSummary, error)
CountCluster returns the summary of clusters by their health status
func (*ClusterManager) CreateCluster ¶
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 ¶
func (c *ClusterManager) DeleteCluster( ctx context.Context, client *multicluster.MultiClusterClient, name string, ) error
DeleteCluster deletes the cluster by name
func (*ClusterManager) GetCluster ¶
func (c *ClusterManager) GetCluster( ctx context.Context, client *multicluster.MultiClusterClient, name string, ) (*unstructured.Unstructured, error)
GetCluster returns the unstructured Cluster object for a given cluster
func (*ClusterManager) GetNamespace ¶
func (c *ClusterManager) GetNamespace( ctx context.Context, client *multicluster.MultiClusterClient, namespace string, ) (*unstructured.Unstructured, error)
GetNamespaceForCluster returns the yaml byte array for a given cluster
func (*ClusterManager) GetNamespaceYAML ¶
func (c *ClusterManager) GetNamespaceYAML( ctx context.Context, client *multicluster.MultiClusterClient, namespace string, ) ([]byte, error)
GetNamespaceForCluster returns the yaml byte array for 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 ¶
func (c *ClusterManager) ListCluster( ctx context.Context, client *multicluster.MultiClusterClient, orderBy SortCriteria, descending bool, ) (*unstructured.UnstructuredList, error)
ListCluster returns the full list of clusters in a specific order
func (*ClusterManager) ListClusterName ¶
func (c *ClusterManager) ListClusterName(ctx context.Context, client *multicluster.MultiClusterClient, orderBy SortCriteria, descending bool) ([]string, error)
ListClusterName retrieves a list of cluster names based on the specified sorting criteria and order.
func (*ClusterManager) SanitizeKubeConfigFor ¶
func (c *ClusterManager) SanitizeKubeConfigFor(config *KubeConfig)
SanitizeKubeConfigFor masks sensitive information within a KubeConfig object, such as user credentials and certificate data.
func (*ClusterManager) SanitizeKubeConfigWithYAML ¶
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 ¶
func (c *ClusterManager) UpdateCredential( ctx context.Context, client *multicluster.MultiClusterClient, name, kubeconfig string, ) (*unstructured.Unstructured, error)
UpdateCredential updates cluster credential by name and a new kubeconfig
func (*ClusterManager) UpdateMetadata ¶
func (c *ClusterManager) UpdateMetadata( ctx context.Context, client *multicluster.MultiClusterClient, name, displayName, description string, ) (*unstructured.Unstructured, error)
UpdateMetadata updates cluster by name with a full payload
func (*ClusterManager) ValidateKubeConfigFor ¶
func (c *ClusterManager) ValidateKubeConfigFor( ctx context.Context, config *KubeConfig, ) (string, error)
ValidateKubeConfigFor validates the provided KubeConfig.
func (*ClusterManager) ValidateKubeConfigWithYAML ¶
func (c *ClusterManager) ValidateKubeConfigWithYAML( ctx context.Context, plain string, ) (string, error)
ValidateKubeConfigWithYAML unmarshals YAML content into KubeConfig and validates it.
type ClusterSummary ¶
type ContextEntry ¶
ContextEntry represents each context entry in kubeconfig
type KubeConfig ¶
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 ¶
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