flags

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package flags contains command-line flags that can be reused over the project, taking real Shipwright Build-Controller resources as a direct representation as command-line flags.

For instance:

cmd := &cobra.Command{}
br := flags.BuildRunSpecFromFlags(cmd.Flags())
flags.SanitizeBuildRunSpec(&br.Spec)

The snippet above shows how to decorate an existing cobra.Command instance with flags, and return an instantiated object, which will be receive the inputted values. And, to make sure inner items are set to nil when all empty, to the resource in question can be used directly against Kubernetes API.

Index

Constants

View Source
const (
	// BuildrefNameFlag command-line flag.
	BuildrefNameFlag = "buildref-name"
	// BuilderImageFlag command-line flag.
	BuilderImageFlag = "builder-image"
	// BuilderCredentialsSecretFlag command-line flag.
	BuilderCredentialsSecretFlag = "builder-credentials-secret"
	// DockerfileFlag command-line flag.
	DockerfileFlag = "dockerfile"
	// EnvFlag command-line flag.
	EnvFlag = "env"
	// SourceURLFlag command-line flag.
	SourceURLFlag = "source-url"
	// SourceRevisionFlag command-line flag.
	SourceRevisionFlag = "source-revision"
	// SourceContextDirFlag command-line flag.
	SourceContextDirFlag = "source-context-dir"
	// SourceCredentialsSecretFlag command-line flag.
	SourceCredentialsSecretFlag = "source-credentials-secret" // #nosec G101
	// SourceBundleImageFlag command-line flag
	SourceBundleImageFlag = "source-bundle-image"
	// SourceBundlePruneFlag command-line flag
	SourceBundlePruneFlag = "source-bundle-prune"
	// StrategyAPIVersionFlag command-line flag.
	StrategyAPIVersionFlag = "strategy-apiversion"
	// StrategyKindFlag command-line flag.
	StrategyKindFlag = "strategy-kind"
	// StrategyNameFlag command-line flag.
	StrategyNameFlag = "strategy-name"
	// OutputImageFlag command-line flag.
	OutputImageFlag = "output-image"
	// OutputInsecure command-line flag.
	OutputInsecureFlag = "output-insecure"
	// OutputCredentialsSecretFlag command-line flag.
	OutputCredentialsSecretFlag = "output-credentials-secret" // #nosec G101
	// ParameterValueFlag command-line flag.
	ParamValueFlag = "param-value"
	// ServiceAccountNameFlag command-line flag.
	ServiceAccountNameFlag = "sa-name"
	// ServiceAccountGenerateFlag command-line flag.
	ServiceAccountGenerateFlag = "sa-generate"
	// TimeoutFlag command-line flag.
	TimeoutFlag = "timeout"
	// OutputImageLabelsFlag command-line flag.
	OutputImageLabelsFlag = "output-image-label"
	// OutputImageAnnotationsFlag command-line flag.
	OutputImageAnnotationsFlag = "output-image-annotation"
	// RetentionFailedLimitFlag command-line flag.
	RetentionFailedLimitFlag = "retention-failed-limit"
	// RetentionSucceededLimitFlag command-line flag.
	RetentionSucceededLimitFlag = "retention-succeeded-limit"
	// RetentionTTLAfterFailedFlag command-line flag.
	RetentionTTLAfterFailedFlag = "retention-ttl-after-failed"
	// RetentionTTLAfterSucceededFlag command-line flag.
	RetentionTTLAfterSucceededFlag = "retention-ttl-after-succeeded"
)

Variables

This section is empty.

Functions

func BuildRunSpecFromFlags

func BuildRunSpecFromFlags(flags *pflag.FlagSet) *buildv1alpha1.BuildRunSpec

BuildRunSpecFromFlags creates a BuildRun spec from command-line flags.

func BuildSpecFromFlags

func BuildSpecFromFlags(flags *pflag.FlagSet) *buildv1alpha1.BuildSpec

BuildSpecFromFlags creates a BuildSpec instance based on command-line flags.

func FollowFlag added in v0.8.0

func FollowFlag(flags *pflag.FlagSet, follow *bool)

FollowFlag register the (log) follow flag, recording the value on the informed boolean pointer.

func SanitizeBuildRunSpec

func SanitizeBuildRunSpec(br *buildv1alpha1.BuildRunSpec)

SanitizeBuildRunSpec checks for empty inner data structures and replaces them with nil.

func SanitizeBuildSpec

func SanitizeBuildSpec(b *buildv1alpha1.BuildSpec)

SanitizeBuildSpec checks for empty inner data structures and replaces them with nil.

Types

type CoreEnvVarArrayValue added in v0.7.0

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

CoreEnvVarArrayValue implements pflag.Value interface, in order to store corev1.EnvVar key-value pairs used on Shipwright's BuildSpec.

func NewCoreEnvVarArrayValue added in v0.7.0

func NewCoreEnvVarArrayValue(envs *[]corev1.EnvVar) *CoreEnvVarArrayValue

NewCoreEnvVarArrayValue instantiate a CoreEnvVarSliceValue sharing the EnvVar pointer.

func (*CoreEnvVarArrayValue) Set added in v0.7.0

func (c *CoreEnvVarArrayValue) Set(value string) error

Set receives a key-value entry separated by equal sign ("=").

func (*CoreEnvVarArrayValue) String added in v0.7.0

func (c *CoreEnvVarArrayValue) String() string

String prints out the string representation of the slice of EnvVar objects.

func (*CoreEnvVarArrayValue) Type added in v0.7.0

func (c *CoreEnvVarArrayValue) Type() string

Type analogous to the pflag "stringArray" type, where each flag entry will be tranlated to a single array (slice) entry, therefore the comma (",") is accepted as part of the value, as any other special character.

type MapValue added in v0.7.0

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

MapValue implements pflag.Value interface, in order to store key-value pairs used on Shipwright's BuildSpec which have map[string]string as field type.

func NewMapValue added in v0.7.0

func NewMapValue(m map[string]string) *MapValue

NewMapValue instantiate a MapValue sharing the map.

func (*MapValue) Set added in v0.7.0

func (m *MapValue) Set(value string) error

Set receives a key-value entry separated by equal sign ("=").

func (*MapValue) String added in v0.7.0

func (m *MapValue) String() string

String prints out the string representation of the map.

func (*MapValue) Type added in v0.7.0

func (m *MapValue) Type() string

Type analogous to the pflag "stringArray" type, where each flag entry will be translated to a single array (slice) entry, therefore the comma (",") is accepted as part of the value, as any other special character.

type ParamArrayValue added in v0.14.0

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

ParamArrayValue implements pflag.Value interface, in order to store ParamValue key-value pairs used on Shipwright's BuildSpec.

func NewParamArrayValue added in v0.14.0

func NewParamArrayValue(params *[]buildv1alpha1.ParamValue) *ParamArrayValue

NewCoreEnvVarArrayValue instantiate a ParamValSliceValue sharing the EnvVar pointer.

func (*ParamArrayValue) Set added in v0.14.0

func (p *ParamArrayValue) Set(value string) error

Set receives a key-value entry separated by equal sign ("=").

func (*ParamArrayValue) String added in v0.14.0

func (p *ParamArrayValue) String() string

String prints out the string representation of the slice of EnvVar objects.

func (*ParamArrayValue) Type added in v0.14.0

func (p *ParamArrayValue) Type() string

Type analogous to the pflag "stringArray" type, where each flag entry will be tranlated to a single array (slice) entry, therefore the comma (",") is accepted as part of the value, as any other special character.

type StrategyKindValue

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

StrategyKindValue implements pflag.Value interface, to represent Shipwright's BuildStrategyKind as a string command-line in an cobra.Command instance.

func NewStrategyKindValue

func NewStrategyKindValue(kindPtr *buildv1alpha1.BuildStrategyKind) *StrategyKindValue

NewStrategyKindValue creates a new instance of StrategyKindValue sharing an existing reference.

func (*StrategyKindValue) Set

func (s *StrategyKindValue) Set(value string) error

Set set the informed string as BuildStrategyKind by casting.

func (*StrategyKindValue) String

func (s *StrategyKindValue) String() string

String shows the value as string.

func (*StrategyKindValue) Type

func (s *StrategyKindValue) Type() string

Type analogous to the pflag "string".

type StringPointerValue

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

StringPointerValue implements pflag.Value interface, to represent a pointer to an string as a command-line flag with Cobra.

func NewStringPointerValue

func NewStringPointerValue(stringPtr *string) *StringPointerValue

NewStringPointerValue instantiate StringPointerValue with the default pointer to string.

func (*StringPointerValue) Set

func (s *StringPointerValue) Set(str string) error

Set set a new value. When empty it keeps the current value set.

func (*StringPointerValue) String

func (s *StringPointerValue) String() string

String returns the value as string, so when the pointer is nil it returns a empty string.

func (*StringPointerValue) Type

func (s *StringPointerValue) Type() string

Type analogous to the pflag "string".

Jump to

Keyboard shortcuts

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