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
- func BuildRunSpecFromFlags(flags *pflag.FlagSet) *buildv1alpha1.BuildRunSpec
- func BuildSpecFromFlags(flags *pflag.FlagSet) *buildv1alpha1.BuildSpec
- func SanitizeBuildRunSpec(br *buildv1alpha1.BuildRunSpec)
- func SanitizeBuildSpec(b *buildv1alpha1.BuildSpec)
- type StrategyKindValue
- type StringPointerValue
Constants ¶
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" // 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" // OutputCredentialsSecretFlag command-line flag. OutputCredentialsSecretFlag = "output-credentials-secret" // ServiceAccountNameFlag command-line flag. ServiceAccountNameFlag = "sa-name" // ServiceAccountGenerateFlag command-line flag. ServiceAccountGenerateFlag = "sa-generate" // TimeoutFlag command-line flag. TimeoutFlag = "timeout" )
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 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 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".