Documentation ¶
Index ¶
- Constants
- Variables
- func AddPreRunE(cmd *cobra.Command, preRunE func(*cobra.Command, []string) error)
- func ConfigGlobals(cfg *internalconfig.RedSkyConfig, cmd *cobra.Command)
- func MapErrors(cmd *cobra.Command, f func(error) error)
- func SetExperimentsAPI(expAPI *experimentsv1alpha1.API, cfg *internalconfig.RedSkyConfig, ...) error
- func SetFlagValues(cmd *cobra.Command, flagName string, values ...string)
- func SetKubePrinter(printer *ResourcePrinter, cmd *cobra.Command, ...)
- func SetPrinter(meta TableMeta, printer *ResourcePrinter, cmd *cobra.Command, ...)
- func SetStreams(streams *IOStreams, cmd *cobra.Command)
- func StreamsPreRun(streams *IOStreams) func(cmd *cobra.Command, args []string)
- func WithContextE(runE func(context.Context) error) func(*cobra.Command, []string) error
- func WithoutArgsE(runE func() error) func(*cobra.Command, []string) error
- type AdditionalFormat
- type ContextServer
- type ContextServerOption
- type IOStreams
- type NoPrinterError
- type ResourcePrinter
- type ResourcePrinterFunc
- type ResourceReader
- type TableMeta
Constants ¶
const ( // PrinterAllowedFormats is the configuration key for setting the list of // allowed output formats. This must be a comma-delimited list of format // names that will reduce the default of formats (e.g. to allow only // JSON and YAML). PrinterAllowedFormats = "allowedFormats" // PrinterOutputFormat is the configuration key for setting the initial // output format. This value is effectively the default output format for // the command. It must be set to one of the allowed formats. PrinterOutputFormat = "outputFormat" // PrinterColumns is the configuration key for setting the initial column // list. This must be a comma-delimited list of column names that will be // displayed for tabular formats. PrinterColumns = "columns" // PrinterNoHeader is the configuration key for setting the initial // suppress header flag value. Suppressing the header on tabular formats // will prevent the header row from being emitted. PrinterNoHeader = "noHeader" // PrinterShowLabels is the configuration key for setting the initial // show labels flag value. Showing labels effects tabular formats which // would not otherwise have an explicit label column. The reason the label // column is special is because it is an arbitrary length list of key/value // pairs, showing it by default might cause undesired wrapping. PrinterShowLabels = "showLabels" // PrinterHideStatus is the configuration key for setting the initial // hide status flag value. Hiding the status effect the printing of // Kubernetes objects which have a `status` section that may need to be // suppressed from the output because representing an object at rest does // not need to include the status. PrinterHideStatus = "hideStatus" // PrinterStreamList is the configuration key for setting the initial // stream list status flag value. When printing Kubernetes objects this // may result in an YAML document stream instead of a `v1/List` object // being printed. PrinterStreamList = "streamList" )
Variables ¶
var OnlyVersion runtime.GroupVersioner = onlyVersion{}
OnlyVersion is a group version that only resolves if there is a single possible kind
Functions ¶
func AddPreRunE ¶
AddPreRunE adds an error returning pre-run function to the supplied command, existing pre-run actions will run AFTER the supplied function, and only if the supplied pre-run function does not return an error
func ConfigGlobals ¶
func ConfigGlobals(cfg *internalconfig.RedSkyConfig, cmd *cobra.Command)
ConfigGlobals sets up persistent globals for the supplied configuration
func MapErrors ¶
MapErrors wraps all of the error returning functions on the supplied command (and it's sub-commands) so that they pass any errors through the mapping function.
func SetExperimentsAPI ¶
func SetExperimentsAPI(expAPI *experimentsv1alpha1.API, cfg *internalconfig.RedSkyConfig, cmd *cobra.Command) error
SetExperimentsAPI creates a new experiments API interface from the supplied configuration
func SetFlagValues ¶ added in v1.9.2
SetFlagValues updates the named flag usage and completion to include possible choices.
func SetKubePrinter ¶
func SetKubePrinter(printer *ResourcePrinter, cmd *cobra.Command, additionalFormats map[string]AdditionalFormat)
SetKubePrinter assigns a client-go enabled resource printer during the pre-run of the supplied command
func SetPrinter ¶
func SetPrinter(meta TableMeta, printer *ResourcePrinter, cmd *cobra.Command, additionalFormats map[string]AdditionalFormat)
SetPrinter assigns the resource printer during the pre-run of the supplied command
func SetStreams ¶
SetStreams updates the streams using the supplied command
func StreamsPreRun ¶
StreamsPreRun is intended to be used as a pre-run function for commands when no other action is required
func WithContextE ¶
WithContextE wraps a function that accepts a context in one that accepts a command and argument slice
Types ¶
type AdditionalFormat ¶
type AdditionalFormat interface {
NewPrinter(columns []string, noHeader, showLabels bool) (ResourcePrinter, error)
}
AdditionalFormat is a factory function for registering new formats
type ContextServer ¶
type ContextServer struct {
// contains filtered or unexported fields
}
ContextServer is a server bound to a context lifecycle
func NewContextServer ¶
func NewContextServer(ctx context.Context, handler http.Handler, options ...ContextServerOption) *ContextServer
NewContextServer creates a new context server bound to the lifecycle of the supplied context
func (*ContextServer) ListenAndServe ¶
func (cs *ContextServer) ListenAndServe() error
ListenAndServe will start the server and block, the resulting error may be from start up, start up handlers, or shutdown
type ContextServerOption ¶
type ContextServerOption func(*ContextServer)
ContextServerOption is an option that can be applied to a context server
func HandleStart ¶
func HandleStart(startUp func(string) error) ContextServerOption
HandleStart runs the supplied function with the server URL once the server is listening
func ShutdownOnIdle ¶
func ShutdownOnIdle(idle time.Duration, onIdle func()) ContextServerOption
ShutdownOnIdle shuts the server down when all connections have been idle for a specified duration
func ShutdownOnInterrupt ¶
func ShutdownOnInterrupt(onInterrupt func()) ContextServerOption
ShutdownOnInterrupt shuts the server down in response to a SIGINT or SIGTERM
func WithServerOptions ¶
func WithServerOptions(serverOptions func(*http.Server)) ContextServerOption
WithServerOptions exposes the underlying HTTP server for configuration
type IOStreams ¶
type IOStreams struct { // In is used to access the standard input stream (or it's override) In io.Reader // Out is used to access the standard output stream (or it's override) Out io.Writer // ErrOut is used to access the standard error output stream (or it's override) ErrOut io.Writer }
IOStreams allows individual commands access to standard process streams (or their overrides).
func (*IOStreams) OpenFile ¶
func (s *IOStreams) OpenFile(filename string) (io.ReadCloser, error)
OpenFile returns a read closer for the specified filename. If the filename is logically empty (i.e. "-"), the input stream is returned.
func (*IOStreams) YAMLWriter ¶ added in v1.11.0
YAMLWriter returns a resource node writer for the current output stream. The writer is configured to strip common annotations used during pipeline processing.
type NoPrinterError ¶
type NoPrinterError struct { // OutputFormat is the requested output format OutputFormat string // AllowedFormats are the available output formats AllowedFormats []string }
NoPrinterError is an error occurring when no suitable printer is available
func (NoPrinterError) Error ¶
func (e NoPrinterError) Error() string
Error returns a useful message for a "no printer" error
type ResourcePrinter ¶
type ResourcePrinter interface { // PrintObj formats the specified object to the specified writer PrintObj(interface{}, io.Writer) error }
ResourcePrinter formats an object to a byte stream
type ResourcePrinterFunc ¶
ResourcePrinterFunc allows a simple function to be used as resource printer
func (ResourcePrinterFunc) NewPrinter ¶
func (rpf ResourcePrinterFunc) NewPrinter([]string, bool, bool) (ResourcePrinter, error)
type ResourceReader ¶
type ResourceReader struct { Scheme *runtime.Scheme PreferredVersion runtime.GroupVersioner }
ResourceReader helps properly decode Kubernetes resources on the CLI. It is meant to be a lighter weight alternative to the cli-runtime resource.Builder.
func NewResourceReader ¶
func NewResourceReader() *ResourceReader
NewResourceReader returns a new resource reader for the supplied byte stream.
func (*ResourceReader) ReadInto ¶
func (r *ResourceReader) ReadInto(reader io.ReadCloser, target runtime.Object) error
ReadInto decodes the supplied byte stream into the target runtime object. The default values and type information of the target object will be populated.
type TableMeta ¶
type TableMeta interface { // ExtractList accepts a single object (which possibly represents a list) and returns a slice to iterate over; this // should include a single element slice from the input object if it does not represent a list ExtractList(obj interface{}) ([]interface{}, error) // Columns returns the default list of columns to render for a given object (in some cases this may be overridden by the user) Columns(obj interface{}, outputFormat string, showLabels bool) []string // ExtractValue returns the column string value for a given object from the extract list result ExtractValue(obj interface{}, column string) (string, error) // Header returns the header value to use for a column Header(outputFormat string, column string) string }
TableMeta is used to inspect objects for formatting