util

package
v0.0.0-...-a426a1e Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneMap

func CloneMap(src map[string]interface{}) map[string]interface{}

CloneMap returns clone of the provided map.

func CopyMap

func CopyMap(src, dest map[string]interface{})

CopyMap copies values from one map to the other.

func GetBool

func GetBool(dict map[string]interface{}, key string) (bool, error)

GetBool tries to return value from map cast to bool type. If value doesn't exist, error is returned.

func GetBoolOrDefault

func GetBoolOrDefault(dict map[string]interface{}, key string, defaultValue bool) (bool, error)

GetBoolOrDefault tries to return value from map cast to bool type. If value doesn't exist default value is used.

func GetDuration

func GetDuration(dict map[string]interface{}, key string) (time.Duration, error)

GetDuration tries to return value from map cast to duration type. If value doesn't exist, error is returned.

func GetDurationOrDefault

func GetDurationOrDefault(dict map[string]interface{}, key string, defaultValue time.Duration) (time.Duration, error)

GetDurationOrDefault tries to return value from map cast to duration type. If value doesn't exist default value is used.

func GetFloat64

func GetFloat64(dict map[string]interface{}, key string) (float64, error)

GetFloat64 tries to return value from map cast to float64 type. If value doesn't exist, error is returned.

func GetFloat64OrDefault

func GetFloat64OrDefault(dict map[string]interface{}, key string, defaultValue float64) (float64, error)

GetFloat64OrDefault tries to return value from map cast to float64 type. If value doesn't exist default value is used.

func GetInt

func GetInt(dict map[string]interface{}, key string) (int, error)

GetInt tries to return value from map cast to int type. If value doesn't exist, error is returned.

func GetIntOrDefault

func GetIntOrDefault(dict map[string]interface{}, key string, defaultValue int) (int, error)

GetIntOrDefault tries to return value from map cast to int type. If value doesn't exist default value is used.

func GetMap

func GetMap(dict map[string]interface{}, key string) (map[string]interface{}, error)

GetMap tries to return value from map of type map. If value doesn't exist, error is returned.

func GetMasterIPs

func GetMasterIPs(c clientset.Interface, addressType corev1.NodeAddressType) ([]string, error)

GetMasterIPs returns master node ips of the given type.

func GetMasterName

func GetMasterName(c clientset.Interface) (string, error)

GetMasterName returns master node name.

func GetSchedulableUntainedNodes

func GetSchedulableUntainedNodes(c clientset.Interface) ([]corev1.Node, error)

GetSchedulableUntainedNodes returns nodes in the cluster.

func GetSchedulableUntainedNodesNumber

func GetSchedulableUntainedNodesNumber(c clientset.Interface) (int, error)

GetSchedulableUntainedNodesNumber returns number of nodes in the cluster.

func GetString

func GetString(dict map[string]interface{}, key string) (string, error)

GetString tries to return value from map cast to string type. If value doesn't exist, error is returned.

func GetStringOrDefault

func GetStringOrDefault(dict map[string]interface{}, key string, defaultValue string) (string, error)

GetStringOrDefault tries to return value from map cast to string type. If value doesn't exist default value is used.

func IsErrKeyNotFound

func IsErrKeyNotFound(err error) bool

IsErrKeyNotFound returns true only if error type is ErrKeyNotFound.

func IsNodeSchedulableAndUntainted

func IsNodeSchedulableAndUntainted(node *corev1.Node) bool

IsNodeSchedulableAndUntainted returns true whether node is schedulable and untainted.

func LogClusterNodes

func LogClusterNodes(c clientset.Interface) error

LogClusterNodes prints nodes information (name, internal ip, external ip) to log.

func PrettyPrintJSON

func PrettyPrintJSON(data interface{}) (string, error)

PrettyPrintJSON converts given data into formatted json.

func RandomDNS1123String

func RandomDNS1123String(length int) string

RandomDNS1123String generates random string of a given length.

func SSH

func SSH(command string, node *v1.Node, stdin io.Reader) error

SSH executes command on a given node with stdin provided. If stdin is nil, the process reads from null device.

Types

type ErrKeyNotFound

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

ErrKeyNotFound is returned when key doesn't exists in a map.

func (*ErrKeyNotFound) Error

func (e *ErrKeyNotFound) Error() string

Erros is an error interface implementation.

Jump to

Keyboard shortcuts

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