{"record":{"id":"c3e60bf5a173f20a","repo":"kubernetes/kops","slug":"name-is-required-c3e60b","errorCode":null,"errorMessage":"--name is required","messagePattern":"--name is required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/toolbox_instance-selector.go","lineNumber":126,"sourceCode":"\ttoolboxInstanceSelectorShort = i18n.T(`Generate instance-group specs by providing resource specs such as vcpus and memory.`)\n)\n\n// NewCmdToolboxInstanceSelector defines the cobra command for the instance-selector tool\nfunc NewCmdToolboxInstanceSelector(f commandutils.Factory, out io.Writer) *cobra.Command {\n\toptions := &InstanceSelectorOptions{}\n\n\tcommandline := cli.New(\n\t\t\"instance-selector INSTANCE_GROUP\",\n\t\ttoolboxInstanceSelectorShort,\n\t\ttoolboxInstanceSelectorLong,\n\t\ttoolboxInstanceSelectorExample,\n\t\tnil,\n\t)\n\tcommandline.Command.Args = func(cmd *cobra.Command, args []string) error {\n\t\toptions.ClusterName = rootCommand.ClusterName(true)\n\n\t\tif options.ClusterName == \"\" {\n\t\t\treturn fmt.Errorf(\"--name is required\")\n\t\t}\n\n\t\tif len(args) == 0 {\n\t\t\treturn fmt.Errorf(\"must specify name of instance group to create\")\n\t\t}\n\n\t\toptions.InstanceGroupName = args[0]\n\n\t\tif len(args) != 1 {\n\t\t\treturn fmt.Errorf(\"can only create one instance group at a time\")\n\t\t}\n\n\t\tif err := processAndValidateFlags(&commandline); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsetInstanceSelectorOpts(options, &commandline)\n\n\t\treturn nil","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/toolbox_instance-selector.go#L108-L144","documentation":"`kops toolbox instance-selector` needs to know which cluster to compute instance types for. The command resolves the cluster name from rootCommand.ClusterName(true) (the --name flag or context). If it resolves to empty, Args validation returns this error before any cluster access.","triggerScenarios":"Running `kops toolbox instance-selector <ig-name>` without --name and without a kops context/default cluster configured.","commonSituations":"Scripts running outside a directory/context that supplies a cluster name; forgetting --name; KOPS_CLUSTER_NAME unset; using kubectl-style context assumptions that kops doesn't share.","solutions":["Pass the cluster explicitly: kops toolbox instance-selector --name <cluster> nodes","Or set KOPS_CLUSTER_NAME in the environment","Verify with `kops get clusters` that the intended cluster exists and use its full name"],"exampleFix":"// before\nkops toolbox instance-selector nodes\n// after\nkops toolbox instance-selector --name mycluster.k8s.local nodes","handlingStrategy":"validation","validationCode":"if [ -z \"${KOPS_CLUSTER_NAME:-}\" ] && [[ \"$*\" != *--name* ]]; then\n  echo \"--name is required\" >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export KOPS_CLUSTER_NAME in CI","Always pass --name explicitly","Verify with kops get clusters"],"tags":["cli","flag-validation","instance-selector","usage"],"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"}