Skip to content
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

Merged
merged 1 commit into from
Apr 17, 2020
Merged

Conversation

amwat
Copy link
Contributor

@amwat amwat commented Apr 17, 2020

fixes #1094

/cc @BenTheElder

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 17, 2020
@@ -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") {
Copy link
Member

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)

Copy link
Contributor Author

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

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)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarified.

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)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@BenTheElder
Copy link
Member

/lgtm
/approve
Maybe write elaborate unit tests in a follow up ;-)
Thanks!

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 17, 2020
@k8s-ci-robot k8s-ci-robot merged commit f277913 into kubernetes-sigs:master Apr 17, 2020
@amwat amwat deleted the envname branch April 17, 2020 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. ¯\_(ツ)_/¯ ¯\\\_(ツ)_/¯
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support KIND_CLUSTER_NAME
3 participants