Documentation ¶
Overview ¶
Package genericcli includes utilities to build generic CLI commands for operating with Kubernetes style resources.
Index ¶
- func GetResourceInterface(ctx context.Context, t Type, client dynamic.Interface, ns string) dynamic.ResourceInterface
- func NewDeleteByNameCommand(t Type, p *config.KfParams, opts ...DeleteByNameOption) *cobra.Command
- func NewDescribeCommand(t Type, p *config.KfParams, opts ...DescribeOption) *cobra.Command
- func NewListCommand(t Type, p *config.KfParams, opts ...ListOption) *cobra.Command
- func NewStubCommand(name string, short string, alt string, example string, opts ...StubOption) *cobra.Command
- func ValidArgsFunction(t Type, p *config.KfParams) ...
- type DeleteByNameOption
- func WithDeleteByNameAdditionalLongText(val string) DeleteByNameOption
- func WithDeleteByNameAliases(val []string) DeleteByNameOption
- func WithDeleteByNameCommandName(val string) DeleteByNameOption
- func WithDeleteByNameExample(val string) DeleteByNameOption
- func WithDeleteByNameLong(val string) DeleteByNameOption
- func WithDeleteByNamePropagationPolicy(val metav1.DeletionPropagation) DeleteByNameOption
- func WithDeleteByNameShort(val string) DeleteByNameOption
- type DeleteByNameOptions
- func (opts DeleteByNameOptions) AdditionalLongText() string
- func (opts DeleteByNameOptions) Aliases() []string
- func (opts DeleteByNameOptions) CommandName() string
- func (opts DeleteByNameOptions) Example() string
- func (opts DeleteByNameOptions) Extend(other DeleteByNameOptions) DeleteByNameOptions
- func (opts DeleteByNameOptions) Long() string
- func (opts DeleteByNameOptions) PropagationPolicy() metav1.DeletionPropagation
- func (opts DeleteByNameOptions) Short() string
- type DescribeOption
- type DescribeOptions
- type KubernetesType
- type ListArgumentFilter
- type ListArgumentFilterHandler
- type ListOption
- func WithListAliases(val []string) ListOption
- func WithListArgumentFilters(val []ListArgumentFilter) ListOption
- func WithListCommandName(val string) ListOption
- func WithListExample(val string) ListOption
- func WithListLabelFilters(val map[string]string) ListOption
- func WithListLabelRequirements(val []labels.Requirement) ListOption
- func WithListLong(val string) ListOption
- func WithListPluralFriendlyName(val string) ListOption
- func WithListShort(val string) ListOption
- type ListOptions
- func (opts ListOptions) Aliases() []string
- func (opts ListOptions) ArgumentFilters() []ListArgumentFilter
- func (opts ListOptions) CommandName() string
- func (opts ListOptions) Example() string
- func (opts ListOptions) Extend(other ListOptions) ListOptions
- func (opts ListOptions) LabelFilters() map[string]string
- func (opts ListOptions) LabelRequirements() []labels.Requirement
- func (opts ListOptions) Long() string
- func (opts ListOptions) PluralFriendlyName() string
- func (opts ListOptions) Short() string
- type StubOption
- type StubOptions
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetResourceInterface ¶
func GetResourceInterface(ctx context.Context, t Type, client dynamic.Interface, ns string) dynamic.ResourceInterface
GetResourceInterface is a helper method to return the Resource interface of a given client.
func NewDeleteByNameCommand ¶
NewDeleteByNameCommand creates a delete command for Kubernetes objects that works by the name of the object.
func NewDescribeCommand ¶
NewDescribeCommand creates a describe command.
func NewListCommand ¶
NewListCommand creates a list command that can print tables.
func NewStubCommand ¶
func NewStubCommand(name string, short string, alt string, example string, opts ...StubOption) *cobra.Command
NewStubCommand creates a stub command.
Types ¶
type DeleteByNameOption ¶
type DeleteByNameOption func(*deleteByNameConfig)
DeleteByNameOption is a single option for configuring a deleteByNameConfig
func WithDeleteByNameAdditionalLongText ¶
func WithDeleteByNameAdditionalLongText(val string) DeleteByNameOption
WithDeleteByNameAdditionalLongText creates an Option that sets additional text to append to long.
func WithDeleteByNameAliases ¶
func WithDeleteByNameAliases(val []string) DeleteByNameOption
WithDeleteByNameAliases creates an Option that sets an array of aliases that can be used instead of the command name.
func WithDeleteByNameCommandName ¶
func WithDeleteByNameCommandName(val string) DeleteByNameOption
WithDeleteByNameCommandName creates an Option that sets the name to use for the command.
func WithDeleteByNameExample ¶
func WithDeleteByNameExample(val string) DeleteByNameOption
WithDeleteByNameExample creates an Option that sets the example to use for the command.
func WithDeleteByNameLong ¶
func WithDeleteByNameLong(val string) DeleteByNameOption
WithDeleteByNameLong creates an Option that sets the long description to use for the command.
func WithDeleteByNamePropagationPolicy ¶
func WithDeleteByNamePropagationPolicy(val metav1.DeletionPropagation) DeleteByNameOption
WithDeleteByNamePropagationPolicy creates an Option that sets propagation policy for deleting an object.
func WithDeleteByNameShort ¶
func WithDeleteByNameShort(val string) DeleteByNameOption
WithDeleteByNameShort creates an Option that sets the short description to use for the command.
type DeleteByNameOptions ¶
type DeleteByNameOptions []DeleteByNameOption
DeleteByNameOptions is a configuration set defining a deleteByNameConfig
func DeleteByNameOptionDefaults ¶
func DeleteByNameOptionDefaults() DeleteByNameOptions
DeleteByNameOptionDefaults gets the default values for DeleteByName.
func (DeleteByNameOptions) AdditionalLongText ¶
func (opts DeleteByNameOptions) AdditionalLongText() string
AdditionalLongText returns the last set value for AdditionalLongText or the empty value if not set.
func (DeleteByNameOptions) Aliases ¶
func (opts DeleteByNameOptions) Aliases() []string
Aliases returns the last set value for Aliases or the empty value if not set.
func (DeleteByNameOptions) CommandName ¶
func (opts DeleteByNameOptions) CommandName() string
CommandName returns the last set value for CommandName or the empty value if not set.
func (DeleteByNameOptions) Example ¶
func (opts DeleteByNameOptions) Example() string
Example returns the last set value for Example or the empty value if not set.
func (DeleteByNameOptions) Extend ¶
func (opts DeleteByNameOptions) Extend(other DeleteByNameOptions) DeleteByNameOptions
Extend creates a new DeleteByNameOptions with the contents of other overriding the values set in this DeleteByNameOptions.
func (DeleteByNameOptions) Long ¶
func (opts DeleteByNameOptions) Long() string
Long returns the last set value for Long or the empty value if not set.
func (DeleteByNameOptions) PropagationPolicy ¶
func (opts DeleteByNameOptions) PropagationPolicy() metav1.DeletionPropagation
PropagationPolicy returns the last set value for PropagationPolicy or the empty value if not set.
func (DeleteByNameOptions) Short ¶
func (opts DeleteByNameOptions) Short() string
Short returns the last set value for Short or the empty value if not set.
type DescribeOption ¶
type DescribeOption func(*describeConfig)
DescribeOption is a single option for configuring a describeConfig
func WithDescribeAliases ¶
func WithDescribeAliases(val []string) DescribeOption
WithDescribeAliases creates an Option that sets an array of aliases that can be used instead of the command name.
func WithDescribeCommandName ¶
func WithDescribeCommandName(val string) DescribeOption
WithDescribeCommandName creates an Option that sets the name to use for the command.
func WithDescribeExample ¶
func WithDescribeExample(val string) DescribeOption
WithDescribeExample creates an Option that sets the example to use for the command.
func WithDescribeLong ¶
func WithDescribeLong(val string) DescribeOption
WithDescribeLong creates an Option that sets the long description to use for the command.
func WithDescribeShort ¶
func WithDescribeShort(val string) DescribeOption
WithDescribeShort creates an Option that sets the short description to use for the command.
type DescribeOptions ¶
type DescribeOptions []DescribeOption
DescribeOptions is a configuration set defining a describeConfig
func DescribeOptionDefaults ¶
func DescribeOptionDefaults() DescribeOptions
DescribeOptionDefaults gets the default values for Describe.
func (DescribeOptions) Aliases ¶
func (opts DescribeOptions) Aliases() []string
Aliases returns the last set value for Aliases or the empty value if not set.
func (DescribeOptions) CommandName ¶
func (opts DescribeOptions) CommandName() string
CommandName returns the last set value for CommandName or the empty value if not set.
func (DescribeOptions) Example ¶
func (opts DescribeOptions) Example() string
Example returns the last set value for Example or the empty value if not set.
func (DescribeOptions) Extend ¶
func (opts DescribeOptions) Extend(other DescribeOptions) DescribeOptions
Extend creates a new DescribeOptions with the contents of other overriding the values set in this DescribeOptions.
func (DescribeOptions) Long ¶
func (opts DescribeOptions) Long() string
Long returns the last set value for Long or the empty value if not set.
func (DescribeOptions) Short ¶
func (opts DescribeOptions) Short() string
Short returns the last set value for Short or the empty value if not set.
type KubernetesType ¶
type KubernetesType struct { NsScoped bool Group string Version string Kind string Resource string KfName string }
KubernetesType is an implementation of Type that relies on hard-coded values.
func (*KubernetesType) FriendlyName ¶
func (g *KubernetesType) FriendlyName() string
FriendlyName implements Type.FriendlyName
func (*KubernetesType) GroupVersionKind ¶
func (g *KubernetesType) GroupVersionKind(context.Context) schema.GroupVersionKind
GroupVersionKind implements Type.GroupVersionKind
func (*KubernetesType) GroupVersionResource ¶
func (g *KubernetesType) GroupVersionResource(context.Context) schema.GroupVersionResource
GroupVersionResource implements Type.GroupVersionResource
func (*KubernetesType) Namespaced ¶
func (g *KubernetesType) Namespaced() bool
Namespaced implements Type.Namespaced
type ListArgumentFilter ¶
type ListArgumentFilter struct { // Name contains the name of the argument. Name string // Handler is a callback for the argument. Handler ListArgumentFilterHandler // Required indicates if the argument is required. Required bool }
ListArgumentFilter allows attaching optional filters to arguments.
type ListArgumentFilterHandler ¶
type ListArgumentFilterHandler func(argValue string, opts *metav1.ListOptions) error
ListArgumentFilterHandler is a callback for a CLI argument that modifies a Kubernetes ListOptions selector.
func NewAddLabelFilter ¶
func NewAddLabelFilter(labelKey string) ListArgumentFilterHandler
NewAddLabelFilter creates a ListArgumentFilterHandler that adds an additional label to the existing selector.
type ListOption ¶
type ListOption func(*listConfig)
ListOption is a single option for configuring a listConfig
func WithListAliases ¶
func WithListAliases(val []string) ListOption
WithListAliases creates an Option that sets an array of aliases that can be used instead of the command name.
func WithListArgumentFilters ¶
func WithListArgumentFilters(val []ListArgumentFilter) ListOption
WithListArgumentFilters creates an Option that sets callbacks that can modify the lister.
func WithListCommandName ¶
func WithListCommandName(val string) ListOption
WithListCommandName creates an Option that sets the name to use for the command.
func WithListExample ¶
func WithListExample(val string) ListOption
WithListExample creates an Option that sets the example to use for the command.
func WithListLabelFilters ¶
func WithListLabelFilters(val map[string]string) ListOption
WithListLabelFilters creates an Option that sets flag name to label pairs to use as list filters.
func WithListLabelRequirements ¶
func WithListLabelRequirements(val []labels.Requirement) ListOption
WithListLabelRequirements creates an Option that sets label requirements to filter resources.
func WithListLong ¶
func WithListLong(val string) ListOption
WithListLong creates an Option that sets the long description to use for the command.
func WithListPluralFriendlyName ¶
func WithListPluralFriendlyName(val string) ListOption
WithListPluralFriendlyName creates an Option that sets the plural object name to display for this resource.
func WithListShort ¶
func WithListShort(val string) ListOption
WithListShort creates an Option that sets the short description to use for the command.
type ListOptions ¶
type ListOptions []ListOption
ListOptions is a configuration set defining a listConfig
func ListOptionDefaults ¶
func ListOptionDefaults() ListOptions
ListOptionDefaults gets the default values for List.
func (ListOptions) Aliases ¶
func (opts ListOptions) Aliases() []string
Aliases returns the last set value for Aliases or the empty value if not set.
func (ListOptions) ArgumentFilters ¶
func (opts ListOptions) ArgumentFilters() []ListArgumentFilter
ArgumentFilters returns the last set value for ArgumentFilters or the empty value if not set.
func (ListOptions) CommandName ¶
func (opts ListOptions) CommandName() string
CommandName returns the last set value for CommandName or the empty value if not set.
func (ListOptions) Example ¶
func (opts ListOptions) Example() string
Example returns the last set value for Example or the empty value if not set.
func (ListOptions) Extend ¶
func (opts ListOptions) Extend(other ListOptions) ListOptions
Extend creates a new ListOptions with the contents of other overriding the values set in this ListOptions.
func (ListOptions) LabelFilters ¶
func (opts ListOptions) LabelFilters() map[string]string
LabelFilters returns the last set value for LabelFilters or the empty value if not set.
func (ListOptions) LabelRequirements ¶
func (opts ListOptions) LabelRequirements() []labels.Requirement
LabelRequirements returns the last set value for LabelRequirements or the empty value if not set.
func (ListOptions) Long ¶
func (opts ListOptions) Long() string
Long returns the last set value for Long or the empty value if not set.
func (ListOptions) PluralFriendlyName ¶
func (opts ListOptions) PluralFriendlyName() string
PluralFriendlyName returns the last set value for PluralFriendlyName or the empty value if not set.
func (ListOptions) Short ¶
func (opts ListOptions) Short() string
Short returns the last set value for Short or the empty value if not set.
type StubOption ¶
type StubOption func(*stubConfig)
StubOption is a single option for configuring a stubConfig
func WithStubAliases ¶
func WithStubAliases(val []string) StubOption
WithStubAliases creates an Option that sets an array of aliases that can be used instead of the command name.
func WithStubCommandName ¶
func WithStubCommandName(val string) StubOption
WithStubCommandName creates an Option that sets the name to use for the command.
func WithStubExample ¶
func WithStubExample(val string) StubOption
WithStubExample creates an Option that sets the example to use for the command.
func WithStubLong ¶
func WithStubLong(val string) StubOption
WithStubLong creates an Option that sets the long description to use for the command.
func WithStubShort ¶
func WithStubShort(val string) StubOption
WithStubShort creates an Option that sets the short description to use for the command.
type StubOptions ¶
type StubOptions []StubOption
StubOptions is a configuration set defining a stubConfig
func StubOptionDefaults ¶
func StubOptionDefaults() StubOptions
StubOptionDefaults gets the default values for Stub.
func (StubOptions) Aliases ¶
func (opts StubOptions) Aliases() []string
Aliases returns the last set value for Aliases or the empty value if not set.
func (StubOptions) CommandName ¶
func (opts StubOptions) CommandName() string
CommandName returns the last set value for CommandName or the empty value if not set.
func (StubOptions) Example ¶
func (opts StubOptions) Example() string
Example returns the last set value for Example or the empty value if not set.
func (StubOptions) Extend ¶
func (opts StubOptions) Extend(other StubOptions) StubOptions
Extend creates a new StubOptions with the contents of other overriding the values set in this StubOptions.
func (StubOptions) Long ¶
func (opts StubOptions) Long() string
Long returns the last set value for Long or the empty value if not set.
func (StubOptions) Short ¶
func (opts StubOptions) Short() string
Short returns the last set value for Short or the empty value if not set.