{"record":{"id":"1ab70dc476edb5d5","repo":"kubernetes/kops","slug":"name-is-required-1ab70d","errorCode":null,"errorMessage":"--name is required","messagePattern":"--name is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/delete_secret.go","lineNumber":75,"sourceCode":"\t\t\t\toptions.SecretType = args[0]\n\t\t\t\treturn nil\n\t\t\t}\n\n\t\t\tif len(args) > 0 && args[0] == \"secret\" {\n\t\t\t\targs = args[1:]\n\t\t\t}\n\n\t\t\tif len(args) == 0 {\n\t\t\t\treturn fmt.Errorf(\"secret name is required\")\n\t\t\t}\n\t\t\tif len(args) > 1 {\n\t\t\t\treturn fmt.Errorf(\"too many arguments\")\n\t\t\t}\n\t\t\toptions.SecretNames = args\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\treturn nil\n\t\t},\n\t\tValidArgsFunction: completeSecretNames(f),\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\treturn RunDeleteSecret(cmd.Context(), f, out, options)\n\t\t},\n\t}\n\n\treturn cmd\n}\n\nfunc RunDeleteSecret(ctx context.Context, f *util.Factory, out io.Writer, options *DeleteSecretOptions) error {\n\tif options.SecretType == \"sshpublickey\" {\n\t\treturn RunDeleteSSHPublicKey(ctx, f, out, &DeleteSSHPublicKeyOptions{\n\t\t\tClusterName: options.ClusterName,\n\t\t})","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/delete_secret.go#L57-L93","documentation":"After argument validation, the command resolves the cluster name from rootCommand.ClusterName(true). If it is empty, the command requires the --name flag to identify which cluster's secret to delete. Secrets are cluster-scoped, so the cluster name is mandatory.","triggerScenarios":"`kops delete secret <name>` with no --name flag, no KOPS_CLUSTER_NAME env var, and no cluster set in $KOPS_STATE_STORE/<cluster> context (e.g. not run from within a cluster directory).","commonSituations":"Running the command outside a kOps context without --name; missing KOPS_CLUSTER_NAME in CI scripts.","solutions":["Add --name <cluster> to the command","Set the KOPS_CLUSTER_NAME environment variable in scripts/CI","cd into the cluster's state or use kops export kubecfg so the cluster name can be inferred"],"exampleFix":"// before\nkops delete secret dockerconfig\n// after\nkops delete secret dockerconfig --name mycluster.k8s.local","handlingStrategy":"validation","validationCode":"CLUSTER=${KOPS_CLUSTER_NAME:?set --name or KOPS_CLUSTER_NAME}\nkops delete secret \"$SECRET_NAME\" --name \"$CLUSTER\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass --name <cluster> explicitly in scripts","Export KOPS_CLUSTER_NAME in CI environments","Confirm with `kops get clusters` that the name resolves"],"tags":["cli","secrets","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"}