Documentation ¶
Index ¶
- func BindFlags(flags *pflag.FlagSet) clientcmd.ClientConfig
- func CallInNetNSWithSysfsRemounted(innerNS ns.NetNS, toCall func(ns.NetNS) error) error
- func GenIsoImage(isoPath string, volumeID string, srcDir string) error
- func GetBoolFromString(str string) bool
- func GetFsStatsForPath(path string) (uint64, uint64, error)
- func GetK8sClientConfig(host string) (*rest.Config, error)
- func GetK8sClientset(config *rest.Config) (*kubernetes.Clientset, error)
- func Merge(base, override interface{}) interface{}
- func NewUUID() string
- func NewUUID5(nsUUID, s string) string
- func ReadJSON(filename string, v interface{}) error
- func Stringify(value interface{}) string
- func ToJSON(o interface{}) string
- func ToJSONUnindented(o interface{}) string
- func WaitForProcess(procFile string) (int, error)
- func WaitLoop(test func() (bool, error), retryPeriod time.Duration, timeout time.Duration, ...) error
- func WriteFiles(targetDir string, content map[string][]byte) error
- func WriteJSON(filename string, v interface{}, perm os.FileMode) error
- type Command
- type Commander
- type MountPointChecker
- type Mounter
- type ShellTemplate
- type VFInfo
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
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 ¶
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
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
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
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 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 ReadJSON ¶ added in v1.0.0
ReadJSON converts data from file specified by `filename` to provided as `v` interface.
func Stringify ¶ added in v1.4.2
func Stringify(value interface{}) string
Stringify returns string representation for provided value.
func ToJSON ¶ added in v1.3.0
func ToJSON(o interface{}) string
ToJSON converts the specified object to indented JSON. It panics in case if the object connot be converted.
func ToJSONUnindented ¶ added in v1.3.0
func ToJSONUnindented(o interface{}) string
ToJSONUnindented converts the specified object to unindented JSON. It panics in case if the object connot be converted.
func WaitForProcess ¶ added in v0.9.0
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 ¶
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.
Types ¶
type Command ¶ added in v1.4.0
type Command interface { // Output runs the command and returns its standard output. // If stdin is non-nil, it's passed to the command's standed // input. Any returned error will usually be of type // *ExitError with ExitError.Stderr containing the stderr // output of the command. Run(stdin []byte) ([]byte, error) }
Command represents an external command being prepared or run.
type Commander ¶ added in v1.4.0
type Commander interface { // Command returns an isntance of Command to execute the named // program with the given arguments. Command(name string, arg ...string) Command }
Commander is used to run external commands.
var DefaultCommander Commander = &defaultCommander{}
DefaultCommander is an implementation of Commander that runs the commands using exec.Command.
type MountPointChecker ¶ added in v1.4.2
type MountPointChecker interface { // CheckMountPointInfo checks if entry is a mountpoint (second returned value will be true) // and if so returns mountInfo for it. In other case it returns false as a second value. CheckMountPointInfo(string) (mountEntry, bool) // IsPathAnNs verifies if the path is a mountpoint with nsfs filesystem type IsPathAnNs(string) bool }
MountPointChecker is used to check if a directory entry is a mount point. It returns its source info and filesystem type.
var FakeMountPointChecker MountPointChecker = fakeMountPointChecker{}
FakeMountPointChecker is defined there for unittests
func NewMountPointChecker ¶ added in v1.4.2
func NewMountPointChecker() (MountPointChecker, error)
NewMountPointChecker returns a new instance of MountPointChecker
type Mounter ¶ added in v1.3.0
type Mounter interface { // Mount mounts the specified source under the target path. // For bind mounts, bind must be true. Mount(source string, target string, fstype string, bind bool) error // Unmount unmounts the specified target directory. If detach // is true, MNT_DETACH option is used (disconnect the // filesystem for the new accesses even if it's busy). Unmount(target string, detach bool) error }
Mounter defines mount/unmount interface
var NullMounter Mounter = &nullMounter{}
NullMounter is a mounter that's used for testing and does nothing instead of mounting/unmounting.
type ShellTemplate ¶ added in v1.3.0
ShellTemplate denotes a simple template used to generate shell commands. It adds 'shellquote' function to go-template that can be used to quote string values for the shell.
func NewShellTemplate ¶ added in v1.3.0
func NewShellTemplate(text string) *ShellTemplate
NewShellTemplate returns a new shell template using the specified text. It panics if the template doesn't compile.
func (*ShellTemplate) ExecuteToString ¶ added in v1.3.0
func (t *ShellTemplate) ExecuteToString(data interface{}) (string, error)
ExecuteToString executes the template using the specified data and returns the result as a string.
func (*ShellTemplate) MustExecuteToString ¶ added in v1.3.0
func (t *ShellTemplate) MustExecuteToString(data interface{}) string
MustExecuteToString executes the template using the specified data and returns the result as a string. It panics upon an error
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
ParseIPLinkOutput takes output of `ip link show somelink` and parses it to list of VFInfo structures