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

[WIP] Move exposed Printing funcs to cmd/util/factory_builder.go #50113

Conversation

juanvallejo
Copy link
Contributor

@juanvallejo juanvallejo commented Aug 3, 2017

Proposal: #50388

Related doc: https://docs.google.com/a/redhat.com/document/d/15uieHE_QnfF9eEj-AAbAvo3xBqfyu5x1v5Cghzy4ZDI/edit?usp=sharing

Related cards:

Release note:

NONE

This PR attempts to only expose printing methods through the cmdutil factory.
It also attempts to remove complexity from using these printing methods by consolidating printers.OutputOptions and printers.PrintOptions into a single struct.

It also attempts remove cobra.Command dependency from printer methods (except PrinterForCommand), and attempts to facilitate code reusability by consumers of factory printing methods.

cc @fabianofranz @kubernetes/sig-cli @deads2k

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 3, 2017
@k8s-ci-robot
Copy link
Contributor

Hi @juanvallejo. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 3, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: juanvallejo
We suggest the following additional approver: dchen1107

Assign the PR to them by writing /assign @dchen1107 in a comment when ready.

No associated issue. Update pull-request body to add a reference to an issue, or get approval with /approve no-issue

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot k8s-github-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels Aug 3, 2017
@@ -149,6 +149,7 @@ type ClientAccessFactory interface {
// SuggestedPodTemplateResources returns a list of resource types that declare a pod template
SuggestedPodTemplateResources() []schema.GroupResource

// TODO: how is this different than PrinterForMapping?
// Returns a Printer for formatting objects of the given type or an error.
Printer(mapping *meta.RESTMapping, options printers.PrintOptions) (printers.ResourcePrinter, error)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fabianofranz maybe we could get rid of this method and use PrinterForMapping instead?

@juanvallejo juanvallejo force-pushed the jvallejo/limit-printer-exposure branch from 51f943c to 8cbe4df Compare August 4, 2017 15:35
@k8s-github-robot k8s-github-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 4, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/limit-printer-exposure branch from d567602 to c06055d Compare August 4, 2017 20:42
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 5, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/limit-printer-exposure branch from c06055d to 86e2410 Compare August 7, 2017 14:31
@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 7, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/limit-printer-exposure branch 2 times, most recently from 4e0da42 to f23a703 Compare August 8, 2017 20:05
@juanvallejo juanvallejo force-pushed the jvallejo/limit-printer-exposure branch from f23a703 to 1e76b7d Compare August 8, 2017 22:20
return p, nil
}

// TODO(juanvallejo): change printersinternal.AddHandlers to printersinternal.GetDefaultHandlers and return
// a *printers.HandlerEntry list. Handle any errors returned from generating this list.
Copy link
Contributor Author

@juanvallejo juanvallejo Aug 8, 2017

Choose a reason for hiding this comment

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

@fabianofranz working on a patch for this. Will expose pkg/printers.handlerEntry, and update pkg/printers/internalversion.AddHandlers to return a slice of *pkg/printers.HandlerEntry.

This will allow a new factory method that returns the list of client-side registered printer handlers, per the doc on printer refactor.

Your thoughts and feedback are welcome on this

@smarterclayton
Copy link
Contributor

smarterclayton commented Aug 9, 2017 via email

@smarterclayton
Copy link
Contributor

smarterclayton commented Aug 9, 2017 via email

@fabianofranz
Copy link
Contributor

@kubernetes/sig-cli-misc @deads2k @liggitt @sttts

@k8s-ci-robot k8s-ci-robot added the sig/cli Categorizes an issue or PR as relevant to SIG CLI. label Aug 9, 2017
@juanvallejo
Copy link
Contributor Author

Link to proposal: #50388

@shiywang
Copy link
Contributor

/ok-to-test

}

format, formatArgument, allowMissingTemplateKeys := outputOpts.FmtType, outputOpts.FmtArg, outputOpts.AllowMissingKeys
func GetStandardPrinter(noHeaders bool, mapper meta.RESTMapper, typer runtime.ObjectTyper, encoder runtime.Encoder, decoders []runtime.Decoder, options PrintOptions) (ResourcePrinter, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

as we removed PrinterForCommand, could we also remove noHeaders bool ?

// printerWithOptions returns the printer for the given options.
// Requires that printer flags have been added to cmd (see AddPrinterFlags).
func printerWithOptions(mapper meta.RESTMapper, typer runtime.ObjectTyper, encoder runtime.Encoder, decoders []runtime.Decoder, options printers.PrintOptions) (printers.ResourcePrinter, error) {
printer, err := printers.GetStandardPrinter(options.NoHeaders, mapper, typer, encoder, decoders, options)
Copy link
Contributor

@shiywang shiywang Aug 11, 2017

Choose a reason for hiding this comment

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

options.NoHeaders is included in options right ? could we only use options ?

@k8s-github-robot k8s-github-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 11, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/limit-printer-exposure branch from f5f1607 to cc841e9 Compare August 11, 2017 22:27
@juanvallejo juanvallejo force-pushed the jvallejo/limit-printer-exposure branch from d106430 to 7e1b487 Compare August 14, 2017 15:13
@k8s-github-robot
Copy link

@juanvallejo PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 15, 2017
@juanvallejo juanvallejo force-pushed the jvallejo/limit-printer-exposure branch from 7266b47 to be00aa2 Compare August 17, 2017 19:11
@k8s-ci-robot
Copy link
Contributor

@juanvallejo: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-bazel be00aa2 link /test pull-kubernetes-bazel
pull-kubernetes-unit be00aa2 link /test pull-kubernetes-unit
pull-kubernetes-node-e2e be00aa2 link /test pull-kubernetes-node-e2e
pull-kubernetes-federation-e2e-gce be00aa2 link /test pull-kubernetes-federation-e2e-gce
pull-kubernetes-kubemark-e2e-gce be00aa2 link /test pull-kubernetes-kubemark-e2e-gce
pull-kubernetes-e2e-kops-aws be00aa2 link /test pull-kubernetes-e2e-kops-aws
pull-kubernetes-verify be00aa2 link /test pull-kubernetes-verify
pull-kubernetes-e2e-gce-etcd3 be00aa2 link /test pull-kubernetes-e2e-gce-etcd3

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@juanvallejo
Copy link
Contributor Author

/assign seans3
/assign mengqiy

@k8s-ci-robot
Copy link
Contributor

@juanvallejo: GitHub didn't allow me to assign the following users: seans3.

Note that only kubernetes members can be assigned.

In response to this:

/assign seans3
/assign mengqiy

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@juanvallejo
Copy link
Contributor Author

juanvallejo commented Oct 30, 2017

Splitting this PR into multiple easier-to-review PRs.
Tracking commits that have been split so far in this comment:

x13n pushed a commit to x13n/kubernetes that referenced this pull request Nov 14, 2017
…intResourceInfoRorCommand-cmdutil-factory

Automatic merge from submit-queue (batch tested with PRs 54602, 54877, 55243, 55509, 55128). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

move cmd/util/printing.go#PrintResourceInfoForCommand -> factory…

**Release note**:
```release-note
NONE
```

This patch is one in a series of patches that aims to move all
printing functions to the `cmdutil.Factory` in order to make
the factory the one-stop shop for accessing printers in the client.

This PR is related to kubernetes#50113 and aims to break the set of changes
introduced in this commit in order to make them easier to review.

@fabianofranz @mengqiy @shiywang @seans3
k8s-github-robot pushed a commit that referenced this pull request Nov 18, 2017
…s-cmdutil-factory

Automatic merge from submit-queue (batch tested with PRs 55233, 55927, 55903, 54867, 55940). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

move cmd/util/printing.go#PrintSuccess to factory_builder.go

**Release note**:
```release-note
NONE
```

This patch is one in a series of patches that aims to move all
printing functions to the `cmdutil.Factory` in order to make
the factory the one-stop shop for accessing printers in the client.

This PR is related to #50113 and aims to break that set of changes
by introducing a portion of them in this commit in order to make 
them easier to review.

@fabianofranz @mengqiy @shiywang @seans3
k8s-github-robot pushed a commit that referenced this pull request Nov 21, 2017
…tOpts-printOpts

Automatic merge from submit-queue (batch tested with PRs 54811, 54292, 56103). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

consolidate printer OutputOpts w PrintOpts

This patch removes the use of printers.OutputOptions in favor of only
having a single struct for setting / passing printer options set by user
flags.

This PR is related to #50113 and aims to break the set of changes 
introduced in [this commit](f4d7174) in order to make them easier to review.

**Release note**:
```release-note
NONE
```

cc @fabianofranz @mengqiy @shiywang @seans3
k8s-github-robot pushed a commit that referenced this pull request Dec 17, 2017
…md-through-factory

Automatic merge from submit-queue (batch tested with PRs 56676, 57050, 54881, 56822, 57113). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

ensure PrinterForCommand is consumed through cmdutil.Factory

**Release note**:
```release-note
NONE
```

This patch is one in a series of patches that aims to move all
printing functions to the `cmdutil.Factory` in order to make
the factory the one-stop shop for accessing printers in the client.

This PR is related to #50113 and aims to break the set of changes
introduced in this commit in order to make them easier to review.

@fabianofranz @mengqiy @shiywang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. release-note-none Denotes a PR that doesn't merit a release note. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants