cmdutils

package
v0.136.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 29 Imported by: 40

Documentation

Index

Constants

View Source
const IncompatibleFlags = "cannot be used at the same time"

IncompatibleFlags is a common substring of an error message

Variables

This section is empty.

Functions

func AddApproveFlag

func AddApproveFlag(fs *pflag.FlagSet, cmd *Cmd)

AddApproveFlag adds common `--approve` flag

func AddClusterFlag

func AddClusterFlag(fs *pflag.FlagSet, meta *api.ClusterMeta)

AddClusterFlag adds a common --cluster flag for cluster name. Use this for commands whose principal resource is *not* a cluster.

func AddClusterFlagWithDeprecated

func AddClusterFlagWithDeprecated(fs *pflag.FlagSet, meta *api.ClusterMeta)

AddClusterFlagWithDeprecated adds a common --cluster flag for cluster name as well as a deprecated --name flag. Use AddClusterFlag() for new commands.

func AddCommonCreateNodeGroupAddonsFlags added in v0.42.0

func AddCommonCreateNodeGroupAddonsFlags(fs *pflag.FlagSet, ng *api.NodeGroup, options *CreateNGOptions)

AddCommonCreateNodeGroupIAMAddonsFlags adds flags to set ng.IAM.WithAddonPolicies

func AddCommonCreateNodeGroupFlags

func AddCommonCreateNodeGroupFlags(fs *pflag.FlagSet, cmd *Cmd, ng *api.NodeGroup, mngOptions *CreateManagedNGOptions)

AddCommonCreateNodeGroupFlags adds common flags for creating a nodegroup

func AddCommonFlagsForAWS

func AddCommonFlagsForAWS(cmd *Cmd, p *api.ProviderConfig, addCfnOptions bool)

AddCommonFlagsForAWS adds common flags for api.ProviderConfig

func AddCommonFlagsForGetCmd

func AddCommonFlagsForGetCmd(fs *pflag.FlagSet, chunkSize *int, outputMode *printers.Type)

AddCommonFlagsForGetCmd adds common flafs for get commands

func AddCommonFlagsForKubeconfig

func AddCommonFlagsForKubeconfig(fs *pflag.FlagSet, outputPath, authenticatorRoleARN *string, setContext, autoPath *bool, exampleName string)

AddCommonFlagsForKubeconfig adds common flags for controlling how output kubeconfig is written

func AddConfigFileFlag

func AddConfigFileFlag(fs *pflag.FlagSet, path *string)

AddConfigFileFlag adds common --config-file flag

func AddFlagsForFargate

func AddFlagsForFargate(fs *pflag.FlagSet, options *fargate.Options)

AddFlagsForFargate configures the flags required to interact with Fargate.

func AddFlagsForFargateProfileCreation

func AddFlagsForFargateProfileCreation(fs *pflag.FlagSet, options *fargate.CreateOptions)

AddFlagsForFargateProfileCreation configures the flags required to create a Fargate profile.

func AddIAMIdentityMappingARNFlags

func AddIAMIdentityMappingARNFlags(fs *pflag.FlagSet, cmd *Cmd, arn *string, verb string)

AddIAMIdentityMappingARNFlags adds --arn and deprecated --role flags

func AddIAMServiceAccountFilterFlags

func AddIAMServiceAccountFilterFlags(fs *pflag.FlagSet, includeGlobs, excludeGlobs *[]string)

AddIAMServiceAccountFilterFlags add common `--include` and `--exclude` flags for filtering iamserviceaccounts

func AddInstanceSelectorOptions added in v0.44.0

func AddInstanceSelectorOptions(flagSetGroup *NamedFlagSetGroup, ng *api.NodeGroup)

AddInstanceSelectorOptions adds flags for EC2 instance selector

func AddNodeGroupFilterFlags

func AddNodeGroupFilterFlags(fs *pflag.FlagSet, includeGlobs, excludeGlobs *[]string)

AddNodeGroupFilterFlags add common `--include` and `--exclude` flags for filtering nodegroups

func AddPreRun

func AddPreRun(cmd *cobra.Command, newFn func(cmd *cobra.Command, args []string))

AddPreRun chains cmd.PreRun handlers, as cobra only allows one, so we don't accidentally override one we registered earlier

func AddRegionFlag

func AddRegionFlag(fs *pflag.FlagSet, p *api.ProviderConfig)

AddRegionFlag adds common --region flag

func AddResourceCmd

func AddResourceCmd(flagGrouping *FlagGrouping, parentVerbCmd *cobra.Command, newCmd func(*Cmd))

AddResourceCmd create a registers a new command under the given verb command

func AddStringToStringVarPFlag

func AddStringToStringVarPFlag(fs *pflag.FlagSet, p *map[string]string, name, shorthand string, value map[string]string, usage string)

AddStringToStringVarPFlag is a wrapper that prefixes the description of the flag for consistency

func AddSubnetIDs added in v0.61.0

func AddSubnetIDs(fs *pflag.FlagSet, subnetIDs *[]string, description string)

AddSubnetIDs adds common --subnet-ids flag

func AddTimeoutFlag

func AddTimeoutFlag(fs *pflag.FlagSet, p *time.Duration)

AddTimeoutFlag configures the timeout flag.

func AddTimeoutFlagWithValue

func AddTimeoutFlagWithValue(fs *pflag.FlagSet, p *time.Duration, value time.Duration)

AddTimeoutFlagWithValue configures the timeout flag with the provided value.

func AddUpdateAuthConfigMap

func AddUpdateAuthConfigMap(fs *pflag.FlagSet, updateAuthConfigMap *bool, description string)

AddUpdateAuthConfigMap adds common --update-auth-configmap flag

func AddVersionFlag

func AddVersionFlag(fs *pflag.FlagSet, meta *api.ClusterMeta, extraUsageInfo string)

AddVersionFlag adds common --version flag

func AddWaitFlag

func AddWaitFlag(fs *pflag.FlagSet, wait *bool, description string)

AddWaitFlag adds common --wait flag

func AddWaitFlagWithFullDescription

func AddWaitFlagWithFullDescription(fs *pflag.FlagSet, wait *bool, description string)

AddWaitFlagWithFullDescription adds common --wait flag

func ApplyFilter

func ApplyFilter(clusterConfig *api.ClusterConfig, ngFilter filter.NodegroupFilter) func()

ApplyFilter applies nodegroup filters and returns a log function

func ClusterNameFlag

func ClusterNameFlag(cmd *Cmd) string

ClusterNameFlag returns the flag to use for the cluster name taking the principal resource into account.

func ErrCannotUseWithConfigFile

func ErrCannotUseWithConfigFile(what string) error

ErrCannotUseWithConfigFile is a common error message

func ErrClusterFlagAndArg

func ErrClusterFlagAndArg(cmd *Cmd, nameFlag, nameArg string) error

ErrClusterFlagAndArg wraps ErrFlagAndArg() by passing in the proper flag name.

func ErrFlagAndArg

func ErrFlagAndArg(kind, flag, arg string) error

ErrFlagAndArg may be used to err for options that can be given as flags /and/ arg but only one is allowed to be used.

func ErrMustBeSet

func ErrMustBeSet(pathOrFlag string) error

ErrMustBeSet is a common error message

func ErrUnsupportedManagedFlag

func ErrUnsupportedManagedFlag(flag string) error

ErrUnsupportedManagedFlag reports unsupported flags for Managed Nodegroups

func ErrUnsupportedNameArg

func ErrUnsupportedNameArg() error

ErrUnsupportedNameArg reports unsupported usage of `name` argument

func ErrUnsupportedRegion

func ErrUnsupportedRegion(provider *api.ProviderConfig) error

ErrUnsupportedRegion is a common error message

func GetNameArg

func GetNameArg(args []string) string

GetNameArg tests to ensure there is only 1 name argument

func KubernetesClientAndConfigFrom

func KubernetesClientAndConfigFrom(cmd *Cmd) (kubernetes.Interface, error)

KubernetesClientAndConfigFrom returns a Kubernetes client set and REST configuration object for the currently configured cluster.

func LogCompletedAction

func LogCompletedAction(plan bool, msgFmt string, args ...interface{})

LogCompletedAction calls logger.Success with appropriate prefix

func LogIntendedAction

func LogIntendedAction(plan bool, msgFmt string, args ...interface{})

LogIntendedAction calls logger.Info with appropriate prefix

func LogPlanModeWarning

func LogPlanModeWarning(plan bool)

LogPlanModeWarning will log a message to inform user that they are in plan-mode

func LogRegionAndVersionInfo

func LogRegionAndVersionInfo(meta *api.ClusterMeta)

LogRegionAndVersionInfo will log the selected region and build version

func NewVerbCmd

func NewVerbCmd(use, short, long string) *cobra.Command

NewVerbCmd defines a standard verb command

func PopulateNodegroup

func PopulateNodegroup(ctx context.Context, stackManager manager.StackManager, name string, cfg *api.ClusterConfig, ctl api.ClusterProvider) error

func PopulateNodegroupFromStack added in v0.68.0

func PopulateNodegroupFromStack(nodeGroupType api.NodeGroupType, nodeGroupName string, cfg *api.ClusterConfig) error

PopulateNodegroupFromStack populates the nodegroup field of an api.ClusterConfig by type from its CF stack.

func PopulateUnmanagedNodegroup added in v0.68.0

func PopulateUnmanagedNodegroup(nodeGroupName string, cfg *api.ClusterConfig)

PopulateUnmanagedNodegroup populates the unmanaged nodegroup field of a ClusterConfig.

func PrintDryRunConfig added in v0.44.0

func PrintDryRunConfig(clusterConfig *v1alpha5.ClusterConfig, writer io.Writer) error

PrintDryRunConfig prints ClusterConfig for dry-run

func PrintNodeGroupDryRunConfig added in v0.44.0

func PrintNodeGroupDryRunConfig(clusterConfig *v1alpha5.ClusterConfig, writer io.Writer) error

PrintNodeGroupDryRunConfig prints the dry-run config for nodegroups, omitting any cluster-wide defaults

func ToKubeNodeGroups

func ToKubeNodeGroups(clusterConfig *api.ClusterConfig) []eks.KubeNodeGroup

ToKubeNodeGroups combines managed and unmanaged nodegroups and returns a slice of eks.KubeNodeGroup containing both types of nodegroups

func ValidateNumberOfNodes added in v0.76.0

func ValidateNumberOfNodes(ng *api.NodeGroupBase) error

ValidateNumberOfNodes validates the scaling config of a nodegroup.

Types

type ClusterConfigLoader

type ClusterConfigLoader interface {
	Load() error
}

ClusterConfigLoader is an interface that loaders should implement

func NewCreateClusterLoader

func NewCreateClusterLoader(cmd *Cmd, ngFilter *filter.NodeGroupFilter, ng *api.NodeGroup, params *CreateClusterCmdParams) ClusterConfigLoader

NewCreateClusterLoader will load config or use flags for 'eksctl create cluster'

func NewCreateFargateProfileLoader

func NewCreateFargateProfileLoader(cmd *Cmd, options *fargate.CreateOptions) ClusterConfigLoader

NewCreateFargateProfileLoader will load config or use flags for 'eksctl create fargateprofile'

func NewCreateIAMServiceAccountLoader

func NewCreateIAMServiceAccountLoader(cmd *Cmd, saFilter *filter.IAMServiceAccountFilter) ClusterConfigLoader

NewCreateIAMServiceAccountLoader will load config or use flags for 'eksctl create iamserviceaccount'

func NewCreateNodeGroupLoader

func NewCreateNodeGroupLoader(cmd *Cmd, ng *api.NodeGroup, ngFilter *filter.NodeGroupFilter, ngOptions CreateNGOptions, mngOptions CreateManagedNGOptions) ClusterConfigLoader

NewCreateNodeGroupLoader will load config or use flags for 'eksctl create nodegroup'

func NewCreateOrUpgradeAddonLoader

func NewCreateOrUpgradeAddonLoader(cmd *Cmd) ClusterConfigLoader

func NewDeleteAddonLoader

func NewDeleteAddonLoader(cmd *Cmd) ClusterConfigLoader

func NewDeleteAndDrainNodeGroupLoader added in v0.90.0

func NewDeleteAndDrainNodeGroupLoader(cmd *Cmd, ng *api.NodeGroup, ngFilter *filter.NodeGroupFilter) ClusterConfigLoader

NewDeleteAndDrainNodeGroupLoader will load config or use flags for 'eksctl delete nodegroup'

func NewDeleteFargateProfileLoader

func NewDeleteFargateProfileLoader(cmd *Cmd, options *fargate.Options) ClusterConfigLoader

NewDeleteFargateProfileLoader will load config or use flags for 'eksctl delete fargateprofile'

func NewDeleteIAMServiceAccountLoader

func NewDeleteIAMServiceAccountLoader(cmd *Cmd, sa *api.ClusterIAMServiceAccount, saFilter *filter.IAMServiceAccountFilter) ClusterConfigLoader

NewDeleteIAMServiceAccountLoader will load config or use flags for 'eksctl delete iamserviceaccount'

func NewGetAddonsLoader added in v0.125.0

func NewGetAddonsLoader(cmd *Cmd) ClusterConfigLoader

NewGetAddonsLoader loads config file and validates command for `eksctl get addon`.

func NewGetClusterLoader added in v0.76.0

func NewGetClusterLoader(cmd *Cmd) ClusterConfigLoader

NewGetClusterLoader will load config or use flags for 'eksctl get cluster(s)'

func NewGetFargateProfileLoader

func NewGetFargateProfileLoader(cmd *Cmd, options *fargate.Options) ClusterConfigLoader

NewGetFargateProfileLoader will load config or use flags for 'eksctl get fargateprofile'

func NewGetIAMServiceAccountLoader

func NewGetIAMServiceAccountLoader(cmd *Cmd, options *irsa.GetOptions) ClusterConfigLoader

NewGetIAMServiceAccountLoader will load config or use flags for 'eksctl get iamserviceaccount'

func NewGetLabelsLoader added in v0.75.0

func NewGetLabelsLoader(cmd *Cmd, ngName string) ClusterConfigLoader

NewGetLabelsLoader loads config file and validates command for `eksctl get labels`.

func NewGetNodegroupLoader added in v0.75.0

func NewGetNodegroupLoader(cmd *Cmd, ng *api.NodeGroup) ClusterConfigLoader

NewGetNodegroupLoader loads config file and validates command for `eksctl get nodegroup`.

func NewMetadataLoader

func NewMetadataLoader(cmd *Cmd) ClusterConfigLoader

NewMetadataLoader handles loading of clusterConfigFile vs using flags for all commands that require only metadata fields, e.g. `eksctl delete cluster` or `eksctl utils update-kube-proxy` and other similar commands that do simple operations against existing clusters

func NewScaleAllNodeGroupLoader added in v0.76.0

func NewScaleAllNodeGroupLoader(cmd *Cmd) ClusterConfigLoader

NewScaleAllNodeGroupLoader will load config or use flags for 'eksctl scale nodegroup'

func NewScaleNodeGroupLoader

func NewScaleNodeGroupLoader(cmd *Cmd, ng *api.NodeGroupBase) ClusterConfigLoader

NewScaleNodeGroupLoader will load config or use flags for 'eksctl scale nodegroup'

func NewSetLabelLoader added in v0.77.0

func NewSetLabelLoader(cmd *Cmd, nodeGroupName string, labels map[string]string) ClusterConfigLoader

NewSetLabelLoader will load config or use flags for 'eksctl set labels'

func NewUpdateNodegroupLoader added in v0.55.0

func NewUpdateNodegroupLoader(cmd *Cmd) ClusterConfigLoader

NewUpdateNodegroupLoader will load config or use flags for 'eksctl update nodegroup'.

func NewUtilsAssociateIAMOIDCProviderLoader

func NewUtilsAssociateIAMOIDCProviderLoader(cmd *Cmd) ClusterConfigLoader

NewUtilsAssociateIAMOIDCProviderLoader will load config or use flags for 'eksctl utils associal-iam-oidc-provider'

func NewUtilsEnableEndpointAccessLoader

func NewUtilsEnableEndpointAccessLoader(cmd *Cmd, privateAccess, publicAccess bool) ClusterConfigLoader

NewUtilsEnableEndpointAccessLoader will load config or use flags for 'eksctl utils update-cluster-endpoints'.

func NewUtilsEnableLoggingLoader

func NewUtilsEnableLoggingLoader(cmd *Cmd) ClusterConfigLoader

NewUtilsEnableLoggingLoader will load config or use flags for 'eksctl utils update-cluster-logging'

func NewUtilsKMSLoader added in v0.39.0

func NewUtilsKMSLoader(cmd *Cmd) ClusterConfigLoader

func NewUtilsPublicAccessCIDRsLoader

func NewUtilsPublicAccessCIDRsLoader(cmd *Cmd) ClusterConfigLoader

NewUtilsPublicAccessCIDRsLoader loads config or uses flags for `eksctl utils set-public-access-cidrs <cidrs>`

type Cmd

type Cmd struct {
	CobraCommand *cobra.Command
	FlagSetGroup *NamedFlagSetGroup

	Plan, Wait, Validate bool

	NameArg string

	ClusterConfigFile string

	ProviderConfig api.ProviderConfig
	ClusterConfig  *api.ClusterConfig

	Include, Exclude []string
}

Cmd holds attributes that are common between commands; not all commands use each attribute, but they can if needed

func (*Cmd) InitializeClusterConfig added in v0.112.0

func (c *Cmd) InitializeClusterConfig() error

InitializeClusterConfig validates and initializes the ClusterConfig.

func (*Cmd) NewCtl

func (c *Cmd) NewCtl() (*eks.ClusterProvider, error)

NewCtl performs common defaulting and validation and constructs a new instance of eks.ClusterProvider, it may return an error if configuration is invalid or region is not supported

func (*Cmd) NewProviderForExistingCluster added in v0.67.0

func (c *Cmd) NewProviderForExistingCluster(ctx context.Context) (*eks.ClusterProvider, error)

NewProviderForExistingCluster is a wrapper for NewCtl that also validates that the cluster exists and is not a registered/connected cluster.

func (*Cmd) NewProviderForExistingClusterHelper added in v0.120.0

func (c *Cmd) NewProviderForExistingClusterHelper(ctx context.Context, standardizeClusterVersionFormat func(ctl *eks.ClusterProvider, meta *api.ClusterMeta) error) (*eks.ClusterProvider, error)

NewProviderForExistingClusterHelper allows formating cluster K8s version to a standard value before doing nodegroup validations and initializations

func (*Cmd) SetDescription

func (c *Cmd) SetDescription(use, short, long string, aliases ...string)

SetDescription sets usage along with short and long descriptions as well as aliases

type ConfigLoaderBuilder added in v0.39.0

type ConfigLoaderBuilder struct {
	FlagsIncompatibleWithConfigFile    sets.String
	FlagsIncompatibleWithoutConfigFile sets.String
	// contains filtered or unexported fields
}

func NewConfigLoaderBuilder added in v0.39.0

func NewConfigLoaderBuilder() ConfigLoaderBuilder

func (*ConfigLoaderBuilder) Build added in v0.39.0

func (*ConfigLoaderBuilder) Validate added in v0.39.0

func (b *ConfigLoaderBuilder) Validate(f ValidateCmdFunc)

func (*ConfigLoaderBuilder) ValidateWithConfigFile added in v0.39.0

func (b *ConfigLoaderBuilder) ValidateWithConfigFile(f ValidateCmdFunc)

func (*ConfigLoaderBuilder) ValidateWithoutConfigFile added in v0.39.0

func (b *ConfigLoaderBuilder) ValidateWithoutConfigFile(f ValidateCmdFunc)

type CreateClusterCmdParams

type CreateClusterCmdParams struct {
	WriteKubeconfig             bool
	KubeconfigPath              string
	AutoKubeconfigPath          bool
	AuthenticatorRoleARN        string
	SetContext                  bool
	AvailabilityZones           []string
	InstallWindowsVPCController bool

	KopsClusterNameForVPC string
	Subnets               map[api.SubnetTopology]*[]string
	WithoutNodeGroup      bool
	Fargate               bool
	DryRun                bool
	CreateNGOptions
	CreateManagedNGOptions
}

CreateClusterCmdParams groups CLI options for the create cluster command.

type CreateManagedNGOptions

type CreateManagedNGOptions struct {
	Managed       bool
	Spot          bool
	InstanceTypes []string
}

CreateManagedNGOptions holds options for creating a managed nodegroup

type CreateNGOptions added in v0.42.0

type CreateNGOptions struct {
	InstallNeuronDevicePlugin bool
	InstallNvidiaDevicePlugin bool
	DryRun                    bool
}

CreateNGOptions holds options for creating a nodegroup

type FlagGrouping

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

FlagGrouping holds a superset of all flagsets for all commands

func NewGrouping

func NewGrouping() *FlagGrouping

NewGrouping creates an instance of Grouping

func (*FlagGrouping) New

New creates a new group of flagsets for use with a subcommand

func (*FlagGrouping) Usage

func (g *FlagGrouping) Usage(cmd *cobra.Command) error

Usage is for use with (*cobra.Command).SetUsageFunc

type GitOpsConfigLoader

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

GitOpsConfigLoader handles loading of ClusterConfigFile v.s. using CLI flags for GitOps-related commands.

func NewGitOpsConfigLoader

func NewGitOpsConfigLoader(cmd *Cmd) *GitOpsConfigLoader

NewGitOpsConfigLoader creates a new ClusterConfigLoader which handles loading of ClusterConfigFile GitOps-related commands.

func (*GitOpsConfigLoader) Load

func (l *GitOpsConfigLoader) Load() error

Load ClusterConfig or use CLI flags.

type NamedFlagSetGroup

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

NamedFlagSetGroup holds a single group of flagsets

func (*NamedFlagSetGroup) AddTo

func (n *NamedFlagSetGroup) AddTo(cmd *cobra.Command)

AddTo mixes all flagsets in the given group into another flagset

func (*NamedFlagSetGroup) InFlagSet

func (n *NamedFlagSetGroup) InFlagSet(name string, cb func(*pflag.FlagSet))

InFlagSet returns new or existing named FlagSet in a group

type ValidateCmdFunc added in v0.39.0

type ValidateCmdFunc = func(cmd *Cmd) error

Directories

Path Synopsis
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
filterfakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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