Documentation ¶
Overview ¶
Package cmdlib contains shared functions for the bundle CLI commands.
Index ¶
- Constants
- Variables
- func ExitWithHelp(cmd *cobra.Command, err string)
- func ReadBundleContents(ctx context.Context, rw files.FileReaderWriter, g *GlobalOptions) (*bpb.ClusterBundle, 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 ReadBundleContents ¶
func ReadBundleContents(ctx context.Context, rw files.FileReaderWriter, g *GlobalOptions) (*bpb.ClusterBundle, error)
ReadBundleContents reads bundle 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 bundle before doing any processing Inline bool // Whether to inline just the top layer of the bundle. Only used when Inline // is set to true. TopLayerInlineOnly bool }
GlobalOptions are options that apply to all commands
func (*GlobalOptions) Copy ¶
func (g *GlobalOptions) Copy() *GlobalOptions