genericclioptions

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 16 Imported by: 139

Documentation

Index

Constants

View Source
const (
	// ProjectFlagName is the name of the flag allowing a user to specify which project to operate on
	ProjectFlagName = "project"
	// ApplicationFlagName is the name of the flag allowing a user to specify which application to operate on
	ApplicationFlagName = "app"
	// ComponentFlagName is the name of the flag allowing a user to specify which component to operate on
	ComponentFlagName = "component"
	// OutputFlagName is the name of the flag allowing user to specify output format
	OutputFlagName = "output"
	// ContextFlagName is the name of the flag allowing a user to specify the location of the component settings
	ContextFlagName = "context"
)
View Source
const DefaultAppName = "app"

DefaultAppName is the default name of the application when an application name is not provided

Variables

This section is empty.

Functions

func AddContextFlag added in v1.0.0

func AddContextFlag(cmd *cobra.Command, setValueTo *string)

AddContextFlag adds `context` flag to given cobra command

func AddNowFlag added in v1.0.0

func AddNowFlag(cmd *cobra.Command, setValueTo *bool)

AddNowFlag adds `now` flag to given cobra command

func ApplyIgnore added in v1.0.0

func ApplyIgnore(ignores *[]string, sourcePath string) (err error)

ApplyIgnore will take the current ignores []string and either ignore it (if .odoignore is used) or find the .gitignore file in the directory and use that instead.

func CheckMachineReadableOutputCommand added in v1.0.0

func CheckMachineReadableOutputCommand(cmd *cobra.Command)

CheckMachineReadableOutputCommand performs machine-readable output functions required to have it work correctly

func Client

func Client(command *cobra.Command) *occlient.Client

Client returns an oc client configured for this command's options

func ClientWithConnectionCheck

func ClientWithConnectionCheck(command *cobra.Command, skipConnectionCheck bool) *occlient.Client

ClientWithConnectionCheck returns an oc client configured for this command's options but forcing the connection check status to the value of the provided bool, skipping it if true, checking the connection otherwise

func FlagValueIfSet

func FlagValueIfSet(cmd *cobra.Command, flagName string) string

FlagValueIfSet retrieves the value of the specified flag if it is set for the given command

func GenericRun added in v0.0.19

func GenericRun(o Runnable, cmd *cobra.Command, args []string)

func GetContextFlagValue added in v1.2.6

func GetContextFlagValue(command *cobra.Command) string

func ResolveAppFlag added in v1.2.4

func ResolveAppFlag(command *cobra.Command) string

ResolveAppFlag resolves the app from the flag

Types

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context holds contextual information useful to commands such as correctly configured client, target project and application (based on specified flag values) and provides for a way to retrieve a given component given this context

func NewConfigContext added in v1.1.1

func NewConfigContext(command *cobra.Command) *Context

NewConfigContext is a special kind of context which only contains local configuration, other information is not retrived

from the cluster. This is useful for commands which don't want to connect to cluster.

func NewContext

func NewContext(command *cobra.Command, ignoreMissingConfiguration ...bool) *Context

NewContext creates a new Context struct populated with the current state based on flags specified for the provided command

func NewContextCompletion added in v1.0.2

func NewContextCompletion(command *cobra.Command) *Context

NewContextCompletion disables checking for a local configuration since when we use autocompletion on the command line, we couldn't care less if there was a configuriation. We only need to check the parameters.

func NewContextCreatingAppIfNeeded

func NewContextCreatingAppIfNeeded(command *cobra.Command) *Context

NewContextCreatingAppIfNeeded creates a new Context struct populated with the current state based on flags specified for the provided command, creating the application if none already exists

func NewDevfileContext added in v1.1.2

func NewDevfileContext(command *cobra.Command, ignoreMissingConfiguration ...bool) *Context

NewDevfileContext creates a new Context struct populated with the current state based on flags specified for the provided command

func NewFakeContext

func NewFakeContext(project, application, component string, client *occlient.Client, kclient *kclient.Client) *Context

func UpdatedContext added in v1.0.0

func UpdatedContext(context *Context) (*Context, *config.LocalConfigInfo, error)

UpdatedContext returns a new context updated from config file

func (*Context) Component

func (o *Context) Component(optionalComponent ...string) string

Component retrieves the optionally specified component or the current one if it is set. If no component is set, exit with an error

func (*Context) ComponentAllowingEmpty

func (o *Context) ComponentAllowingEmpty(allowEmpty bool, optionalComponent ...string) string

ComponentAllowingEmpty retrieves the optionally specified component or the current one if it is set, allowing empty components (instead of exiting with an error) if so specified

type Runnable added in v0.0.19

type Runnable interface {
	Complete(name string, cmd *cobra.Command, args []string) error
	Validate() error
	Run() error
}

Jump to

Keyboard shortcuts

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