Documentation ¶
Overview ¶
Package cmdlib contains shared functions for the bundle CLI commands.
Index ¶
- Constants
- Variables
- func ExitWithHelp(cmd *cobra.Command, err string)
- func ReadBundle(ctx context.Context, rw files.FileReaderWriter, g *GlobalOptions) (*bundle.Bundle, error)
- func WriteStructuredContents(ctx context.Context, obj interface{}, rw files.FileReaderWriter, ...) error
- type CobraActionFunc
- type ContextActionFunc
- type GlobalOptions
Constants ¶
const DefaultFilePermissions = os.FileMode(0644)
DefaultFilePermissions is the permission used for the bundle output file (rw-r--r--).
Variables ¶
var GlobalOptionsValues = &GlobalOptions{}
GlobalOptionsValues is a global tracker for global options (for command line executions only).
Functions ¶
func ExitWithHelp ¶
ExitWithHelp exits and prints the help message.
func ReadBundle ¶ added in v0.6.0
func ReadBundle(ctx context.Context, rw files.FileReaderWriter, g *GlobalOptions) (*bundle.Bundle, error)
ReadBundle reads component data file contents from a file or stdin.
func WriteStructuredContents ¶
func WriteStructuredContents(ctx context.Context, obj interface{}, rw files.FileReaderWriter, g *GlobalOptions) error
WriteStructuredContents writes some structured contents from some object `obj`. The contents must be serializable to both JSON and YAML.
Types ¶
type CobraActionFunc ¶
CobraActionFunc provides a common type for all Cobra commands.
func ContextAction ¶
func ContextAction(ctx context.Context, f ContextActionFunc) CobraActionFunc
ContextAction returns a CobraActionFunc for a provided ContextActionFunc.
type ContextActionFunc ¶
ContextActionFunc is a common type for providing a context to a Cobra function.
type GlobalOptions ¶
type GlobalOptions struct { // A path to a bundle file. BundleFile string // Format for the input. By default, assumes YAML. InputFormat string // Path for an output file. OutputFile string // The format for any output. By default, assumes YAML. OutputFormat string // Whether to inline the components in the bundle before doing any processing InlineComponents bool // Whether to inline tho objects before doing any processing (typically // requires InlineComponents to be useful) InlineObjects bool }
GlobalOptions are options that apply to all commands
func (*GlobalOptions) Copy ¶
func (g *GlobalOptions) Copy() *GlobalOptions
Copy creates an options copy.