cmdutil

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PlanRetriesFlagMessage is the message to be used by the --retries flag.
	PlanRetriesFlagMessage = "Number of times monitoring will be retried. Meaning it accepts an N number of API errors"
	// TrackFlagMessage is the message to be used by the --track flag.
	TrackFlagMessage = "Tracks the progress of the performed task"
)
View Source
const DefaultECERegion = "ece-region"

DefaultECERegion is the region for ECE

View Source
const DeprecatedText = "DEPRECATED (Will be removed in the next major version):"

DeprecatedText is an additional helper text for commands

View Source
const PlatformAdminRequired = "(Available for ECE only)"

PlatformAdminRequired is an additional helper text for commands

Variables

View Source
var (
	// StatelessKinds declares the stateless deployment resource kinds
	StatelessKinds = []string{"apm", "appsearch", "kibana"}

	// StatefulKinds declares the stateful deployment resource kinds (Elasticsearch).
	StatefulKinds = []string{"elasticsearch"}

	// AllKinds is StatelessKinds appending StatefulKinds
	AllKinds = append(StatelessKinds, StatefulKinds...)

	// StatelessKindsCompFunc is the bash autocompletion function for stateless kinds.
	StatelessKindsCompFunc = fmt.Sprintf(compFuncTpl, "stateless", strings.Join(StatelessKinds, " "))

	// AllKindsCompFunc is the bash autocompletion function for all kinds.
	AllKindsCompFunc = fmt.Sprintf(compFuncTpl, "all", strings.Join(AllKinds, " "))
)
View Source
var DefaultTestFrequency = plan.TrackFrequencyConfig{
	PollFrequency: time.Millisecond,
	MaxRetries:    1,
}

DefaultTestFrequency provides sane defaults for testing Plan change tracking.

View Source
var DefaultTrackFrequencyConfig = plan.TrackFrequencyConfig{
	PollFrequency: time.Second * 5,
	MaxRetries:    3,
}

DefaultTrackFrequencyConfig provides sane defaults for Plan change tracking.

Functions

func ActionConfirm

func ActionConfirm(actionRaw, msg string) (*bool, error)

ActionConfirm asks you to confirm before performing an action

func AddKindFlag

func AddKindFlag(cmd *cobra.Command, prefix string, all bool) *string

AddKindFlag adds a kind string flag to the specified command, with the resource kinds autocompletion function. It is intended to be used for any commands which call the deployment/resource APIs.

func AddTrackFlags

func AddTrackFlags(cmd *cobra.Command)

AddTrackFlags adds flags which control the tracking frequency to the passed command reference.

func AdminReqDescription

func AdminReqDescription(desc string) string

AdminReqDescription adds a text about required admin permissions to a string

func ConflictingFlags

func ConflictingFlags(cmd *cobra.Command, first, second string) error

ConflictingFlags checks if both flags have been specified, and if so returns an error.

func DeprecatedDescription

func DeprecatedDescription(desc string) string

DeprecatedDescription adds a text about deprecation to a string

func GetInsecurePassword

func GetInsecurePassword(insecure string) ([]byte, error)

GetInsecurePassword retrieves an insecure password from a CLI command

func GetTrackSettings

func GetTrackSettings(cmd *cobra.Command) (int, time.Duration)

GetTrackSettings obtains the currently set tracking settings, the first return value being the MaxPollRetries and the second one the poll frequency.

func InsecureOrSecurePassword

func InsecureOrSecurePassword(insecure, message string, verify bool) ([]byte, error)

InsecureOrSecurePassword checks if an insecure password has been set and gets a password in a secure or insecure way.

func MustUseAFlag

func MustUseAFlag(cmd *cobra.Command, first, second string) error

MustUseAFlag checks if one or another flags are used, and if not returns an error.

func PasswordVerify

func PasswordVerify(password []byte) error

PasswordVerify retrieves a password from terminal input and verifies a match

func Track

func Track(params TrackParams) error

Track will either print and track the parameter specified Response. If the formatter is not specified an error will be returned.

Types

type TrackParams

type TrackParams struct {
	planutil.TrackChangeParams

	// Formatter used to print the structure.
	Formatter formatter.Formatter

	// When set to true, it tracks the progress of the resource change with the
	// specified TrackResourcesParams.
	Track bool

	// Template is the template name which the formatter will use.
	Template string

	// Response will be printed using the formatter and template name.
	Response interface{}
}

TrackParams is consumed by Track.

func NewTrackParams

func NewTrackParams(params TrackParamsConfig) TrackParams

NewTrackParams creates a TrackParams structure from the config.

func (TrackParams) Validate

func (params TrackParams) Validate() error

Validate ensures the parameters are usable by the consuming function.

type TrackParamsConfig

type TrackParamsConfig struct {
	App             *ecctl.App
	DeploymentID    string
	ResourceID      string
	Kind            string
	Template        string
	Response        interface{}
	Track           bool
	FrequencyConfig *plan.TrackFrequencyConfig
}

TrackParamsConfig is used to create TrackParams which print the output / track.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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