Documentation ¶
Index ¶
- func FilterStringsByPrefix(prefix string, values []string) []string
- func NewTestIOStreams() (IOStreams, *SafeBytesBuffer, *SafeBytesBuffer, *SafeBytesBuffer)
- func ShellEscape(values ...interface{}) string
- func StripUnsafe(s string) string
- type Clock
- type Factory
- type FactoryImpl
- func (f *FactoryImpl) Clock() Clock
- func (f *FactoryImpl) Context() context.Context
- func (f *FactoryImpl) GardenHomeDir() string
- func (f *FactoryImpl) Manager() (target.Manager, error)
- func (f *FactoryImpl) PublicIPs(ctx context.Context) ([]string, error)
- func (f *FactoryImpl) TargetFlags() target.TargetFlags
- type IOStreams
- type RealClock
- type SafeBytesBuffer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterStringsByPrefix ¶
func NewTestIOStreams ¶
func NewTestIOStreams() (IOStreams, *SafeBytesBuffer, *SafeBytesBuffer, *SafeBytesBuffer)
NewTestIOStreams returns a valid IOStreams and in, out, errout buffers for unit tests.
func ShellEscape ¶
func ShellEscape(values ...interface{}) string
ShellEscape returns a shell-escaped version of the given string. It also removes non-printable characters.
func StripUnsafe ¶
StripUnsafe remove non-printable characters from the string.
Types ¶
type Factory ¶
type Factory interface { // Context returns the root context any command should use. Context() context.Context // Clock returns a clock that provides access to the current time. Clock() Clock // GardenHomeDir returns the gardenctl home directory for the executing user. GardenHomeDir() string // Manager returns the target manager used to read and change the currently targeted system. Manager() (target.Manager, error) // PublicIPs returns the current host's public IP addresses. It's // recommended to provide a context with a timeout/deadline. The // returned slice can contain IPv6, IPv4 or both, in no particular // order. PublicIPs(context.Context) ([]string, error) // TargetFlags returns the TargetFlags to which the cobra flags are bound allowing the user to // override the target configuration stored on the filesystem. TargetFlags() target.TargetFlags }
Factory provides abstractions that allow the command to be extended across multiple types of resources and different API sets.
type FactoryImpl ¶
type FactoryImpl struct { // GardenHomeDirectory is the home directory for all gardenctl // related files. While some files can be explicitly loaded from // different locations, cache files will always be placed inside // the garden home. GardenHomeDirectory string // ConfigFile is the location of the gardenctlv2 configuration file. // This can be overridden via a CLI flag and defaults to ~/.garden/gardenctlv2.yaml // if empty. ConfigFile string // contains filtered or unexported fields }
FactoryImpl implements util.Factory interface.
func NewFactoryImpl ¶
func NewFactoryImpl() *FactoryImpl
func (*FactoryImpl) Clock ¶
func (f *FactoryImpl) Clock() Clock
func (*FactoryImpl) Context ¶
func (f *FactoryImpl) Context() context.Context
func (*FactoryImpl) GardenHomeDir ¶
func (f *FactoryImpl) GardenHomeDir() string
func (*FactoryImpl) PublicIPs ¶
func (f *FactoryImpl) PublicIPs(ctx context.Context) ([]string, error)
func (*FactoryImpl) TargetFlags ¶
func (f *FactoryImpl) TargetFlags() target.TargetFlags
type IOStreams ¶
type IOStreams struct { // In think, os.Stdin In io.Reader // Out think, os.Stdout Out io.Writer // ErrOut think, os.Stderr ErrOut io.Writer }
IOStreams provides the standard names for iostreams. This is useful for embedding and for unit testing. Inconsistent and different names make it hard to read and review code.
func NewIOStreams ¶
func NewIOStreams() IOStreams
NewIOStreams returns a valid IOStreams and with the default stdin/out/err streams.
type SafeBytesBuffer ¶
type SafeBytesBuffer struct {
// contains filtered or unexported fields
}
SafeBytesBuffer is a bytes.Buffer that is safe for use in multiple goroutines.
func (*SafeBytesBuffer) Read ¶
func (s *SafeBytesBuffer) Read(p []byte) (n int, err error)
Read reads the next len(p) bytes from the buffer or until the buffer is drained. The return value n is the number of bytes read. If the buffer has no data to return, err is io.EOF (unless len(p) is zero); otherwise it is nil.
func (*SafeBytesBuffer) String ¶
func (s *SafeBytesBuffer) String() string
String returns the contents of the unread portion of the buffer as a string. If the Buffer is a nil pointer, it returns "<nil>".
To build strings more efficiently, see the strings.Builder type.