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

bind filenames var instead of looking up #12743

Merged
merged 1 commit into from
Sep 1, 2015

Conversation

deads2k
Copy link
Contributor

@deads2k deads2k commented Aug 14, 2015

The elimination of util.StringList here 7cbb52c#diff-4b43cea33f490ce3393439029e5712ee, removed the variable binding as side effect. This restores that binding.

Binding flags to variables makes it easier for the implementation of commands to avoid coupling to the particular flagsets that originate them. Decoupling that connection makes composing commands as helpers functions much easier.

@deads2k deads2k mentioned this pull request Aug 14, 2015
41 tasks
@k8s-bot
Copy link

k8s-bot commented Aug 14, 2015

GCE e2e build/test passed for commit f7c78bd1d0529b5f1ce7e74fbfd0682af96b8261.

@deads2k deads2k force-pushed the bind-to-var branch 2 times, most recently from 34318fa to 1036902 Compare August 17, 2015 19:17
@k8s-bot
Copy link

k8s-bot commented Aug 17, 2015

GCE e2e build/test passed for commit 34318fa4991ba16dbc3cee65dc7a91582918280b.

@k8s-bot
Copy link

k8s-bot commented Aug 17, 2015

GCE e2e build/test passed for commit 1036902576a900d041cb098a73064af1cbafb7ec.

@k8s-bot
Copy link

k8s-bot commented Aug 18, 2015

GCE e2e build/test passed for commit b99bf30b9858f753e71751273d7cba1dbc75b6c3.

@eparis
Copy link
Contributor

eparis commented Aug 18, 2015

I say NAK. We use this syntax for everything. See all of the other calls to GetFlag*

file number of GetFlag calls
create.go 1
delete.go 8
expose.go 7
get.go 4
describe.go 1
stop.go 6
rollingupdate.go 7
replace.go 6
label.go 2
pathc.go 2

And this is AFTER you removed filename....

@deads2k
Copy link
Contributor Author

deads2k commented Aug 18, 2015

I say NAK. We use this syntax for everything. See all of the other calls to GetFlag*

Looking up via name as opposed to binding a variable to flag is causing various parts of our system to start depending on having flagsets (and particular flagsets at that) deeper into the stack that they should. The data is important, but the particular flag used to set is not.

This is producing instability downstream as the data dependency chain is unclear due to the magic container properties of certain flagsets. You can see the effect of this in flags like template, output, and validate.

Given an intent to have composable commands, we cannot continue to depend upon locating particular flags by name in particular flagsets propagated through the stack.

@deads2k
Copy link
Contributor Author

deads2k commented Aug 18, 2015

@smarterclayton Anything to add? This contributes to rebase pain as we see failures depending on exactly which branches we take through certain codepaths that rely on finding the correct flagset containing flags with particular names.

@deads2k
Copy link
Contributor Author

deads2k commented Aug 18, 2015

See also #7311 for the intent to have composable units that decoupled from flags. Binding to variables to makes this transition easier because it forces the data flow to be explicit.

@eparis
Copy link
Contributor

eparis commented Aug 18, 2015

Making 'filename' a special case is not the answer. I'm sticking with my NAK,

Having an options structure seems much more reasonable and I'd be a fan/fine with that. We already do it with config, attach, exec...

I'd say expand that concept not this one off....

@liggitt
Copy link
Member

liggitt commented Aug 18, 2015

moving the binding to a local var is a step in the direction of an options struct... I agree this isn't where we want to end up, but I think this is a contained change in the right direction

@eparis
Copy link
Contributor

eparis commented Aug 18, 2015

@liggitt it's not though, it's a hack. Create an options struct with a single option, then I'd call it a step in the right direction.

@deads2k
Copy link
Contributor Author

deads2k commented Aug 18, 2015

@liggitt it's not though, it's a hack. Create an options struct with a single option, then I'd call it a step in the right direction.

Are you demanding options structs for everything before accepting this? Would a "get no worse" approach be ok? Such an approach would require the func AddJsonFilenameFlag(cmd *cobra.Command, value *[]string, usage string) API change, which ripples through every command regardless. The callers could choose to pass an ignored value through, but would really consider that better?

@eparis
Copy link
Contributor

eparis commented Aug 18, 2015

My take:

  • I agree that AddJsonfilenameflag() should take the additional arg.
  • You should define a createOptions, deleteOptions, exposeOptions, *Options which contains only the filename slice of strings (which you will hand to AddJsonFilenameFlag)
  • Instead of passing that filename slice of string to runCreate, runDelete, run* you pass the *Options.

Seems like it will be small addition to this patch...

@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 27, 2015
@k8s-github-robot
Copy link

Labelling this PR as size/L

@deads2k
Copy link
Contributor Author

deads2k commented Sep 1, 2015

@eparis refactored to have a stub Options object.

@k8s-bot
Copy link

k8s-bot commented Sep 1, 2015

GCE e2e build/test passed for commit f1b81ff.

@k8s-bot
Copy link

k8s-bot commented Sep 1, 2015

GCE e2e build/test passed for commit d54639b5fcbee4e4ae74c524ae58be913ee24d18.

@eparis eparis added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 1, 2015
@eparis
Copy link
Contributor

eparis commented Sep 1, 2015

thank you @deads2k do you think it is a (minor) improvement?

@deads2k
Copy link
Contributor Author

deads2k commented Sep 1, 2015

thank you @deads2k do you think it is a (minor) improvement?

I do. It makes gathering the low hanging fruit more obvious. I may do the obvious flags for a few commands in followups.

@k8s-github-robot
Copy link

@k8s-bot test this [testing build queue, sorry for the noise]

@k8s-bot
Copy link

k8s-bot commented Sep 1, 2015

GCE e2e build/test passed for commit f1b81ff.

@k8s-github-robot
Copy link

Automatic merge from SubmitQueue

k8s-github-robot pushed a commit that referenced this pull request Sep 1, 2015
Auto commit by PR queue bot
@k8s-github-robot k8s-github-robot merged commit c949e94 into kubernetes:master Sep 1, 2015
@deads2k deads2k deleted the bind-to-var branch September 1, 2015 19:37
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. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants