cmdlib

package
v0.4.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package cmdlib contains shared functions for the bundle CLI commands.

Index

Constants

View Source
const DefaultFilePermissions = os.FileMode(0644)

DefaultFilePermissions is the permission used for the bundle output file (rw-r--r--).

Variables

View Source
var GlobalOptionsValues = &GlobalOptions{}

GlobalOptionsValues is a global tracker for global options (for command line executions only).

Functions

func ExitWithHelp

func ExitWithHelp(cmd *cobra.Command, err string)

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

type CobraActionFunc func(cmd *cobra.Command, args []string)

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

type ContextActionFunc func(ctx context.Context, cmd *cobra.Command, args []string)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL