{"record":{"id":"95fc47be365e92fa","repo":"kubernetes/kops","slug":"must-specify-name-of-keyset-to-add-keypair-to","errorCode":null,"errorMessage":"must specify name of keyset to add keypair to","messagePattern":"must specify name of keyset to add keypair to","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/create_keypair.go","lineNumber":107,"sourceCode":"\n// NewCmdCreateKeypair returns a create keypair command.\nfunc NewCmdCreateKeypair(f *util.Factory, out io.Writer) *cobra.Command {\n\toptions := &CreateKeypairOptions{}\n\n\tcmd := &cobra.Command{\n\t\tUse:     \"keypair {KEYSET | all}\",\n\t\tShort:   createKeypairShort,\n\t\tLong:    createKeypairLong,\n\t\tExample: createKeypairExample,\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 to add keypair to\")\n\t\t\t}\n\n\t\t\toptions.Keyset = args[0]\n\n\t\t\tif len(args) != 1 {\n\t\t\t\treturn fmt.Errorf(\"can only add to one keyset at a time\")\n\t\t\t}\n\n\t\t\tif options.Keyset == \"all\" {\n\t\t\t\tif options.CertPath != \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"cannot specify --cert with \\\"all\\\"\")\n\t\t\t\t}\n\t\t\t\tif options.PrivateKeyPath != \"\" {\n\t\t\t\t\treturn fmt.Errorf(\"cannot specify --key with \\\"all\\\"\")\n\t\t\t\t}\n\t\t\t\tif options.Primary {\n\t\t\t\t\treturn fmt.Errorf(\"cannot specify --primary with \\\"all\\\"\")\n\t\t\t\t}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/create_keypair.go#L89-L125","documentation":"The Args validator requires exactly at least one positional argument naming the keyset (e.g. apiserver, kubelet, ca) to which a new keypair will be added. With zero args, the command cannot proceed and returns this message.","triggerScenarios":"Running `kops create keypair --name <cluster>` with no keyset argument at all.","commonSituations":"Omitting the keyset name when copy-pasting the command skeleton; scripting where a variable holding the keyset is empty; confusing `create keypair` with `export kubecfg`-style commands that need no argument.","solutions":["Provide the keyset name: `kops create keypair --name <cluster> <keyset>` (e.g. `ca`, `apiserver`, `kubelet`)","List available keysets with `kops get secrets` / cluster keyset listing to pick a valid name","Fix empty variables in scripts that interpolate the keyset argument"],"exampleFix":"// before\nkops create keypair --name c.k8s.local\n// after\nkops create keypair --name c.k8s.local apiserver","handlingStrategy":"validation","validationCode":"[ $# -ge 1 ] || { echo \"usage: kops create keypair --name <cluster> <keyset>\" >&2; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the keyset positional argument","Guard scripts against empty variables feeding the argument","Check --help for the expected argument shape"],"tags":["cli","args","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}