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

Inline the ResourceDeclaration struct in TaskResource #1366

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

nlewo
Copy link
Contributor

@nlewo nlewo commented Sep 30, 2019

Before the commit 92d5bcc, attributes
of ResourceDeclaration belong to TaskResource.

This avoids generated JSON structures to contain the useless
ResourceDeclaration attribute.

Changes

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.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

Describe any user facing changes here, or delete this block.

Examples of user facing changes:
- API changes
- Bug fixes
- Any changes in behavior

Before the commit 92d5bcc, attributes
of `ResourceDeclaration` belong to `TaskResource`.

This avoids generated JSON structures to contain the useless
`ResourceDeclaration` attribute.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@tekton-robot tekton-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 30, 2019
@tekton-robot
Copy link
Collaborator

Hi @nlewo. Thanks for your PR.

I'm waiting for a tektoncd 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.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@nlewo
Copy link
Contributor Author

nlewo commented Sep 30, 2019

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit and removed cla: no labels Sep 30, 2019
@vdemeester
Copy link
Member

/ok-to-test
/cc @dibyom @bobcatfish

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 1, 2019
Copy link
Member

@dibyom dibyom left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 1, 2019
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold
/cc @bobcatfish

I don't think it has any backward incompatible effect but… I want a 2nd set of eyes on this 👼

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 1, 2019
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nlewo, vdemeester

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 Oct 1, 2019
@bobcatfish
Copy link
Collaborator

@nlewo sounds like this is a good change but I'm not super familiar with what "inline" does - im also a bit confused b/c I thought if it changed the way the json fields are treated, that some of our generated code would change but it looks like it doesn't.

This avoids generated JSON structures to contain the useless ResourceDeclaration attribute.

Could you explain a bit more about what the generated structures look like before and after this change? Also interested in more detail about how you ran into this (i.e. if it causes problems for users)

@nlewo
Copy link
Contributor Author

nlewo commented Oct 1, 2019

@bobcatfish I ran into this issue because I tried to generate cue files from your go sources: the objective is to extract a schema as the cue kubernetes tutorial does.
Without the inline tag, cue generates this struct (a piece of the struct):

spec:
  inputs:
    resources:
    - ResourceDeclaration:
        name: "source"
        type: "git"

while with the inline tag it generates:


spec:
  inputs:
    resources:
    -  name: "source"
        type: "git"

This is also explained in the cue get go --help message:

	- embedded structs marked with a json inline tag unify with struct
	  definition. For instance, the Go struct

	    struct MyStruct {
			Common  json:",inline"
			Field string
		 }

	  translates to the CUE struct

		 MyStruct: Common & {
			 Field: string
		 }

The Go json marshaller, by default, inlines embedded structs (i didn't try before you asked for).I tried to find some documentation about this tag, but I wasn't able to:/ That's really strange!
Note that you are already using such kind of tag here for instance.

@nlewo
Copy link
Contributor Author

nlewo commented Oct 3, 2019

So, this inline flag is recognized by the go-yaml package (go-yaml/yaml@8691640) but I have not been able to find it in the go-json package!

@dibyom
Copy link
Member

dibyom commented Oct 3, 2019

Thanks for the thorough explanation @nlewo !
/hold cancel

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 3, 2019
@tekton-robot tekton-robot merged commit 0351c6d into tektoncd:master Oct 3, 2019
This pull request was closed.
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants