util

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2025 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ClientFactory creates a new Kubernetes clientset from the provided kubeconfig.
	ClientFactory = func(kubeconfig *rest.Config) (clientset.Interface, error) {
		return clientset.NewForConfig(kubeconfig)
	}

	// BuildClientFromSecretRefFactory constructs a Kubernetes clientset using a LocalSecretReference.
	BuildClientFromSecretRefFactory = func(client clientset.Interface, ref *operatorv1alpha1.LocalSecretReference) (clientset.Interface, error) {
		return BuildClientFromSecretRef(client, ref)
	}
)

Functions

func AdminKarmadaConfigSecretName added in v1.13.0

func AdminKarmadaConfigSecretName(karmadaInstanceName string) string

AdminKarmadaConfigSecretName returns the secret name for the Karmada admin kubeconfig for the specified Karmada instance.

func BuildClientFromSecretRef added in v1.8.0

func BuildClientFromSecretRef(client clientset.Interface, ref *operatorv1alpha1.LocalSecretReference) (clientset.Interface, error)

BuildClientFromSecretRef builds a clientset from the secret reference.

func ComponentKarmadaConfigSecretName added in v1.13.0

func ComponentKarmadaConfigSecretName(karmadaComponent string) string

ComponentKarmadaConfigSecretName returns the secret name of a Karmada component's kubeconfig

func ContainAllTasks added in v1.12.0

func ContainAllTasks(tasks, subset []workflow.Task) error

ContainAllTasks checks if all tasks in the subset are present in the tasks slice. Returns an error if any subset task is not found; nil otherwise.

func ContainsAllValues added in v1.12.0

func ContainsAllValues(container interface{}, values interface{}) bool

ContainsAllValues checks if all values in the 'values' slice exist in the 'container' slice or array.

func CreateBasic

func CreateBasic(serverURL, clusterName, userName string, caCert []byte) *clientcmdapi.Config

CreateBasic creates a basic, general KubeConfig object that then can be extended

func CreateWithCerts

func CreateWithCerts(serverURL, clusterName, userName string, caCert []byte, clientKey []byte, clientCert []byte) *clientcmdapi.Config

CreateWithCerts creates a KubeConfig object with access to the API server with client certificates

func DeepEqualTasks added in v1.12.0

func DeepEqualTasks(t1, t2 workflow.Task) error

DeepEqualTasks checks if two workflow.Task instances are deeply equal. It returns an error if they differ, or nil if they are equal. The comparison includes the task name, RunSubTasks flag, and the length and contents of the Tasks slice. Function references and behavior are not compared; only the values of the specified fields are considered. Any differences are detailed in the returned error.

func DownloadFile

func DownloadFile(url, filePath string) error

DownloadFile Download files via URL

func EtcdCertSecretName

func EtcdCertSecretName(karmadaInstanceName string) string

EtcdCertSecretName returns the secret name for etcd certificates for the specified Karmada instance.

func GetAPIServiceIP

func GetAPIServiceIP(clientset clientset.Interface) (string, error)

GetAPIServiceIP returns a valid node IP address.

func GetControlplaneEndpoint

func GetControlplaneEndpoint(address, port string) (string, error)

GetControlplaneEndpoint parses an Endpoint and returns it as a string, or returns an error in case it cannot be parsed.

func IsInCluster added in v1.8.0

func IsInCluster(hostCluster *operatorv1alpha1.HostCluster) bool

IsInCluster checks if the specified host cluster is the local cluster. It returns true if: - the hostCluster is nil; - or its SecretRef is nil; - or the SecretRef's Name is an empty string. This indicates that the remote cluster is either not configured or not identifiable as the local cluster.

func KarmadaAPIServerName

func KarmadaAPIServerName(karmadaInstanceName string) string

KarmadaAPIServerName returns the name of the Karmada API server for the specified Karmada instance.

func KarmadaAggregatedAPIServerName

func KarmadaAggregatedAPIServerName(karmadaInstanceName string) string

KarmadaAggregatedAPIServerName returns the name of the Karmada aggregated API server for the specified Karmada instance.

func KarmadaCertSecretName

func KarmadaCertSecretName(karmadaInstanceName string) string

KarmadaCertSecretName returns the secret name of Karmada certificate for the specified Karmada instance.

func KarmadaControllerManagerName

func KarmadaControllerManagerName(karmadaInstanceName string) string

KarmadaControllerManagerName returns the name of the Karmada controller manager for the specified Karmada instance.

func KarmadaDeschedulerName

func KarmadaDeschedulerName(karmadaInstanceName string) string

KarmadaDeschedulerName returns the name of the Karmada descheduler for the specified Karmada instance.

func KarmadaEtcdClientName

func KarmadaEtcdClientName(karmadaInstanceName string) string

KarmadaEtcdClientName returns the name of the Karmada etcd client for the specified Karmada instance.

func KarmadaEtcdName

func KarmadaEtcdName(karmadaInstanceName string) string

KarmadaEtcdName returns the name of the Karmada etcd instance for the specified Karmada instance.

func KarmadaMetricsAdapterName added in v1.7.0

func KarmadaMetricsAdapterName(karmadaInstanceName string) string

KarmadaMetricsAdapterName returns the name of the Karmada metrics adapter for the specified Karmada instance.

func KarmadaSchedulerName

func KarmadaSchedulerName(karmadaInstanceName string) string

KarmadaSchedulerName returns the name of the Karmada scheduler for the specified Karmada instance.

func KarmadaSearchAPIServerName added in v1.9.0

func KarmadaSearchAPIServerName(karmadaInstanceName string) string

KarmadaSearchAPIServerName returns the name of the Karmada search API server for the specified Karmada instance.

func KarmadaSearchName added in v1.9.0

func KarmadaSearchName(karmadaInstanceName string) string

KarmadaSearchName returns the name of the Karmada search component for the specified Karmada instance.

func KarmadaWebhookName

func KarmadaWebhookName(karmadaInstanceName string) string

KarmadaWebhookName returns the name of the Karmada webhook for the specified Karmada instance.

func KubeControllerManagerName

func KubeControllerManagerName(karmadaInstanceName string) string

KubeControllerManagerName returns the name of the kube-controller-manager for the specified Karmada instance.

func ListFiles

func ListFiles(path string) []os.FileInfo

ListFiles traverse directory files

func ParseTemplate

func ParseTemplate(strtmpl string, obj interface{}) ([]byte, error)

ParseTemplate validates and parses passed as argument template

func PathExists

func PathExists(path string) (bool, error)

PathExists check whether the path is exist

func ReadYamlFile

func ReadYamlFile(path string) ([]byte, error)

ReadYamlFile ready file given path with yaml format

func ReplaceYamlForRegs added in v1.13.0

func ReplaceYamlForRegs(path string, replacements map[*regexp.Regexp]string) ([]byte, error)

ReplaceYamlForRegs replace content of yaml file with Regexps

func Unpack

func Unpack(file, targetPath string) error

Unpack unpack a given file to target path

func WebhookCertSecretName

func WebhookCertSecretName(karmadaInstanceName string) string

WebhookCertSecretName returns the secret name for Karmada webhook certificates for the specified Karmada instance.

Types

type Downloader

type Downloader struct {
	io.Reader
	Total   int64
	Current int64
}

Downloader Download progress

func (*Downloader) Read

func (d *Downloader) Read(p []byte) (n int, err error)

Read Implementation of Downloader

type FileExtInfo added in v1.7.2

type FileExtInfo struct {
	os.FileInfo
	AbsPath string
}

FileExtInfo file info with absolute path

func ListFileWithSuffix added in v1.7.2

func ListFileWithSuffix(path, suffix string) []FileExtInfo

ListFileWithSuffix traverse directory files with suffix

type Namefunc

type Namefunc func(karmada string) string

Namefunc defines a function that generates a resource name based on the Karmada resource name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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