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

Minor style nits affecting YAML output #798

Merged
merged 1 commit into from
Apr 25, 2019

Conversation

imjasonh
Copy link
Member

Changes

Address some minor styling nits affecting YAML output.

  • Add omitempty for string, slice, map or pointer fields that can be omitted.
  • Remove omitempty from non-pointer struct fields, where omitempty doesn't do anything.

From encoding/json:

The "omitempty" option specifies that the field should be omitted from the encoding if the field has an empty value, defined as false, 0, a nil pointer, a nil interface value, and any empty array, slice, map, or string.

In addition to this change, some fields that are structs could be changed to pointers, to allow them to be omitted from YAML output as well, when not specified.

For example, TaskRunSpec's Outputs field is an Outputs struct, which means the field is always present in YAML output, but is outputs: {} when none are specified. If the field was a *Outputs with json:"outputs,omitempty, it could be omitted from YAML if none are specified. Same with TaskRunSpec's Inputs and Trigger fields, and some in PipelineRunSpec, etc.

It's possible that outputs: {} is preferrable to just omitting it, but it's unclear whether that was an explicit decision or not. 🤷‍♂️

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide
for more details.

Release Notes

N/A

@tekton-robot tekton-robot requested a review from dlorenc April 25, 2019 17:56
@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Apr 25, 2019
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 25, 2019
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ImJasonH

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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 25, 2019
@bobcatfish
Copy link
Collaborator

It's possible that outputs: {} is preferrable to just omitting it, but it's unclear whether that was an explicit decision or not. 🤷‍♂️

No I don't think this was intentional! Should be a pointer from what I can tell 😅

@bobcatfish
Copy link
Collaborator

Thanks for the cleanup @imjasonh !! ❤️ 🎉 💃

/lgtm
/meow space

@tekton-robot
Copy link
Collaborator

@bobcatfish: cat image

In response to this:

Thanks for the cleanup @imjasonh !! ❤️ 🎉 💃

/lgtm
/meow space

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.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 25, 2019
@tekton-robot tekton-robot merged commit 860ab89 into tektoncd:master Apr 25, 2019
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. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit lgtm Indicates that a PR is ready to be merged. 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.

4 participants