-
Notifications
You must be signed in to change notification settings - Fork 40k
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
Deprecated -t for --template to make it --tty #12813
Conversation
GCE e2e build/test passed for commit 12f92a6c646bc5db1cd5d0aae32cd0885320022f. |
@@ -63,8 +63,8 @@ resourcequotas (quota) or secrets. | |||
|
|||
.PP | |||
\fB\-t\fP, \fB\-\-template\fP="" | |||
Template string or path to template file to use when \-o=template or \-o=templatefile. The template format is golang templates [ | |||
\[la]http://golang.org/pkg/text/template/#pkg-overview\[ra]] | |||
Template string or path to template file to use when \-o=template or \-o=templatefile. \-t is DEPRECATED to support \-\-tty. The template format is golang templates [ |
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.
I wouldn't mention that we plan to use -t for --tty -- that may just confuse users.
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.
Fixed.
cc @kubernetes/kubectl |
12f92a6
to
59738f2
Compare
GCE e2e build/test passed for commit 59738f2fa451505913c84153d2c0ada22b312373. |
No objections from me |
if len(outputFormat) == 0 && len(templateFile) != 0 { | ||
outputFormat = "template" | ||
if len(templateFile) != 0 { | ||
glog.Warningf("%s is DEPRECATED and will be removed in a future version.", "-t") |
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.
Is there way for you to tell whether they've typed -t
versus --template
. If I'm reading the issue right, the intent is to deprecate -t
, but not --template
. I'm concerned about dumping this message too aggressively.
One alternative is to actually split --template
into two flags and use MarkDeprecated
for the -t
flag. If you do that, pflags will take care of the deprecation notification.
59738f2
to
677a437
Compare
@deads2k Thanks for your suggestions. I didn't find a way that tells whether the users typed the shorthand or the flag name. Therefore, I updated the code to read the args and see if a deprecated shorthand, such as As for the alternative you mentioned, splitting the flag gives us |
GCE e2e build/test failed for commit 677a437daa96aef5173e3685e3c3ade408923a57. |
@k8s-bot test this please |
GCE e2e build/test passed for commit 677a437daa96aef5173e3685e3c3ade408923a57. |
@@ -303,6 +307,34 @@ func (f *Factory) BindFlags(flags *pflag.FlagSet) { | |||
flags.SetNormalizeFunc(util.WordSepNormalizeFunc) | |||
} | |||
|
|||
func (f *Factory) AddDeprecatedFlagShorthands(shorthand string) error { |
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.
How about moving this code into pflag
? It looks like this would be a good complementary method to https://github.com/kubernetes/kubernetes/blob/master/Godeps/_workspace/src/github.com/spf13/pflag/flag.go#L283 and detection you wrote below would function well inside https://github.com/kubernetes/kubernetes/blob/master/Godeps/_workspace/src/github.com/spf13/pflag/flag.go#L299 against the pre-normalized name. The details (flag.Deprecated
) could be used to explain that only -t
is gone.
We have a couple committers on pflags. @eparis Any objections to that approach instead of adding this here?
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.
I think that's a good idea to move this to pflag. Doing it "right" will take a bit more work. Obviously right now we only track if the short and long are both deprecated. So we'll need a way to say that only the short is deprecated. We really should start hiding the short from help text and documentation generation. I don't think Set()
is actually the place you'll be able to find the short flag. I think it only handles long flags. You'll need to look at origArg[0]
in setFlag()
.
Also CheckDeprecatedFlagShorthands()
isn't right... It is legal (although silly) to do something like -wt '{ name }'
(or something like there) where you have multiple shorthands after one -
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.
@deads2k I also thought about the split idea but we'd need an options struct like we talked about yesterday.... |
Are we removing the golang template functionality altogether, or moving it to --golang-template or somehwere else? If we're moving it, it probably doesn't make sense to tell people it's being deprecated without giving them the future way of doing it. |
@ghodss We're only deprecating |
@janetkuo ah cool. I personally would recommend the help text be changed slightly to something like: |
677a437
to
4fc78b4
Compare
@@ -289,6 +290,16 @@ func (f *FlagSet) MarkDeprecated(name string, usageMessage string) error { | |||
return nil | |||
} | |||
|
|||
// Mark the shorthand of a flag deprecated in your program | |||
func (f *FlagSet) MarkShorthandDeprecated(name string, usageMessage string) error { |
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.
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.
Code updated manually. It's easier to test the code change here. @deads2k @eparis please take a look and I'll apply this change to pflag package.
The pflags
change looks good. Can you separate this into its own commit? I'd suggest naming it something like "UPSTREAM: pflags 52: Add shorthand deprecator". It makes it easier for people to find patches to bumped godeps.
GCE e2e build/test passed for commit 4fc78b499339532752d32d84c3bb33a94129dde4. |
GCE e2e build/test passed for commit adc87307caaa44af654c009202c10fdce11e15a1. |
Looks like you just need to update the generated docs and squash the non-upstream changes. lgtm |
adc8730
to
3e09035
Compare
GCE e2e build/test passed for commit 3e0903554b79713914fc42e8d16c5154ac8a8883. |
3e09035
to
9e92cd5
Compare
GCE e2e build/test passed for commit 9e92cd55f83f864dd4db5980b1e7363928f85f1c. |
9e92cd5
to
0436ecc
Compare
GCE e2e build/test passed for commit 0436eccfa4f953dffb3acbc392cc3a66b402176e. |
lgtm. @jlowdermilk can you tag? |
0436ecc
to
0bcb314
Compare
@k8s-bot test this please |
GCE e2e build/test passed for commit 0bcb314. |
Just to be clear. The LGTM label stands even after the rebase. Ready to merge. |
Deprecated -t for --template to make it --tty
Automatic merge from submit-queue Add flag -t as shorthand for --tty `-t` was deprecated in #12813 (Aug. 2015, about 6+ months ago). Now remove `--template`'s shorthand `-t` and create a shorthand `-t` for `--tty` in `kubectl run`. @kubernetes/kubectl
Fixes #12248