utils

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MaxRespBodyLength is the max length of http response body
	MaxRespBodyLength = 1 << 20 // 1 MiB
)

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, annotations map[string]string, 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 CreateDeployAndWait added in v1.10.0

func CreateDeployAndWait(kubeClientSet kubernetes.Interface, deployment *appsv1.Deployment, waitComponentReadyTimeout int) error

CreateDeployAndWait Create deployment and then waiting for ready

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 ParseIP added in v1.1.5

func ParseIP(s string) (net.IP, int, error)

ParseIP parses an IP address and returns whether it is a v4 or v6 IP address

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