cmdutils

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: Apache-2.0 Imports: 26 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 AddCommonCreateNodeGroupFlags

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

AddCommonCreateNodeGroupFlags adds common flags for creating a nodegroup

func AddCommonCreateNodeGroupIAMAddonsFlags

func AddCommonCreateNodeGroupIAMAddonsFlags(fs *pflag.FlagSet, ng *api.NodeGroup)

AddCommonCreateNodeGroupIAMAddonsFlags adds flags to set ng.IAM.WithAddonPolicies

func AddCommonFlagsForAWS

func AddCommonFlagsForAWS(group *NamedFlagSetGroup, p *api.ProviderConfig, addCfnOptions bool)

AddCommonFlagsForAWS adds common flags for api.ProviderConfig

func AddCommonFlagsForFlux

func AddCommonFlagsForFlux(fs *pflag.FlagSet, opts *api.Git)

FLUX V1 DEPRECATION NOTICE. https://github.com/weaveworks/eksctl/issues/2963 AddCommonFlagsForFlux configures the flags required to install Flux on an EKS cluster and have it point to the specified Git repository.

func AddCommonFlagsForGetCmd

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

AddCommonFlagsForGetCmd adds common flafs for get commands

func AddCommonFlagsForGitRepo added in v0.39.0

func AddCommonFlagsForGitRepo(fs *pflag.FlagSet, repo *api.Repo)

FLUX V1 DEPRECATION NOTICE. https://github.com/weaveworks/eksctl/issues/2963 AddCommonFlagsForGitRepo configures the flags required to interact with a Git repository.

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 AddCommonFlagsForProfile

func AddCommonFlagsForProfile(fs *pflag.FlagSet, opts *api.Profile)

AddCommonFlagsForProfile configures the flags required to enable a Quick Start profile.

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)

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 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 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.Clientset, *rest.Config, 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(stackManager manager.StackManager, name string, cfg *api.ClusterConfig, ctl api.ClusterProvider) error

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 ToNodePools

func ToNodePools(clusterConfig *api.ClusterConfig) []api.NodePool

ToNodePools combines managed and self-managed nodegroups and returns a slice of api.NodePool

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, 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 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 NewDeleteNodeGroupLoader

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

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

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 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 NewScaleNodeGroupLoader

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

NewScaleNodeGroupLoader will load config or use flags for 'eksctl scale 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) 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) 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
	InstallNeuronDevicePlugin   bool
	InstallNvidiaDevicePlugin   bool
	KopsClusterNameForVPC       string
	Subnets                     map[api.SubnetTopology]*[]string
	WithoutNodeGroup            bool
	Fargate                     bool
	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 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 GitConfigLoader added in v0.39.0

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

FLUX V1 DEPRECATION NOTICE. https://github.com/weaveworks/eksctl/issues/2963 GitConfigLoader handles loading of ClusterConfigFile v.s. using CLI flags for Git-related commands.

func NewGitConfigLoader added in v0.39.0

func NewGitConfigLoader(cmd *Cmd, cfg *api.Git) *GitConfigLoader

FLUX V1 DEPRECATION NOTICE. https://github.com/weaveworks/eksctl/issues/2963 NewGitConfigLoader creates a new ClusterConfigLoader which handles loading of ClusterConfigFile v.s. using CLI flags for Git-related commands.

func (*GitConfigLoader) Load added in v0.39.0

func (l *GitConfigLoader) Load() error

FLUX V1 DEPRECATION NOTICE. https://github.com/weaveworks/eksctl/issues/2963 Load ClusterConfig or use CLI flags.

func (*GitConfigLoader) WithProfileValidation added in v0.39.0

func (l *GitConfigLoader) WithProfileValidation() *GitConfigLoader

FLUX V1 DEPRECATION NOTICE. https://github.com/weaveworks/eksctl/issues/2963 WithProfileValidation adds extra validation to make sure that the git url and the email are provided as they are required for the commands enable profile and enable repo (but not for generate profile)

func (*GitConfigLoader) WithRepoValidation added in v0.39.0

func (l *GitConfigLoader) WithRepoValidation() *GitConfigLoader

FLUX V1 DEPRECATION NOTICE. https://github.com/weaveworks/eksctl/issues/2963 WithRepoValidation adds extra validation to make sure that the git url and the email are provided as they are required for the commands enable profile and enable repo (but not for generate profile)

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

Jump to

Keyboard shortcuts

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