-
Notifications
You must be signed in to change notification settings - Fork 39k
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
[WIP] Move exposed Printing funcs to cmd/util/factory_builder.go #50113
Conversation
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 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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: juanvallejo Assign the PR to them by writing No associated issue. Update pull-request body to add a reference to an issue, or get approval with 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 |
pkg/kubectl/cmd/util/factory.go
Outdated
@@ -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) |
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.
@fabianofranz maybe we could get rid of this method and use PrinterForMapping
instead?
51f943c
to
8cbe4df
Compare
d567602
to
c06055d
Compare
c06055d
to
86e2410
Compare
4e0da42
to
f23a703
Compare
f23a703
to
1e76b7d
Compare
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. |
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.
@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
What doc on printer refactor?
…On Tue, Aug 8, 2017 at 6:27 PM, Juan Vallejo ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pkg/kubectl/cmd/util/factory_client_access.go
<#50113 (comment)>
:
> 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.
@fabianofranz <https://github.com/fabianofranz> working on a separate PR
for this. Will expose pkg/printers.handlerEntry
<https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/humanreadable.go#L48>,
and update pkg/printers/internalversion.AddHandlers
<https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/internalversion/printers.go#L67>
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
<https://docs.google.com/document/d/15uieHE_QnfF9eEj-AAbAvo3xBqfyu5x1v5Cghzy4ZDI/edit?ts=5978e6a6#heading=h.1l1gx9w54z6p>
.
Your thoughts and feedback are welcome on this
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#50113 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABG_p8N8Y8WjX45gwCBZx789jGFIKf3Lks5sWOC9gaJpZM4OtFl->
.
|
Linked doc is not available to members of sig-cli?
…On Tue, Aug 8, 2017 at 9:12 PM, Clayton Coleman ***@***.***> wrote:
What doc on printer refactor?
On Tue, Aug 8, 2017 at 6:27 PM, Juan Vallejo ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In pkg/kubectl/cmd/util/factory_client_access.go
> <#50113 (comment)>
> :
>
> > 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.
>
> @fabianofranz <https://github.com/fabianofranz> working on a separate PR
> for this. Will expose pkg/printers.handlerEntry
> <https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/humanreadable.go#L48>,
> and update pkg/printers/internalversion.AddHandlers
> <https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/internalversion/printers.go#L67>
> 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
> <https://docs.google.com/document/d/15uieHE_QnfF9eEj-AAbAvo3xBqfyu5x1v5Cghzy4ZDI/edit?ts=5978e6a6#heading=h.1l1gx9w54z6p>
> .
>
> Your thoughts and feedback are welcome on this
>
> —
> You are receiving this because you were assigned.
> Reply to this email directly, view it on GitHub
> <#50113 (review)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABG_p8N8Y8WjX45gwCBZx789jGFIKf3Lks5sWOC9gaJpZM4OtFl->
> .
>
|
Link to proposal: #50388 |
/ok-to-test |
pkg/printers/printers.go
Outdated
} | ||
|
||
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) { |
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.
as we removed PrinterForCommand
, could we also remove noHeaders bool
?
pkg/kubectl/cmd/util/printing.go
Outdated
// 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) |
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.
options.NoHeaders
is included in options
right ? could we only use options
?
f5f1607
to
cc841e9
Compare
d106430
to
7e1b487
Compare
@juanvallejo PR needs rebase |
7266b47
to
be00aa2
Compare
@juanvallejo: The following tests failed, say
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. |
/assign seans3 |
@juanvallejo: GitHub didn't allow me to assign the following users: seans3. Note that only kubernetes members can be assigned. In response to this:
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. |
Splitting this PR into multiple easier-to-review PRs.
|
…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
…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
…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
…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
Proposal: #50388
Related doc: https://docs.google.com/a/redhat.com/document/d/15uieHE_QnfF9eEj-AAbAvo3xBqfyu5x1v5Cghzy4ZDI/edit?usp=sharing
Related cards:
Release note:
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
andprinters.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