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

logs: add AddGoFlags #114731

Merged
merged 2 commits into from Jan 25, 2023
Merged

logs: add AddGoFlags #114731

merged 2 commits into from Jan 25, 2023

Conversation

pohly
Copy link
Contributor

@pohly pohly commented Dec 28, 2022

What type of PR is this?

/kind feature

What this PR does / why we need it:

This makes it possible to use logging command line flags with a flag.FlagSet, without having to copy values from a pflag.FlagSet.

Does this PR introduce a user-facing change?

k8s.io/component-base/logs now also supports adding command line flags to a flag.FlagSet.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 28, 2022
@k8s-ci-robot
Copy link
Contributor

@pohly: This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Dec 28, 2022
@k8s-ci-robot k8s-ci-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Dec 28, 2022
@songxiao-wang87
Copy link
Contributor

/test pull-kubernetes-unit

This is useful for binaries that don't use pflag and cannot migrate to it
because they have to support the traditional single-dash command line
parsing. pflag is a drop-in replacement at the source code level, but the
behavior of flag parsing in the resulting binary is different.
TestFlags got superseded by TestFlagSet/pflag in
8251a63.
@pohly pohly changed the title WIP: logs: add AddGoFlags logs: add AddGoFlags Jan 24, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 24, 2023
@serathius
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 24, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: cb1a56814c50ecedfed2fa80790127229c0deb9e

@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@pohly
Copy link
Contributor Author

pohly commented Jan 24, 2023

/assign @thockin

For approval.

Needed for #114843 (review) and kubernetes-csi/node-driver-registrar#259.

@thockin
Copy link
Member

thockin commented Jan 24, 2023

Is there a canonical example of what a best-practice, no-baggage, max-leverage, no-BS component's main.go should look like? If I were writing a NEW component, what code would I copy-and-extend?

There are so many public functions here now, I can't keep track of who calls what, and what I am supposed to do - what is the north star (is that hemispherist?) ?

@thockin thockin added the sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. label Jan 24, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Jan 24, 2023
@pohly
Copy link
Contributor Author

pohly commented Jan 24, 2023

The canonical example is https://github.com/kubernetes/component-base/blob/master/logs/example/cmd/logger.go. It uses cobra + pflags.

There's no example for Go with just the stdlib (yet) - I could add one.

@thockin
Copy link
Member

thockin commented Jan 24, 2023

I'd love to see an example that shows canonical use with a small set of options, not just logging but all of the "facilities" available to a "kube component".

That example helps some - still seems like some boilerplate that could be trimmed, but I only looked superficially :)

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pohly, serathius, thockin

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

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 24, 2023
@k8s-ci-robot k8s-ci-robot merged commit d29e3bd into kubernetes:master Jan 25, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.27 milestone Jan 25, 2023
@pohly pohly mentioned this pull request Jan 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/architecture Categorizes an issue or PR as relevant to SIG Architecture. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants