commands

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutputYaml = "yaml"
	OutputJson = "json"
	OutputWide = "wide"
)
View Source
const (
	MethodGet              = "GET"
	MethodDelete           = "DELETE"
	MethodPost             = "POST"
	IgnoreProductOfCluster = "Cluster"
	IgnoreProductOfProduct = "Product"
	CodeRepoBinding        = "CodeRepoBinding"
)

Variables

This section is empty.

Functions

func AskToProceedS

func AskToProceedS(message string) string

AskToProceedS prompts the user with a message (typically a yes, no or all question) and returns string "a", "y" or "n".

func CheckError

func CheckError(err error)

CheckError logs a fatal message and exits with error code if err is not nil

func DeleteResource

func DeleteResource(apiServer string, token string, skipCheck bool, resource string, resourceHandler types.ResourceHandler) error

func Execute

func Execute(apiServer string, token string, filePath string, skipCheck bool,
	resourceTypeArr []types.ResourcesType, resourceFunc types.ResourceFunc) error

func Fatal

func Fatal(exitcode int, args ...interface{})

Fatal is a wrapper for logrus.Fatal() to exit with custom code

func NewResourceCommand

func NewResourceCommand(clientOptions *types.ClientOptions, resourceType reflect.Type, responseItemType reflect.Type,
	subCommandFunc func(clientOptions *types.ClientOptions, resourceHandler types.ResourceHandler, resourceName string,
		resourceType, responseItemType reflect.Type) *cobra.Command) (ccCommands []*cobra.Command)

NewResourceCommand creates and returns a set of Cobra commands for a resource type based on reflection and provided options. It takes client options, resource type, response item type, and a subCommandFunc responsible for creating subcommands. The generated commands include those for the resource itself, its plural form, and any short commands specified in tags. The subCommandFunc is called to create subcommands for each of these names.

func PrintResource

func PrintResource(resource interface{}, output string) error

PrintResource prints a single resource in YAML or JSON format to stdout according to the output format

func PrintResourceResponseList

func PrintResourceResponseList(resources interface{}, output string, single bool) error

PrintResourceResponseList marshals & prints a list of resources to stdout according to the output format

func SaveResource

func SaveResource(apiServer string, token string, skipCheck bool, resource string, resourceHandler types.ResourceHandler) error

func SubDeleteCommand

func SubDeleteCommand(clientOptions *types.ClientOptions, resourceHandler types.ResourceHandler, resourceName string, _, _ reflect.Type) *cobra.Command

SubDeleteCommand creates a Cobra command for the "delete" subcommand of a resource. It removes one or more resources based on the provided arguments and options. The command supports confirmation prompts and the option to bypass prompts using the "--yes" flag. The "product" flag allows filtering resources by product name.

func SubGetCommand

func SubGetCommand(clientOptions *types.ClientOptions, resourceHandler types.ResourceHandler, resourceName string, _, responseItemType reflect.Type) *cobra.Command

SubGetCommand creates a Cobra command for the "get" subcommand of a resource. It retrieves information about a specific resource or a list of resources based on the provided arguments. The command supports various output formats such as json, yaml, or a wide table format. The "product" flag allows filtering resources by product name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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