Repository navigation
fix(kubernetes): reject extra names in kubernetes create - #609
Merged
fulviodenza merged 3 commits intoNov 2, 2026
Merged
Conversation
kubernetes create had no Args check, so 'civo kubernetes create a b c' created a single cluster named a and ignored the rest. Limit it to at most one name; the name stays optional. Part of civo#398
fulviodenza
approved these changes
Nov 2, 2026
fulviodenza
left a comment
Contributor
There was a problem hiding this comment.
Thanks for this. Reviewed: cobra.MaximumNArgs(1) still allows zero args, so the random cluster name path is unchanged, and the pattern matches the existing objectstore credential secret command. The test exercises the real command's arg validation. I updated the branch from master so CI ran against current dependencies (the earlier govulncheck failure was x/net on the stale base), and Lint, Security and Test are now green.
Small follow-up for later, not blocking: kubernetesCreateCmdExample still shows civo kubernetes create CLUSTER_NAME [flags], which reads as required now that Use says [CLUSTER_NAME].
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #398
Problem
civo kubernetes createhas no limit on positional args, socivo kubernetes create test2 test3 test4creates a single cluster calledtest2and silently drops the other names.Fix
Args: cobra.MaximumNArgs(1). The name is still optional (a random one is generated when it's missing), but passing more than one now fails before any API call.Usetocreate [CLUSTER_NAME]so the usage line shows the optional name, the same wayinstance createdoes.The issue mentioned either creating them all or failing. I went with failing, since size, nodes, network and firewall apply per cluster and creating several clusters from one call would be easy to do by accident. Same approach as #602.
This does change behaviour for anything that passed stray args before, for example an unquoted name with a space (
civo k8s create my clusterused to createmy). It errors now instead.Tests
TestKubernetesCreateArgsincmd/kubernetes/kubernetes_create_test.go(no name, one name, extra names)test2. With this change there are no API calls, and flags mixed between names (create a --nodes 2 b) are rejected too. One name and no name send the same requests as before.go test ./...and golangci-lint pass locallySome other create commands have the same gap.
instance createhas noArgscheck, and a few that useMinimumNArgs(1)(e.g.volume create) also ignore extra names. I can look at those in a separate PR if you want.