utils

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindFlags added in v1.1.0

func BindFlags(flags *pflag.FlagSet) clientcmd.ClientConfig

BindFlags applies standard Go flags and the flags used by kubeclient to the specified FlagSet.

func CallInNetNSWithSysfsRemounted added in v1.1.2

func CallInNetNSWithSysfsRemounted(innerNS ns.NetNS, toCall func(ns.NetNS) error) error

CallInNetNSWithSysfsRemounted enters particular netns, adds new sysfs mount on top of /sys, calls "toCall" callback in this netns removing temporary mount on /sys at the end.

func GenIsoImage

func GenIsoImage(isoPath string, volumeID string, srcDir string) error

GenIsoImage generates an ISO 9660 filesystem image containing files from srcDir. It uses specified volumeID as the volume id.

func GetBoolFromString added in v0.9.0

func GetBoolFromString(str string) bool

GetBoolFromString returns false if str is an empty string or is equal to one of: "0", "f" or "false". Case doesnt't matter anythging else is true

func GetFsStatsForPath added in v1.2.0

func GetFsStatsForPath(path string) (uint64, uint64, error)

GetFsStatsForPath returns the info about inode usage and space usage (in bytes) for the filesystem that contains the provided path.

func GetK8sClientConfig added in v0.9.0

func GetK8sClientConfig(host string) (*rest.Config, error)

GetK8sClientConfig returns config that is needed to access k8s

func GetK8sClientset added in v0.9.0

func GetK8sClientset(config *rest.Config) (*kubernetes.Clientset, error)

GetK8sClientset returns clientset for standard k8s APIs

func MapToJSON added in v1.0.0

func MapToJSON(m map[string]interface{}) string

MapToJSON converts the specified map object to indented JSON. It panics in case if the map connot be converted.

func MapToJSONUnindented added in v1.0.0

func MapToJSONUnindented(m map[string]interface{}) string

MapToJSONUnindented converts the specified map object to unindented JSON. It panics in case if the map connot be converted.

func Merge added in v0.9.0

func Merge(base, override interface{}) interface{}

Merge will take two data sets and merge them together - returning a new data set

func NewUUID added in v1.0.0

func NewUUID() string

NewUUID returns a new uuid4 as a string

func NewUUID5 added in v1.0.0

func NewUUID5(nsUUID, s string) string

NewUUID5 returns a new uuid5 as a string

func ReadJSON added in v1.0.0

func ReadJSON(filename string, v interface{}) error

ReadJSON converts data from file specified by `filename` to provided as `v` interface.

func WaitForProcess added in v0.9.0

func WaitForProcess(procFile string) (int, error)

WaitForProcess waits for the following conditions to be true at the same time:

  • the specified procFile is readable and contains two numeric values separated by space, PID and start time in jiffies (field 22 in /proc/PID/stat, starting from 1)
  • the process with the PID read from procFile exists and has start time equal to the start time read from procFile

This avoids possible problems with stale procFile that could happen if only PID was stored there. The command can be used in shell script to generate the "procfile" for the current shell: /bin/sh -c 'echo "$$ `cut -d" " -f22 /proc/$$/stat`"'

func WaitLoop

func WaitLoop(test func() (bool, error), retryPeriod time.Duration, timeout time.Duration, clock clockwork.Clock) error

WaitLoop executes test func in loop until it returns error, true, or the timeout elapses. clock argument denotes a clock object to use for waiting. When clock is nil, WaitLoop uses clockwork.NewRealClock()

func WriteFiles

func WriteFiles(targetDir string, content map[string][]byte) error

WriteFiles writes the files specified as a map under `targetDir`. The keys of the map are subpaths and values are file contents. WriteFiles automatically creates any non-existing directories mentioned in subpaths.

func WriteJSON added in v1.0.0

func WriteJSON(filename string, v interface{}, perm os.FileMode) error

WriteJSON saves under specified `filename` data provided in `v` interface setting file mode according to `perm` value.

Types

type VFInfo added in v1.1.2

type VFInfo struct {
	// ID contains VF number
	ID int
	// Mac contains hardware mac address
	Mac string
	// VLanID contains vlan id
	VLanID int
	// SpoofChecking holds status of spoof checking
	SpoofChecking bool
	// LinkState holds state of link (nil means auto)
	LinkState *bool
}

VFInfo contains information about particular VF

func ParseIPLinkOutput added in v1.1.2

func ParseIPLinkOutput(data []byte) ([]VFInfo, error)

ParseIPLinkOutput takes output of `ip link show somelink` and parses it to list of VFInfo structures

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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