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

Add command.Addwriter() support #1198

Merged
merged 1 commit into from
Mar 21, 2020
Merged

Add command.Addwriter() support #1198

merged 1 commit into from
Mar 21, 2020

Conversation

saschagrunert
Copy link
Member

@saschagrunert saschagrunert commented Mar 19, 2020

What type of PR is this?

/kind feature

What this PR does / why we need it:

This allows commands to specify additional writers, for example when
having the need for logging to files.

Which issue(s) this PR fixes:

None

Special notes for your reviewer:

Does this PR introduce a user-facing change?

- Added `Addwriter()`, `AddErrorWriter()` and  `AddOutputWriter()` to command package which allows commands to specify additional writers, for example when having the need for logging to files.

@k8s-ci-robot
Copy link
Contributor

@saschagrunert: Adding label: do-not-merge/blocked-paths because PR changes a protected file.

Reasons for blocking this PR:

[Changes to certain release tools can affect our ability to test, build, and release Kubernetes. This PR must be explicitly approved by SIG Release repo admins.]

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 release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/blocked-paths Indicates that a PR should not merge because it touches files in blocked paths. 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. needs-priority size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 19, 2020
Copy link
Contributor

@hasheddan hasheddan left a comment

Choose a reason for hiding this comment

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

Thanks @saschagrunert! One comment but definitely not blocking :)

/lgtm
/hold for other reviewers

@@ -190,8 +199,12 @@ func (c *Command) run(printOutput bool) (res *Status, err error) {

var stdOutWriter, stdErrWriter io.Writer
if printOutput {
stdOutWriter = io.MultiWriter(os.Stdout, stdOutBuffer)
stdErrWriter = io.MultiWriter(os.Stderr, stdErrBuffer)
stdOutWriter = io.MultiWriter(append(
Copy link
Contributor

Choose a reason for hiding this comment

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

Not blocking, but just wondering if you think we would ever want to support supplying separate writers for Stdout and Stderr? I could be mistaken here but it looks like if you want one to be written to a passed in writer, than you must allow for both.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes this gives us more flexibility. I changed the API to allow writers for stdout and stderr separately. Or we just use AddWriter for both.

Updated the test cases as well 👍

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Mar 19, 2020
This allows commands to specify additional writers, for example when
having the need for logging to files.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 19, 2020
Copy link
Contributor

@hasheddan hasheddan left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 19, 2020
@justaugustus justaugustus removed do-not-merge/blocked-paths Indicates that a PR should not merge because it touches files in blocked paths. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Mar 21, 2020
@justaugustus
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hasheddan, justaugustus, saschagrunert

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:
  • pkg/OWNERS [hasheddan,justaugustus,saschagrunert]

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 merged commit f4a82e7 into kubernetes:master Mar 21, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Mar 21, 2020
@saschagrunert saschagrunert deleted the add-writer branch March 21, 2020 07:37
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. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. 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 release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. 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.

4 participants