util

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendDotFlatMapKeyFormatter

func AppendDotFlatMapKeyFormatter(path, newPart string) string

e.g. path = "", newPart = "root". Return: "root"

path = "root", newPart = "child". Return: "root.child"

func ApplyCmdWithError added in v1.0.0

func ApplyCmdWithError(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command

ApplyCmdWithError runs the kubectl apply command and returns an error, if any.

func CapitalizeUnderscoreFlatMapKeyFormatter

func CapitalizeUnderscoreFlatMapKeyFormatter(path, newPart string) string

func GetBearerToken

func GetBearerToken(in *restclient.Config, explicitKubeConfigPath string, serviceAccountName string) (token string, username string, err error)

func GetDeployedWebURL

func GetDeployedWebURL(yamlFile *DynamicYaml) (string, error)

func GetWildCardDNS

func GetWildCardDNS(url string) string

func GetYamlStringValue added in v1.0.0

func GetYamlStringValue(mapping map[string]interface{}, key string) (*string, error)

GetYamlStringValue will attempt to get the key from the input mapping and return it as a lowercase string If the key does not exist, nil is returned, with no error If the value exists, but is not a string, an error is returned

func IsApplicationControllerManagerRunning added in v1.0.0

func IsApplicationControllerManagerRunning(c *kubernetes.Clientset) (bool, error)

IsApplicationControllerManagerRunning checks if the application-controller-manager pod is running

func IsIpv4

func IsIpv4(host string) bool

func KubectlApply

func KubectlApply(filePath string) (err error)

KubectlApply applies the yaml at the given filePath

func KubectlDelete added in v0.17.0

func KubectlDelete(filePath string) (err error)

KubectlDelete run's kubectl delete using the input filePath

func KubectlGet

func KubectlGet(resource string, resourceName string, namespace string, extraArgs []string, flags map[string]interface{}) (stdout string, stderr string, err error)

func KubectlPatch added in v1.0.0

func KubectlPatch(namespace string, resource string, filePath string) (err error)

KubectlPatch patches a resource. resource example: serviceaccount/default

func ListOnepanelEnabledNamespaces added in v1.0.2

func ListOnepanelEnabledNamespaces(c *kubernetes.Clientset) (namespaces []string, err error)

func LowerCamelCaseFlatMapKeyFormatter

func LowerCamelCaseFlatMapKeyFormatter(path, newPart string) string

func LowerCamelCaseStringFormat added in v0.12.0

func LowerCamelCaseStringFormat(value, separator string) string

LowerCamelCaseStringFormat takes a string, splits it by the separator and joins the pieces using LowerCamelCaseFlatMapKeyFormatter

func NamespacesExist added in v1.0.0

func NamespacesExist(c *kubernetes.Clientset, namespaces ...string) (bool, error)

NamespacesExist checks if the cluster has the input namespaces

func NamespacesToCheck added in v1.0.0

func NamespacesToCheck(yamlFile *DynamicYaml) []string

NamespacesToCheck returns an array of namespaces to check depending on what's present in the yamlFile

func NewKubernetesClient added in v1.0.0

func NewKubernetesClient() (*kubernetes.Clientset, error)

NewKubernetesClient creates a kubernetes client with the config returned from NewConfig

func NodeValueToActual

func NodeValueToActual(node *yaml.Node) (interface{}, error)

func PrintClusterNetworkInformation added in v1.0.0

func PrintClusterNetworkInformation(c *kubernetes.Clientset, url string)

PrintClusterNetworkInformation prints the ip address of the cluster and network DNS configuration required

func RandASCIIBytes added in v0.18.0

func RandASCIIBytes(n int) ([]byte, error)

RandASCIIBytes generates n rando ASCII bytes adapted from source: https://github.com/kpbird/golang_random_string/blob/master/main.go

func RandASCIIString added in v0.18.0

func RandASCIIString(n int) (string, error)

RandASCIIString returns a rnadom string up to n characters

func RefreshAuthToken

func RefreshAuthToken(in *restclient.Config) error

func RefreshTokenIfExpired

func RefreshTokenIfExpired(restConfig *restclient.Config, explicitPath, curentToken string) (string, error)

func ReloadKubeConfig

func ReloadKubeConfig(explicitPath string) clientcmd.ClientConfig

Types

type Config

type Config = restclient.Config

func NewConfig

func NewConfig() (config *Config, err error)

NewConfig creates a new, default, configuration for kubernetes

type DynamicYaml

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

func LoadDynamicYamlFromFile

func LoadDynamicYamlFromFile(filePath string) (*DynamicYaml, error)

func LoadDynamicYamlFromString

func LoadDynamicYamlFromString(input string) (*DynamicYaml, error)

func (*DynamicYaml) Delete

func (d *DynamicYaml) Delete(key string) error

func (*DynamicYaml) DeleteByParts

func (d *DynamicYaml) DeleteByParts(parts ...string) error

func (*DynamicYaml) DeleteByString

func (d *DynamicYaml) DeleteByString(key, separator string) error

func (*DynamicYaml) FindMissingKeys added in v0.17.0

func (d *DynamicYaml) FindMissingKeys(keys ...string) []string

FindMissingKeys will return an array of the keys that are not in the manifest

func (*DynamicYaml) Flatten

func (d *DynamicYaml) Flatten(keyFormatter FlatMapKeyFormatter) map[string]NodePair

func (*DynamicYaml) FlattenRequiredDefault

func (d *DynamicYaml) FlattenRequiredDefault()

FlattenRequiredDefault goes through the data and finds values with a default it then assigns the default value to the key in the data so when it is serialized it has that set. this also removes the subdata, so if you have s3.bucket.default, and s3.bucket.test, only s3.bucket will be present after.

func (*DynamicYaml) FlattenToKeyValue

func (d *DynamicYaml) FlattenToKeyValue(keyFormatter FlatMapKeyFormatter) map[string]interface{}

func (*DynamicYaml) Get

func (d *DynamicYaml) Get(key string) (keyNode, value *yaml.Node)

func (*DynamicYaml) GetByParts

func (d *DynamicYaml) GetByParts(parts ...string) (key, value *yaml.Node)

func (*DynamicYaml) GetValue

func (d *DynamicYaml) GetValue(key string) (value *yaml.Node)

func (*DynamicYaml) GetValueByParts

func (d *DynamicYaml) GetValueByParts(parts ...string) (value *yaml.Node)

func (*DynamicYaml) GetValueWithSeparator

func (d *DynamicYaml) GetValueWithSeparator(key, separator string) (value *yaml.Node)

func (*DynamicYaml) GetWithSeparator

func (d *DynamicYaml) GetWithSeparator(key, separator string) (keyNode, value *yaml.Node)

func (*DynamicYaml) HasKey

func (d *DynamicYaml) HasKey(key string) bool

func (*DynamicYaml) HasKeys

func (d *DynamicYaml) HasKeys(keys ...string) bool

func (*DynamicYaml) Merge

func (d *DynamicYaml) Merge(items ...*DynamicYaml)

Merge will merge two DynamicYaml's together. If keys already exist, the source is kept.

func (*DynamicYaml) Put

func (d *DynamicYaml) Put(key string, value interface{}) *yaml.Node

func (*DynamicYaml) PutByParts

func (d *DynamicYaml) PutByParts(parts []string, value interface{}) *yaml.Node

func (*DynamicYaml) PutByPartsNode

func (d *DynamicYaml) PutByPartsNode(parts []string, value *yaml.Node) (*yaml.Node, error)

func (*DynamicYaml) PutNode

func (d *DynamicYaml) PutNode(key string, value *yaml.Node) (*yaml.Node, error)

func (*DynamicYaml) PutWithSeparator

func (d *DynamicYaml) PutWithSeparator(key string, value interface{}, separator string) *yaml.Node

func (*DynamicYaml) PutWithSeparatorNode

func (d *DynamicYaml) PutWithSeparatorNode(key string, value *yaml.Node, separator string) (*yaml.Node, error)

func (*DynamicYaml) SetTopComment added in v0.15.0

func (d *DynamicYaml) SetTopComment(comment string) error

SetTopComment sets the topmost comment in the resulting yaml

func (*DynamicYaml) Sort

func (d *DynamicYaml) Sort()

func (*DynamicYaml) String

func (d *DynamicYaml) String() (string, error)

type FlatMapKeyFormatter

type FlatMapKeyFormatter func(path, newPart string) string

Path might be an empty string, denoting the start of a path. In that case, it is expected that newPart in some formatted form will be return. e.g. path = "", newPart = "root". Return: "root"

path = "root", newPart = "child". Return: "root.child"

type NodePair

type NodePair struct {
	Key   *yaml.Node
	Value *yaml.Node
}

Jump to

Keyboard shortcuts

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