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

Deprecated -t for --template to make it --tty #12813

Merged
merged 2 commits into from
Aug 24, 2015

Conversation

janetkuo
Copy link
Member

Fixes #12248

@janetkuo
Copy link
Member Author

@k8s-bot
Copy link

k8s-bot commented Aug 17, 2015

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@bgrant0607
Copy link
Member

cc @kubernetes/kubectl

@bgrant0607 bgrant0607 assigned deads2k and unassigned bgrant0607 Aug 17, 2015
@janetkuo janetkuo force-pushed the kubectl-deprecate-t branch from 12f92a6 to 59738f2 Compare August 17, 2015 23:44
@k8s-bot
Copy link

k8s-bot commented Aug 18, 2015

GCE e2e build/test passed for commit 59738f2fa451505913c84153d2c0ada22b312373.

@smarterclayton
Copy link
Contributor

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")
Copy link
Contributor

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.

@janetkuo janetkuo force-pushed the kubectl-deprecate-t branch from 59738f2 to 677a437 Compare August 18, 2015 23:45
@janetkuo
Copy link
Member Author

@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 -t, is used, and then prints deprecated warning message. This way, we only output deprecated warning when -t is used (but not --template). (The code is a bit hacky though.)

As for the alternative you mentioned, splitting the flag gives us --template and --t, but not -t.

@k8s-bot
Copy link

k8s-bot commented Aug 19, 2015

GCE e2e build/test failed for commit 677a437daa96aef5173e3685e3c3ade408923a57.

@janetkuo
Copy link
Member Author

@k8s-bot test this please

@k8s-bot
Copy link

k8s-bot commented Aug 19, 2015

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 {
Copy link
Contributor

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?

Copy link
Contributor

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 -

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @deads2k @eparis, I'll create a separate PR in github.com/spf13/pflag to support deprecating flag shorthands.

@eparis
Copy link
Contributor

eparis commented Aug 19, 2015

@deads2k I also thought about the split idea but we'd need an options struct like we talked about yesterday....

@ghodss
Copy link
Contributor

ghodss commented Aug 19, 2015

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.

@janetkuo
Copy link
Member Author

@ghodss We're only deprecating -t but not --template.

@ghodss
Copy link
Contributor

ghodss commented Aug 19, 2015

@janetkuo ah cool. I personally would recommend the help text be changed slightly to something like: -t is DEPRECATED and will be removed in a future version - please use --template. since to me the text reads more like the feature is deprecated.

@janetkuo janetkuo force-pushed the kubectl-deprecate-t branch from 677a437 to 4fc78b4 Compare August 19, 2015 23:00
@@ -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 {
Copy link
Member Author

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.

Copy link
Contributor

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.

@k8s-bot
Copy link

k8s-bot commented Aug 19, 2015

GCE e2e build/test passed for commit 4fc78b499339532752d32d84c3bb33a94129dde4.

@k8s-bot
Copy link

k8s-bot commented Aug 21, 2015

GCE e2e build/test passed for commit adc87307caaa44af654c009202c10fdce11e15a1.

@deads2k
Copy link
Contributor

deads2k commented Aug 21, 2015

Looks like you just need to update the generated docs and squash the non-upstream changes.

lgtm

@k8s-bot
Copy link

k8s-bot commented Aug 21, 2015

GCE e2e build/test passed for commit 3e0903554b79713914fc42e8d16c5154ac8a8883.

@janetkuo janetkuo force-pushed the kubectl-deprecate-t branch from 3e09035 to 9e92cd5 Compare August 21, 2015 17:09
@k8s-bot
Copy link

k8s-bot commented Aug 21, 2015

GCE e2e build/test passed for commit 9e92cd55f83f864dd4db5980b1e7363928f85f1c.

@janetkuo janetkuo force-pushed the kubectl-deprecate-t branch from 9e92cd5 to 0436ecc Compare August 21, 2015 18:42
@k8s-bot
Copy link

k8s-bot commented Aug 21, 2015

GCE e2e build/test passed for commit 0436eccfa4f953dffb3acbc392cc3a66b402176e.

@deads2k
Copy link
Contributor

deads2k commented Aug 21, 2015

lgtm. @jlowdermilk can you tag?

@janetkuo janetkuo added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 21, 2015
@janetkuo janetkuo force-pushed the kubectl-deprecate-t branch from 0436ecc to 0bcb314 Compare August 24, 2015 09:16
@janetkuo
Copy link
Member Author

@k8s-bot test this please

@k8s-bot
Copy link

k8s-bot commented Aug 24, 2015

GCE e2e build/test passed for commit 0bcb314.

@eparis
Copy link
Contributor

eparis commented Aug 24, 2015

Just to be clear. The LGTM label stands even after the rebase. Ready to merge.

nikhiljindal added a commit that referenced this pull request Aug 24, 2015
Deprecated -t for --template to make it --tty
@nikhiljindal nikhiljindal merged commit 4ffb59f into kubernetes:master Aug 24, 2015
@janetkuo janetkuo added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Sep 14, 2015
k8s-github-robot pushed a commit that referenced this pull request Apr 28, 2016
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubectl lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants