Merge pull request #14138 from olemarkus/revert-positional-arg

Revert "Remove passing cluster name as positional argument"
This commit is contained in:
Kubernetes Prow Robot 2022-08-18 03:28:37 -07:00 committed by GitHub
commit 161d30b743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 38 additions and 50 deletions

View File

@ -180,7 +180,7 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
encryptEtcdStorage := false encryptEtcdStorage := false
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "cluster", Use: "cluster [CLUSTER]",
Short: createClusterShort, Short: createClusterShort,
Long: createClusterLong, Long: createClusterLong,
Example: createClusterExample, Example: createClusterExample,

View File

@ -64,7 +64,7 @@ func NewCmdCreateSecretCiliumPassword(f *util.Factory, out io.Writer) *cobra.Com
options := &CreateSecretCiliumPasswordOptions{} options := &CreateSecretCiliumPasswordOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "ciliumpassword -f FILENAME", Use: "ciliumpassword [CLUSTER] -f FILENAME",
Short: createSecretCiliumPasswordShort, Short: createSecretCiliumPasswordShort,
Long: createSecretCiliumPasswordLong, Long: createSecretCiliumPasswordLong,
Example: createSecretCiliumPasswordExample, Example: createSecretCiliumPasswordExample,

View File

@ -69,7 +69,7 @@ func NewCmdCreateSecretDockerConfig(f *util.Factory, out io.Writer) *cobra.Comma
options := &CreateSecretDockerConfigOptions{} options := &CreateSecretDockerConfigOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "dockerconfig -f FILENAME", Use: "dockerconfig [CLUSTER] -f FILENAME",
Short: createSecretDockerConfigShort, Short: createSecretDockerConfigShort,
Long: createSecretDockerConfigLong, Long: createSecretDockerConfigLong,
Example: createSecretDockerConfigExample, Example: createSecretDockerConfigExample,

View File

@ -63,7 +63,7 @@ func NewCmdCreateSecretEncryptionConfig(f *util.Factory, out io.Writer) *cobra.C
options := &CreateSecretEncryptionConfigOptions{} options := &CreateSecretEncryptionConfigOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "encryptionconfig -f FILENAME", Use: "encryptionconfig [CLUSTER] -f FILENAME",
Short: createSecretEncryptionConfigShort, Short: createSecretEncryptionConfigShort,
Long: createSecretEncryptionConfigLong, Long: createSecretEncryptionConfigLong,
Example: createSecretEncryptionConfigExample, Example: createSecretEncryptionConfigExample,

View File

@ -71,7 +71,7 @@ func NewCmdCreateSecretWeavePassword(f *util.Factory, out io.Writer) *cobra.Comm
options := &CreateSecretWeavePasswordOptions{} options := &CreateSecretWeavePasswordOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "weavepassword", Use: "weavepassword [CLUSTER]",
Short: createSecretWeavePasswordShort, Short: createSecretWeavePasswordShort,
Long: createSecretWeavePasswordLong, Long: createSecretWeavePasswordLong,
Example: createSecretWeavePasswordExample, Example: createSecretWeavePasswordExample,

View File

@ -52,7 +52,7 @@ func NewCmdCreateSSHPublicKey(f *util.Factory, out io.Writer) *cobra.Command {
options := &CreateSSHPublicKeyOptions{} options := &CreateSSHPublicKeyOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "sshpublickey", Use: "sshpublickey [CLUSTER]",
Short: createSSHPublicKeyShort, Short: createSSHPublicKeyShort,
Long: createSSHPublicKeyLong, Long: createSSHPublicKeyLong,
Example: createSSHPublicKeyExample, Example: createSSHPublicKeyExample,

View File

@ -66,7 +66,7 @@ func NewCmdDeleteCluster(f *util.Factory, out io.Writer) *cobra.Command {
options := &DeleteClusterOptions{} options := &DeleteClusterOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "cluster", Use: "cluster [CLUSTER]",
Short: deleteClusterShort, Short: deleteClusterShort,
Long: deleteClusterLong, Long: deleteClusterLong,
Example: deleteClusterExample, Example: deleteClusterExample,

View File

@ -46,7 +46,7 @@ func NewCmdDeleteSSHPublicKey(f *util.Factory, out io.Writer) *cobra.Command {
options := &DeleteSSHPublicKeyOptions{} options := &DeleteSSHPublicKeyOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "sshpublickey", Use: "sshpublickey [CLUSTER]",
Short: deleteSSHPublicKeyShort, Short: deleteSSHPublicKeyShort,
Example: deleteSSHPublicKeyExample, Example: deleteSSHPublicKeyExample,
Args: rootCommand.clusterNameArgs(&options.ClusterName), Args: rootCommand.clusterNameArgs(&options.ClusterName),

View File

@ -74,7 +74,7 @@ func NewCmdEditCluster(f *util.Factory, out io.Writer) *cobra.Command {
options := &EditClusterOptions{} options := &EditClusterOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "cluster", Use: "cluster [CLUSTER]",
Short: i18n.T("Edit cluster."), Short: i18n.T("Edit cluster."),
Long: editClusterLong, Long: editClusterLong,
Example: editClusterExample, Example: editClusterExample,

View File

@ -84,7 +84,7 @@ func NewCmdGetAssets(f *util.Factory, out io.Writer, getOptions *GetOptions) *co
} }
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "assets", Use: "assets [CLUSTER]",
Short: getAssetsShort, Short: getAssetsShort,
Long: getAssetsLong, Long: getAssetsLong,
Example: getAssetsExample, Example: getAssetsExample,

View File

@ -67,7 +67,7 @@ type renderableCloudInstance struct {
func NewCmdGetInstances(f *util.Factory, out io.Writer, options *GetOptions) *cobra.Command { func NewCmdGetInstances(f *util.Factory, out io.Writer, options *GetOptions) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "instances", Use: "instances [CLUSTER]",
Short: getInstancesShort, Short: getInstancesShort,
Example: getInstancesExample, Example: getInstancesExample,
Args: rootCommand.clusterNameArgs(&options.ClusterName), Args: rootCommand.clusterNameArgs(&options.ClusterName),

View File

@ -50,7 +50,7 @@ func NewCmdGetSSHPublicKeys(f *util.Factory, out io.Writer, getOptions *GetOptio
GetOptions: getOptions, GetOptions: getOptions,
} }
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "sshpublickeys", Use: "sshpublickeys [CLUSTER]",
Aliases: []string{"sshpublickey", "ssh"}, Aliases: []string{"sshpublickey", "ssh"},
Short: getSSHPublicKeysShort, Short: getSSHPublicKeysShort,
Example: getSSHPublicKeysExample, Example: getSSHPublicKeysExample,

View File

@ -166,7 +166,7 @@ func NewCmdRollingUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command {
options.InitDefaults() options.InitDefaults()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "cluster", Use: "cluster [CLUSTER]",
Short: rollingupdateShort, Short: rollingupdateShort,
Long: rollingupdateLong, Long: rollingupdateLong,
Example: rollingupdateExample, Example: rollingupdateExample,

View File

@ -37,7 +37,6 @@ import (
"k8s.io/kops/pkg/client/simple" "k8s.io/kops/pkg/client/simple"
"k8s.io/kops/pkg/commands" "k8s.io/kops/pkg/commands"
"k8s.io/kops/pkg/commands/commandutils" "k8s.io/kops/pkg/commands/commandutils"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kubectl/pkg/util/i18n" "k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates" "k8s.io/kubectl/pkg/util/templates"
) )
@ -268,13 +267,10 @@ func (c *RootCmd) clusterNameArgsAllowNoCluster(clusterName *string) func(cmd *c
func (c *RootCmd) ProcessArgs(args []string) error { func (c *RootCmd) ProcessArgs(args []string) error {
if len(args) > 0 { if len(args) > 0 {
fmt.Fprintf(os.Stderr, "\n") fmt.Fprintf(os.Stderr, "\n")
fmt.Fprintf(os.Stderr, "\nClusterName as positional argument is deprecated and will be removed\n") fmt.Fprintf(os.Stderr, "\nClusterName as positional argument is deprecated and will be removed in a future version\n")
fmt.Fprintf(os.Stderr, "Use `KOPS_FEATURE_FLAGS=PositionalClusterArg` to revert to the old behavior.")
fmt.Fprintf(os.Stderr, "\n") fmt.Fprintf(os.Stderr, "\n")
} }
if !featureflag.PositionalClusterArg.Enabled() {
return nil
}
if len(args) == 0 { if len(args) == 0 {
return nil return nil
} }

View File

@ -75,7 +75,7 @@ func NewCmdToolboxDump(f commandutils.Factory, out io.Writer) *cobra.Command {
options.InitDefaults() options.InitDefaults()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "dump", Use: "dump [CLUSTER]",
Short: toolboxDumpShort, Short: toolboxDumpShort,
Long: toolboxDumpLong, Long: toolboxDumpLong,
Example: toolboxDumpExample, Example: toolboxDumpExample,

View File

@ -79,7 +79,7 @@ func NewCmdToolboxTemplate(f commandutils.Factory, out io.Writer) *cobra.Command
} }
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "template", Use: "template [CLUSTER]",
Short: toolboxTemplatingShort, Short: toolboxTemplatingShort,
Long: toolboxTemplatingLong, Long: toolboxTemplatingLong,
Example: toolboxTemplatingExample, Example: toolboxTemplatingExample,

View File

@ -101,7 +101,7 @@ func NewCmdUpdateCluster(f *util.Factory, out io.Writer) *cobra.Command {
options.InitDefaults() options.InitDefaults()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "cluster", Use: "cluster [CLUSTER]",
Short: updateClusterShort, Short: updateClusterShort,
Long: updateClusterLong, Long: updateClusterLong,
Example: updateClusterExample, Example: updateClusterExample,

View File

@ -66,7 +66,7 @@ func NewCmdUpgradeCluster(f *util.Factory, out io.Writer) *cobra.Command {
options := &UpgradeClusterOptions{} options := &UpgradeClusterOptions{}
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "cluster", Use: "cluster [CLUSTER]",
Short: upgradeClusterShort, Short: upgradeClusterShort,
Long: upgradeClusterLong, Long: upgradeClusterLong,
Example: upgradeClusterExample, Example: upgradeClusterExample,

View File

@ -78,7 +78,7 @@ func NewCmdValidateCluster(f *util.Factory, out io.Writer) *cobra.Command {
options.InitDefaults() options.InitDefaults()
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "cluster", Use: "cluster [CLUSTER]",
Short: validateClusterShort, Short: validateClusterShort,
Long: validateClusterLong, Long: validateClusterLong,
Example: validateClusterExample, Example: validateClusterExample,

View File

@ -12,7 +12,7 @@ Create a Kubernetes cluster using command line flags. This command creates cloud
These operations are done in parallel and rely on eventual consistency. These operations are done in parallel and rely on eventual consistency.
``` ```
kops create cluster [flags] kops create cluster [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -10,7 +10,7 @@ Create a Cilium IPsec configuration.
Create a new Cilium IPsec configuration and store it in the state store. This is used by Cilium to encrypt communication between pods/nodes. Create a new Cilium IPsec configuration and store it in the state store. This is used by Cilium to encrypt communication between pods/nodes.
``` ```
kops create secret ciliumpassword -f FILENAME [flags] kops create secret ciliumpassword [CLUSTER] -f FILENAME [flags]
``` ```
### Examples ### Examples

View File

@ -14,7 +14,7 @@ Create a new Docker config and store it in the state store. Used to configure Do
This will also work when using containerd as the container runtime. This will also work when using containerd as the container runtime.
``` ```
kops create secret dockerconfig -f FILENAME [flags] kops create secret dockerconfig [CLUSTER] -f FILENAME [flags]
``` ```
### Examples ### Examples

View File

@ -10,7 +10,7 @@ Create an encryption config.
Create a new encryption config and store it in the state store. Used to configure encryption-at-rest by the kube-apiserver process. Create a new encryption config and store it in the state store. Used to configure encryption-at-rest by the kube-apiserver process.
``` ```
kops create secret encryptionconfig -f FILENAME [flags] kops create secret encryptionconfig [CLUSTER] -f FILENAME [flags]
``` ```
### Examples ### Examples

View File

@ -14,7 +14,7 @@ Create a new weave encryption secret and store it in the state store. Used by We
WARNING: cannot be enabled or changed on a running cluster without downtime. WARNING: cannot be enabled or changed on a running cluster without downtime.
``` ```
kops create secret weavepassword [flags] kops create secret weavepassword [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -10,7 +10,7 @@ Create an SSH public key.
Create a new SSH public key, and store the key in the state store. The key is not updated by this command. Create a new SSH public key, and store the key in the state store. The key is not updated by this command.
``` ```
kops create sshpublickey [flags] kops create sshpublickey [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -10,7 +10,7 @@ Delete a cluster.
Deletes a Kubernetes cluster and all associated resources. Resources include instancegroups, secrets, and the state store. There is no "UNDO" for this command. Deletes a Kubernetes cluster and all associated resources. Resources include instancegroups, secrets, and the state store. There is no "UNDO" for this command.
``` ```
kops delete cluster [flags] kops delete cluster [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -6,7 +6,7 @@
Delete an SSH public key. Delete an SSH public key.
``` ```
kops delete sshpublickey [flags] kops delete sshpublickey [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -17,7 +17,7 @@ This command changes the desired cluster configuration in the registry.
kops edit does not update the cloud resources; to apply the changes use `kops update cluster`. kops edit does not update the cloud resources; to apply the changes use `kops update cluster`.
``` ```
kops edit cluster [flags] kops edit cluster [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -14,7 +14,7 @@ When invoked with the `--copy` flag, will copy each asset from the
canonical to the download location. canonical to the download location.
``` ```
kops get assets [flags] kops get assets [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -6,7 +6,7 @@
Display cluster instances. Display cluster instances.
``` ```
kops get instances [flags] kops get instances [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -6,7 +6,7 @@
Get one or many secrets. Get one or many secrets.
``` ```
kops get sshpublickeys [flags] kops get sshpublickeys [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -22,7 +22,7 @@ Note: terraform users will need to run all of the following commands from the sa
`terraform apply` prior to running `kops rolling-update cluster`. `terraform apply` prior to running `kops rolling-update cluster`.
``` ```
kops rolling-update cluster [flags] kops rolling-update cluster [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -10,7 +10,7 @@ Dump cluster information
Displays cluster information. Includes information about cloud and Kubernetes resources. Displays cluster information. Includes information about cloud and Kubernetes resources.
``` ```
kops toolbox dump [flags] kops toolbox dump [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -10,7 +10,7 @@ Generate cluster.yaml from template
Generate cluster.yaml from values input yaml file and apply template. Generate cluster.yaml from values input yaml file and apply template.
``` ```
kops toolbox template [flags] kops toolbox template [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -12,7 +12,7 @@ Create or update cloud or cluster resources to match the current cluster and ins
If, such as during a Kubernetes upgrade, nodes need updating, a rolling-update may be subsequently required. If, such as during a Kubernetes upgrade, nodes need updating, a rolling-update may be subsequently required.
``` ```
kops update cluster [flags] kops update cluster [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -12,7 +12,7 @@ production ready Kubernetes version. After this command is run, use `kops update
to finish a cluster upgrade. to finish a cluster upgrade.
``` ```
kops upgrade cluster [flags] kops upgrade cluster [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -15,7 +15,7 @@ This commands validates the following components:
4. All pods with a critical priority are running and have "Ready" status. 4. All pods with a critical priority are running and have "Ready" status.
``` ```
kops validate cluster [flags] kops validate cluster [CLUSTER] [flags]
``` ```
### Examples ### Examples

View File

@ -20,12 +20,6 @@ This changes the default behavior where the CSI snaphotter container was always
So in case of manually deployed CRDs to make the snapshotter work it is now necessary to [enable the snapshot controller](https://kops.sigs.k8s.io/addons/#snapshot-controller). So in case of manually deployed CRDs to make the snapshotter work it is now necessary to [enable the snapshot controller](https://kops.sigs.k8s.io/addons/#snapshot-controller).
## kOps CLI no longer accepts cluster name as positional argument
Prior to kOps 1.25, one could pass cluser name as a CLI argument to most functions. E.g `kOps get <clustername>`. As of kOps 1.25, kOps commands only accepts the cluster name through the `--name` flag or the `KOPS_CLUSTER_NAME` environment variable. The one exception to this change is the `kops get cluster` command, which still accepts one or more cluster names as positional arguments.
This change is behind a feature flag. For now, one can revert to the old behavior by setting `KOPS_FEATURE_FLAGS=PositionalClusterArg`.
## Other breaking changes ## Other breaking changes
* Support for Kubernetes version 1.19 has been removed. * Support for Kubernetes version 1.19 has been removed.

View File

@ -92,8 +92,6 @@ var (
ImageDigest = new("ImageDigest", Bool(true)) ImageDigest = new("ImageDigest", Bool(true))
// Hetzner toggles the Hetzner Cloud support. // Hetzner toggles the Hetzner Cloud support.
Hetzner = new("Hetzner", Bool(false)) Hetzner = new("Hetzner", Bool(false))
// PositionalClusterArg enables passing cluster name as positional argument to various kOps commands
PositionalClusterArg = new("PositionalClusterArg", Bool(false))
) )
// FeatureFlag defines a feature flag // FeatureFlag defines a feature flag