{"record":{"id":"bb3ea928b43d4cbb","repo":"kubernetes/kops","slug":"name-is-required-bb3ea9","errorCode":null,"errorMessage":"--name is required","messagePattern":"--name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/promote_keypair.go","lineNumber":82,"sourceCode":"\tClusterName string\n\tKeyset      string\n\tKeypairID   string\n}\n\n// NewCmdPromoteKeypair returns a promote keypair command.\nfunc NewCmdPromoteKeypair(f *util.Factory, out io.Writer) *cobra.Command {\n\toptions := &PromoteKeypairOptions{}\n\n\tcmd := &cobra.Command{\n\t\tUse:     \"keypair {KEYSET [ID] | all}\",\n\t\tShort:   promoteKeypairShort,\n\t\tLong:    promoteKeypairLong,\n\t\tExample: promoteKeypairExample,\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\toptions.ClusterName = rootCommand.ClusterName(true)\n\n\t\t\tif options.ClusterName == \"\" {\n\t\t\t\treturn fmt.Errorf(\"--name is required\")\n\t\t\t}\n\n\t\t\tif len(args) == 0 {\n\t\t\t\treturn fmt.Errorf(\"must specify name of keyset promote keypair in\")\n\t\t\t}\n\n\t\t\toptions.Keyset = args[0]\n\n\t\t\tif len(args) > 2 {\n\t\t\t\treturn fmt.Errorf(\"can only promote to one keyset at a time\")\n\t\t\t}\n\t\t\tif len(args) > 1 {\n\t\t\t\tif options.Keyset == \"all\" {\n\t\t\t\t\treturn fmt.Errorf(\"cannot specify ID with \\\"all\\\"\")\n\t\t\t\t}\n\n\t\t\t\toptions.KeypairID = args[1]\n\t\t\t}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/promote_keypair.go#L64-L100","documentation":"RunPromoteKeypair needs a target cluster. The cobra Args validator for `kops promote keypair` reads the cluster name from rootCommand.ClusterName(true); if it is empty (no --name flag and no cluster in context/kubecfg), it fails fast with this message.","triggerScenarios":"Running `kops promote keypair <keyset>` without --name and without a cluster name set via KOPS_CLUSTER_NAME, context state, or the --name flag.","commonSituations":"Forgetting --name when scripting; running from a machine with no kops state store access so the cluster cannot be defaulted; typo in --name such that the flag parser ignored it.","solutions":["Add --name <cluster.k8s.local> to the command","Export KOPS_CLUSTER_NAME or ensure the cluster name is resolvable from the current kops context","Check flag spelling (kops uses --name, not --cluster)","Run `kops get clusters` to confirm the exact cluster name"],"exampleFix":"// before\nkops promote keypair all\n// after\nkops promote keypair all --name mycluster.k8s.local","handlingStrategy":"validation","validationCode":"if [ -z \"$KOPS_CLUSTER_NAME\" ]; then echo \"usage: kops promote keypair <keyset> --name <cluster>\"; exit 1; fi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --name explicitly in scripts","Set KOPS_CLUSTER_NAME in your shell profile for single-cluster workflows","Verify with `kops get clusters` before promotion"],"tags":["cli","flag-validation","cluster-name"],"backgroundTag":"missing-required-flag","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}