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

Warns the user for deprecated flags that use _ separators #8026

Merged
merged 2 commits into from
May 27, 2015
Merged

Warns the user for deprecated flags that use _ separators #8026

merged 2 commits into from
May 27, 2015

Conversation

andronat
Copy link
Contributor

Fix for #7478

Also gets rid of "intermediate" representation of flags with . to enforce consistent flag name format throughout the project.

i.e. Formats like flag_f, flag-f and flag.f were all valid in the source code, now we throw a warning if a developer uses the format of flag_f and flag.f is invalid.

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project, in which case you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@andronat
Copy link
Contributor Author

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

@j3ffml
Copy link
Contributor

j3ffml commented May 11, 2015

Thanks for the PR!

LGTM, but I know @smarterclayton has expressed distaste with glog, so I'll let him comment.

@smarterclayton
Copy link
Contributor

It's fine for now - we need to go through and figure out what our log story is for all CLI commands anyway so this doesn't make it any worse.

@andronat
Copy link
Contributor Author

Don't merge yet, sorry but I just found that it is not working with all the flags.

And I also have a situation that I am not sure on how to handle it. There are flags that are coming from other packages that are written with _. e.g. log_dir and log_backtrace_at from the glog package. How am I suppose to handle them? Sending a depreciation warning I think is useless on the situation.

@j3ffml
Copy link
Contributor

j3ffml commented May 11, 2015

I agree a deprecation warning on flags merged from other packages doesn't make sense. How we handle depends on whether we plan to continue using glog in kubectl or not. If yes, then we can't avoid having a mix of _ and - flags. @ghodss, thoughts?

@andronat
Copy link
Contributor Author

Maybe we can "shadow" them? spf13/pflag#23

@j3ffml
Copy link
Contributor

j3ffml commented May 11, 2015

I think a better path is to do the translation ourselves when we import the flags into the kubectl command flagset here; see also AddFlagSetToPFlagSet . Doing the translation inside pflag seems wrong to me.

@ghodss
Copy link
Contributor

ghodss commented May 11, 2015

@jlowdermilk's solution sounds great to me. The alternative is keeping a whitelist inside WordSepNormalizeFunc, which sounds worse.

@andronat
Copy link
Contributor Author

Ok, so I will translate all the persistent flags and then I will enable the _ warning messages

@andronat andronat closed this May 19, 2015
@andronat andronat reopened this May 19, 2015
@andronat
Copy link
Contributor Author

spf13/pflag#23 and spf13/cobra#110 are merged please review.

/cc @ghodss

@j3ffml
Copy link
Contributor

j3ffml commented May 20, 2015

Looks almost ready. Can you rebase to 2 commits (1 to bump cobra/pflag, 1 with your changes)? Also, you'll need to run hack/run-gendocs.sh as the auto-generated kubectl docs have changed now that inherited flags are - separated. You will actually get a presubmit check telling to run gendocs, if you install the hooks.

@andronat
Copy link
Contributor Author

Done, sorry for the docs. I added the hooks now

@j3ffml
Copy link
Contributor

j3ffml commented May 21, 2015

The cobra bump picked up spf13/cobra#109, which is causing the default GenMarkdownTree to prepend the filename to each generated md file, which we do not want.

If you don't mind waiting a bit for spf13/cobra#112 to be merged, and re-updating cobra that would be simplest. Otherwise, quick fix is to replace this line with

GenMarkdownTreeCustom(kubectl, outDir, func(s string) string { return "" }, func(s string) string { return s })

and leave a todo to update once spf13/cobra#112 is in.

@eparis
Copy link
Contributor

eparis commented May 21, 2015

@jlowdermilk merged fix in cobra.

@j3ffml
Copy link
Contributor

j3ffml commented May 21, 2015

Thanks @eparis! @andronat, if you update cobra and rerun hack/run-gendocs.sh tests should be passing.

func AddFlagSetToPFlagSet(fsIn *flag.FlagSet, fsOut *pflag.FlagSet) {
fsIn.VisitAll(func(f *flag.Flag) {
addFlagToPFlagSet(f, fsOut)
})
}

// Add all of the top level 'flag' package flags to the top level 'pflag' flags.
// AddAllFlagsToPFlags adds all of the top level 'flag' package flags to the top level 'pflag' flags.
func AddAllFlagsToPFlags() {
AddFlagSetToPFlagSet(flag.CommandLine, pflag.CommandLine)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this even needed, after spf13/cobra#75

I know it's not the point of your PR, but how much of pflag_import.go can we rip out?

Copy link
Contributor

Choose a reason for hiding this comment

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

Something still isn't quite right around this stuff. ignore me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I was also trying to get rid of those funcs there. The problem is that cobra is merging flag command line flags but is not working for the pflag global flags. Also an other problem is the order and "when" each of those merges are taking place. This is actually an issue of cobra and I might work on that at some point: spf13/cobra#44

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, we should work on this in cobra.

@j3ffml
Copy link
Contributor

j3ffml commented May 21, 2015

lgtm

@j3ffml j3ffml added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 21, 2015
@andronat
Copy link
Contributor Author

Rebased to resolve conflicts

@eparis
Copy link
Contributor

eparis commented May 21, 2015

LGTM

@dchen1107
Copy link
Member

You have to rebase, sorry for this.

@andronat
Copy link
Contributor Author

Done

@andronat andronat closed this May 24, 2015
@andronat andronat reopened this May 24, 2015
@k8s-bot
Copy link

k8s-bot commented May 24, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain @ixdy.

@andronat andronat changed the title Fixes GoogleCloudPlatform/kubernetes#7478 Warns the user for deprecated flags that use _ separators May 24, 2015
@andronat
Copy link
Contributor Author

any news on that? It is ready to merge, I rebased it to latest master

@eparis
Copy link
Contributor

eparis commented May 27, 2015

I haven't tested it, but does using --flag_name= on the command line give a warning, or does it just accept things silently?

@andronat
Copy link
Contributor Author

It is like that:

kubectl --no_headers=true get cs
W0527 14:31:51.039177     373 flags.go:36] no_headers is DEPRECATED and will be removed in a future version. Use no-headers instead.
controller-manager   Healthy   ok        nil
scheduler            Healthy   ok        nil

The same applies to all flags. It works for all cases but prints a warning

@thockin
Copy link
Member

thockin commented May 27, 2015

Are you guys ready to go with this - it is a substantial change, so I want to get it off the books one way or another.

@eparis
Copy link
Contributor

eparis commented May 27, 2015

LGTM

@eparis
Copy link
Contributor

eparis commented May 27, 2015

(but it's not assigned to me, so I'm not adding the label)

@j3ffml
Copy link
Contributor

j3ffml commented May 27, 2015

Still LGTM

@thockin
Copy link
Member

thockin commented May 27, 2015

fire in the hole

thockin added a commit that referenced this pull request May 27, 2015
Warns the user for deprecated flags that use _ separators
@thockin thockin merged commit b9bfce4 into kubernetes:master May 27, 2015
@andronat andronat deleted the fix_7478 branch May 27, 2015 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants