-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support KIND_CLUSTER_NAME. #1493
Conversation
@@ -51,6 +52,9 @@ func NewCommand(logger log.Logger, streams cmd.IOStreams) *cobra.Command { | |||
Short: "Creates a local Kubernetes cluster", | |||
Long: "Creates a local Kubernetes cluster using Docker container 'nodes'", | |||
RunE: func(cmd *cobra.Command, args []string) error { | |||
if !cmd.Flags().Changed("name") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could dry this out by just passing the cmd.Flags()
(flagset pointer) to OverrideDefaultName
and then internally check flags.Changed("name")
then call flags.Set("name", value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I initially had that, but figured that checking the specific name
flag logic should probably live near the command than in the method that just checks the env.
/shrug
pkg/internal/cli/override.go
Outdated
func OverrideDefaultName(logger log.Logger, defaultName *string) { | ||
if name := os.Getenv("KIND_CLUSTER_NAME"); name != "" { | ||
*defaultName = name | ||
logger.V(1).Infof("using %q due to KIND_CLUSTER_NAME", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using what? this message seems a little obtuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarified.
pkg/internal/cli/override.go
Outdated
if !fs.Changed("name") { | ||
if name := os.Getenv("KIND_CLUSTER_NAME"); name != "" { | ||
fs.Set("name", name) | ||
logger.V(1).Infof("using default cluster name as %q due to KIND_CLUSTER_NAME", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last nit: it's not the default right?
using cluster name %q from KIND_CLUSTER_NAME
Or just drop this all together. I don't think most apps log this sort of thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amwat, BenTheElder The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fixes #1094
/cc @BenTheElder