util

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: Apache-2.0 Imports: 33 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 CapitalizeUnderscoreFlatMapKeyFormatter

func CapitalizeUnderscoreFlatMapKeyFormatter(path, newPart string) string

func DeploymentStatus

func DeploymentStatus(yamlFile *DynamicYaml) (ready bool, err error)

func GetBearerToken

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

func GetClusterIp

func GetClusterIp(url string)

func GetDeployedWebURL

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

func GetWildCardDNS

func GetWildCardDNS(url string) string

func IsIpv4

func IsIpv4(host string) bool

func KubectlApply

func KubectlApply(filePath string) (stdout string, stderr string, err error)

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 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 NodeValueToActual

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

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)

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) HideHidden added in v0.12.0

func (d *DynamicYaml) HideHidden() error

HideHidden goes through the vars in the yaml and removes any where hide is set to true

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