{"modulePath":"github.com/stackpointcloud/kubernetes","version":"v1.3.4","isLatest":true,"isStandardLibrary":false,"goos":"linux","goarch":"amd64","docs":"# package util\n\nPackage util implements various utility functions used in both testing and implementation of Kubernetes. Package util may not depend on any other package in the Kubernetes package tree.\n\n## Functions\n\n```go\nfunc AllPtrFieldsNil(obj interface{}) bool\n```\nTests whether all pointer fields in a struct are nil.  This is useful when, for example, an API struct is handled by plugins which need to distinguish \"no plugin accepted this spec\" from \"this spec is empty\".\n\nThis function is only valid for structs and pointers to structs.  Any other type will cause a panic.  Passing a typed nil pointer will return true.\n\n```go\nfunc ApplyRLimitForSelf(maxOpenFiles uint64)\n```\n\n```go\nfunc CompileRegexps(regexpStrings []string) ([]*regexp.Regexp, error)\n```\nTakes a list of strings and compiles them into a list of regular expressions\n\n```go\nfunc ExecuteTemplate(w io.Writer, templateText string, data interface{}) error\n```\nExecuteTemplate executes templateText with data and output written to w.\n\n```go\nfunc ExecuteTemplateToString(templateText string, data interface{}) (string, error)\n```\n\n```go\nfunc FileExists(filename string) (bool, error)\n```\n\n```go\nfunc FlushLogs()\n```\nFlushLogs flushes logs immediately.\n\n```go\nfunc InitLogs()\n```\nInitLogs initializes logs the way we want for kubernetes.\n\n```go\nfunc Int32Ptr(i int32) *int32\n```\nInt32Ptr returns a pointer to an int32\n\n```go\nfunc Int32PtrDerefOr(ptr *int32, def int32) int32\n```\nInt32PtrDerefOr dereference the int32 ptr and returns it i not nil, else returns def.\n\n```go\nfunc IntPtr(i int) *int\n```\nIntPtr returns a pointer to an int\n\n```go\nfunc IntPtrDerefOr(ptr *int, def int) int\n```\nIntPtrDerefOr dereference the int ptr and returns it i not nil, else returns def.\n\n```go\nfunc NewLogger(prefix string) *log.Logger\n```\nNewLogger creates a new log.Logger which sends logs to glog.Info.\n\n```go\nfunc NewUUID() types.UID\n```\n\n```go\nfunc ReadDirNoExit(dirname string) ([]os.FileInfo, []error, error)\n```\nborrowed from ioutil.ReadDir ReadDir reads the directory named by dirname and returns a list of directory entries, minus those with lstat errors\n\n```go\nfunc RunInResourceContainer(containerName string) error\n```\nCreates resource-only containerName if it does not already exist and moves the current process to it.\n\ncontainerName must be an absolute container name.\n\n```go\nfunc Umask(mask int) (old int, err error)\n```\n\n```go\nfunc UsingSystemdInitSystem() bool\n```\nDetects if using systemd as the init system Please note that simply reading /proc/1/cmdline can be misleading because some installation of various init programs can automatically make /sbin/init a symlink or even a renamed version of their main program. TODO(dchen1107): realiably detects the init system using on the system: systemd, upstart, initd, etc.\n\n## Types\n\n```go\ntype Clock interface {\n\tNow() time.Time\n\tSince(time.Time) time.Duration\n\tAfter(d time.Duration) \u003c-chan time.Time\n\tSleep(d time.Duration)\n\tTick(d time.Duration) \u003c-chan time.Time\n}\n```\nClock allows for injecting fake or real clocks into code that needs to do arbitrary things based on time.\n\n```go\ntype FakeClock struct {\n\t// contains filtered or unexported fields\n}\n```\nFakeClock implements Clock, but returns an arbitrary time.\n\n```go\nfunc NewFakeClock(t time.Time) *FakeClock\n```\n\n```go\nfunc (f *FakeClock) After(d time.Duration) \u003c-chan time.Time\n```\nFake version of time.After(d).\n\n```go\nfunc (f *FakeClock) HasWaiters() bool\n```\nReturns true if After has been called on f but not yet satisfied (so you can write race-free tests).\n\n```go\nfunc (f *FakeClock) Now() time.Time\n```\nNow returns f's time.\n\n```go\nfunc (f *FakeClock) SetTime(t time.Time)\n```\nSets the time.\n\n```go\nfunc (f *FakeClock) Since(ts time.Time) time.Duration\n```\nSince returns time since the time in f.\n\n```go\nfunc (f *FakeClock) Sleep(d time.Duration)\n```\n\n```go\nfunc (f *FakeClock) Step(d time.Duration)\n```\nMove clock by Duration, notify anyone that's called After or Tick\n\n```go\nfunc (f *FakeClock) Tick(d time.Duration) \u003c-chan time.Time\n```\n\n```go\ntype GlogWriter struct{}\n```\nGlogWriter serves as a bridge between the standard log package and the glog package.\n\n```go\nfunc (writer GlogWriter) Write(data []byte) (n int, err error)\n```\nWrite implements the io.Writer interface.\n\n```go\ntype IntervalClock struct {\n\tTime     time.Time\n\tDuration time.Duration\n}\n```\nIntervalClock implements Clock, but each invocation of Now steps the clock forward the specified duration\n\n```go\nfunc (*IntervalClock) After(d time.Duration) \u003c-chan time.Time\n```\nUnimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.\n\n```go\nfunc (i *IntervalClock) Now() time.Time\n```\nNow returns i's time.\n\n```go\nfunc (i *IntervalClock) Since(ts time.Time) time.Duration\n```\nSince returns time since the time in i.\n\n```go\nfunc (*IntervalClock) Sleep(d time.Duration)\n```\n\n```go\nfunc (*IntervalClock) Tick(d time.Duration) \u003c-chan time.Time\n```\nUnimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.\n\n```go\ntype LineDelimiter struct {\n\t// contains filtered or unexported fields\n}\n```\nA Line Delimiter is a filter that will\n\n```go\nfunc NewLineDelimiter(output io.Writer, delimiter string) *LineDelimiter\n```\nNewLineDelimiter allocates a new io.Writer that will split input on lines and bracket each line with the delimiter string.  This can be useful in output tests where it is difficult to see and test trailing whitespace.\n\n```go\nfunc (ld *LineDelimiter) Flush() (err error)\n```\nFlush all lines up until now.  This will assume insert a linebreak at the current point of the stream.\n\n```go\nfunc (ld *LineDelimiter) Write(buf []byte) (n int, err error)\n```\nWrite writes buf to the LineDelimiter ld. The only errors returned are ones encountered while writing to the underlying output stream.\n\n```go\ntype RealClock struct{}\n```\nRealClock really calls time.Now()\n\n```go\nfunc (RealClock) After(d time.Duration) \u003c-chan time.Time\n```\nSame as time.After(d).\n\n```go\nfunc (RealClock) Now() time.Time\n```\nNow returns the current time.\n\n```go\nfunc (RealClock) Since(ts time.Time) time.Duration\n```\nSince returns time since the specified timestamp.\n\n```go\nfunc (RealClock) Sleep(d time.Duration)\n```\n\n```go\nfunc (RealClock) Tick(d time.Duration) \u003c-chan time.Time\n```\n\n```go\ntype Runner struct {\n\t// contains filtered or unexported fields\n}\n```\nRunner is an abstraction to make it easy to start and stop groups of things that can be described by a single function which waits on a channel close to exit.\n\n```go\nfunc NewRunner(f ...func(stop chan struct{})) *Runner\n```\nNewRunner makes a runner for the given function(s). The function(s) should loop until the channel is closed.\n\n```go\nfunc (r *Runner) Start()\n```\nStart begins running.\n\n```go\nfunc (r *Runner) Stop()\n```\nStop stops running.\n\n```go\ntype StringFlag struct {\n\t// contains filtered or unexported fields\n}\n```\nStringFlag is a string flag compatible with flags and pflags that keeps track of whether it had a value supplied or not.\n\n```go\nfunc NewStringFlag(defaultVal string) StringFlag\n```\n\n```go\nfunc (f *StringFlag) Default(value string)\n```\n\n```go\nfunc (f StringFlag) Provided() bool\n```\n\n```go\nfunc (f *StringFlag) Set(value string) error\n```\n\n```go\nfunc (f StringFlag) String() string\n```\n\n```go\nfunc (f *StringFlag) Type() string\n```\n\n```go\nfunc (f StringFlag) Value() string\n```\n\n```go\ntype Trace struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc NewTrace(name string) *Trace\n```\n\n```go\nfunc (t *Trace) Log()\n```\n\n```go\nfunc (t *Trace) LogIfLong(threshold time.Duration)\n```\n\n```go\nfunc (t *Trace) Step(msg string)\n```\n\n```go\nfunc (t *Trace) TotalTime() time.Duration\n```\n\n","path":"github.com/stackpointcloud/kubernetes/pkg/util","name":"util","synopsis":"Package util implements various utility functions used in both testing and implementation of Kubernetes.","isRedistributable":true}
