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 WriteContents(ctx context.Context, outPath string, bytes []byte, rw files.FileReaderWriter) 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 ¶
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 WriteContents ¶
func WriteContents(ctx context.Context, outPath string, bytes []byte, rw files.FileReaderWriter) error
WriteContents writes some bytes to disk or stdout. if outPath is empty, write to stdout instdea.
func WriteStructuredContents ¶
func WriteStructuredContents(ctx context.Context, obj interface{}, rw files.FileReaderWriter, g *GlobalOptions) error
WriteContentsStructured writes some structured contents. 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