cmd

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2015 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareNamespaceFromFile

func CompareNamespaceFromFile(cmd *cobra.Command, namespace string) error

CompareNamespaceFromFile returns an error if the namespace the user has provided on the CLI or via the default namespace file does not match the namespace of an input file. This prevents a user from unintentionally updating the wrong namespace.

func DataToObjects

func DataToObjects(m meta.RESTMapper, t runtime.ObjectTyper, data []byte) (result []runtime.Object, errors []error)

DataToObjects converts the raw JSON data into API objects

func FirstNonEmptyString

func FirstNonEmptyString(args ...string) string

Returns the first non-empty string out of the ones provided. If all strings are empty, returns an empty string.

func GetExplicitKubeNamespace added in v0.7.0

func GetExplicitKubeNamespace(cmd *cobra.Command) (string, bool)

GetExplicitKubeNamespace returns the value of the namespace a user explicitly provided on the command line, or false if no such namespace was specified.

func GetFilesFromDir

func GetFilesFromDir(directory string, fileType string) []string

Return a list of file names of a certain type within a given directory.

func GetFlagBool

func GetFlagBool(cmd *cobra.Command, flag string) bool

func GetFlagBoolPtr

func GetFlagBoolPtr(cmd *cobra.Command, flag string) *bool

Returns nil if the flag wasn't set.

func GetFlagInt

func GetFlagInt(cmd *cobra.Command, flag string) int

Assumes the flag has a default value.

func GetFlagString

func GetFlagString(cmd *cobra.Command, flag string) string

func GetKubeNamespace added in v0.7.0

func GetKubeNamespace(cmd *cobra.Command) string

GetKubeNamespace returns the value of the namespace a user provided on the command line or use the default namespace.

func NewCmdNamespace

func NewCmdNamespace(out io.Writer) *cobra.Command

func ReadConfigData

func ReadConfigData(location string) ([]byte, error)

ReadConfigData reads the bytes from the specified filesytem or network location or from stdin if location == "-".

func ReadConfigDataFromLocation

func ReadConfigDataFromLocation(location string) ([]byte, error)

func ResourceFromArgs

func ResourceFromArgs(cmd *cobra.Command, args []string, mapper meta.RESTMapper) (mapping *meta.RESTMapping, namespace, name string)

ResourceFromArgs expects two arguments with a given type, and extracts the fields necessary to uniquely locate a resource. Displays a usageError if that contract is not satisfied, or a generic error if any other problems occur.

func ResourceFromArgsOrFile

func ResourceFromArgsOrFile(cmd *cobra.Command, args []string, filename string, typer runtime.ObjectTyper, mapper meta.RESTMapper, schema validation.Schema) (mapping *meta.RESTMapping, namespace, name string)

ResourceFromArgsOrFile expects two arguments or a valid file with a given type, and extracts the fields necessary to uniquely locate a resource. Displays a usageError if that contract is not satisfied, or a generic error if any other problems occur.

func ResourceFromFile

func ResourceFromFile(cmd *cobra.Command, filename string, typer runtime.ObjectTyper, mapper meta.RESTMapper, schema validation.Schema) (mapping *meta.RESTMapping, namespace, name string, data []byte)

ResourceFromFile retrieves the name and namespace from a valid file. If the file does not resolve to a known type an error is returned. The returned mapping can be used to determine the correct REST endpoint to modify this resource with.

func ResourceOrTypeFromArgs

func ResourceOrTypeFromArgs(cmd *cobra.Command, args []string, mapper meta.RESTMapper) (mapping *meta.RESTMapping, namespace, name string)

ResourceFromArgs expects two arguments with a given type, and extracts the fields necessary to uniquely locate a resource. Displays a usageError if that contract is not satisfied, or a generic error if any other problems occur.

func SplitResourceArgument added in v0.8.0

func SplitResourceArgument(arg string) []string

Types

type Factory

type Factory struct {
	ClientBuilder clientcmd.Builder
	Mapper        meta.RESTMapper
	Typer         runtime.ObjectTyper
	Client        func(cmd *cobra.Command, mapping *meta.RESTMapping) (kubectl.RESTClient, error)
	Describer     func(cmd *cobra.Command, mapping *meta.RESTMapping) (kubectl.Describer, error)
	Printer       func(cmd *cobra.Command, mapping *meta.RESTMapping, noHeaders bool) (kubectl.ResourcePrinter, error)
	Validator     func(*cobra.Command) (validation.Schema, error)
}

Factory provides abstractions that allow the Kubectl command to be extended across multiple types of resources and different API sets.

func NewFactory

func NewFactory(clientBuilder clientcmd.Builder) *Factory

NewFactory creates a factory with the default Kubernetes resources defined

func (*Factory) NewCmdCreate

func (f *Factory) NewCmdCreate(out io.Writer) *cobra.Command

func (*Factory) NewCmdCreateAll

func (f *Factory) NewCmdCreateAll(out io.Writer) *cobra.Command

func (*Factory) NewCmdDelete

func (f *Factory) NewCmdDelete(out io.Writer) *cobra.Command

func (*Factory) NewCmdDescribe

func (f *Factory) NewCmdDescribe(out io.Writer) *cobra.Command

func (*Factory) NewCmdGet

func (f *Factory) NewCmdGet(out io.Writer) *cobra.Command

func (*Factory) NewCmdLog added in v0.6.0

func (f *Factory) NewCmdLog(out io.Writer) *cobra.Command

func (*Factory) NewCmdProxy added in v0.6.0

func (f *Factory) NewCmdProxy(out io.Writer) *cobra.Command

func (*Factory) NewCmdUpdate

func (f *Factory) NewCmdUpdate(out io.Writer) *cobra.Command

func (*Factory) NewCmdVersion added in v0.6.0

func (f *Factory) NewCmdVersion(out io.Writer) *cobra.Command

func (*Factory) Run

func (f *Factory) Run(out io.Writer)

type ResourceInfo added in v0.8.0

type ResourceInfo struct {
	Client    kubectl.RESTClient
	Mapping   *meta.RESTMapping
	Namespace string
	Name      string

	// Optional, this is the most recent value returned by the server if available
	runtime.Object
}

ResourceInfo contains temporary info to execute REST call

func NewResourceInfo added in v0.8.0

func NewResourceInfo(client kubectl.RESTClient, mapping *meta.RESTMapping, namespace, name string) *ResourceInfo

func (*ResourceInfo) Visit added in v0.8.0

func (r *ResourceInfo) Visit(fn func(r *ResourceInfo) error) error

Visit implements ResourceVisitor

type ResourceSelector added in v0.8.0

type ResourceSelector struct {
	Client    kubectl.RESTClient
	Mapping   *meta.RESTMapping
	Namespace string
	Selector  labels.Selector
}

ResourceSelector is a facade for all the resources fetched via label selector

func NewResourceSelector added in v0.8.0

func NewResourceSelector(client kubectl.RESTClient, mapping *meta.RESTMapping, namespace string, selector labels.Selector) *ResourceSelector

NewResourceSelector creates a resource selector which hides details of getting items by their label selector.

func (*ResourceSelector) Visit added in v0.8.0

func (r *ResourceSelector) Visit(fn func(r *ResourceInfo) error) error

Visit implements ResourceVisitor

type ResourceVisitor added in v0.8.0

type ResourceVisitor interface {
	Visit(func(*ResourceInfo) error) error
}

ResourceVisitor lets clients walk the list of resources

func ResourcesFromArgsOrFile added in v0.8.0

func ResourcesFromArgsOrFile(
	cmd *cobra.Command,
	args []string,
	filename, selector string,
	typer runtime.ObjectTyper,
	mapper meta.RESTMapper,
	clientBuilder func(cmd *cobra.Command, mapping *meta.RESTMapping) (kubectl.RESTClient, error),
	schema validation.Schema,
) ResourceVisitor

ResourcesFromArgsOrFile computes a list of Resources by extracting info from filename or args. It will handle label selectors provided.

type ResourceVisitorList added in v0.8.0

type ResourceVisitorList []ResourceVisitor

func (ResourceVisitorList) Visit added in v0.8.0

func (l ResourceVisitorList) Visit(fn func(r *ResourceInfo) error) error

Visit implements ResourceVisitor

Jump to

Keyboard shortcuts

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