utils

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToFile

func BytesToFile(path, name string, data []byte) error

BytesToFile Bytes Conversion File

func ClusterRoleBindingFromSubjects added in v1.2.0

func ClusterRoleBindingFromSubjects(clusterRoleBindingName, clusterRoleName string, sub []rbacv1.Subject, labels map[string]string) *rbacv1.ClusterRoleBinding

ClusterRoleBindingFromSubjects ClusterRoleBinding Subjects

func ClusterRoleFromRules added in v1.2.0

func ClusterRoleFromRules(name string, rules []rbacv1.PolicyRule, labels map[string]string) *rbacv1.ClusterRole

ClusterRoleFromRules ClusterRole Rules

func CreateBasic

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

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

func CreateIfNotExistClusterRole added in v1.2.0

func CreateIfNotExistClusterRole(clientSet *kubernetes.Clientset, role *rbacv1.ClusterRole) error

CreateIfNotExistClusterRole create ClusterRole when it doesn't exist

func CreateIfNotExistClusterRoleBinding added in v1.2.0

func CreateIfNotExistClusterRoleBinding(clientSet *kubernetes.Clientset, binding *rbacv1.ClusterRoleBinding) error

CreateIfNotExistClusterRoleBinding create ClusterRoleBinding when it doesn't exist

func CreateOrUpdateConfigMap added in v1.3.0

func CreateOrUpdateConfigMap(clientSet *kubernetes.Clientset, cm *corev1.ConfigMap) error

CreateOrUpdateConfigMap creates a ConfigMap if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateRole added in v1.3.0

func CreateOrUpdateRole(clientSet *kubernetes.Clientset, role *rbacv1.Role) error

CreateOrUpdateRole creates a Role if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateRoleBinding added in v1.3.0

func CreateOrUpdateRoleBinding(clientSet *kubernetes.Clientset, roleBinding *rbacv1.RoleBinding) error

CreateOrUpdateRoleBinding creates a RoleBinding if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateWithCerts

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

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

func DeCompress

func DeCompress(file, targetPath string) error

DeCompress decompress tar.gz

func DownloadFile

func DownloadFile(url, filePath string) error

DownloadFile Download files via URL

func FileToBytes

func FileToBytes(path, name string) ([]byte, error)

FileToBytes File Conversion Bytes

func FlagsDNS

func FlagsDNS(dns string) []string

FlagsDNS Receive master external DNS from command flags

func FlagsIP

func FlagsIP(ip string) []net.IP

FlagsIP Receive master external IP from command flags

func GenExamples

func GenExamples(path, parentCommand, printRegisterCommand string)

GenExamples Generate sample files

func InternetIP

func InternetIP() (net.IP, error)

InternetIP Current host Internet IP.

func IsExist added in v1.0.2

func IsExist(path string) bool

IsExist Determine whether the path exists

func ListFiles

func ListFiles(path string) []string

ListFiles traverse directory files

func MapToString

func MapToString(labels map[string]string) string

MapToString labels to string

func NewAPIRegistrationClient

func NewAPIRegistrationClient(c *rest.Config) (*aggregator.Clientset, error)

NewAPIRegistrationClient apiregistration ClientSet

func NewCRDsClient

func NewCRDsClient(c *rest.Config) (*clientset.Clientset, error)

NewCRDsClient clientset ClientSet

func NewClientSet

func NewClientSet(c *rest.Config) (*kubernetes.Clientset, error)

NewClientSet Kubernetes ClientSet

func RestConfig

func RestConfig(context, kubeconfigPath string) (*rest.Config, error)

RestConfig Kubernetes kubeconfig

func StaticYamlToJSONByte

func StaticYamlToJSONByte(staticYaml string) []byte

StaticYamlToJSONByte Static yaml file conversion JSON Byte

func StringToMap

func StringToMap(labels string) map[string]string

StringToMap string to label

func StringToNetIP

func StringToNetIP(addr string) net.IP

StringToNetIP String To NetIP

func WriteKubeConfigFromSpec

func WriteKubeConfigFromSpec(serverURL, userName, clusterName, kubeconfigPath, kubeconfigName string, caCert []byte, clientKey []byte, clientCert []byte) error

WriteKubeConfigFromSpec creates a kubeconfig object from a kubeConfigSpec and writes it to the given writer.

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

Jump to

Keyboard shortcuts

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