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

Allow resources to have additional properties #1558

Merged
merged 7 commits into from
Jun 14, 2021

Conversation

theunrepentantgeek
Copy link
Member

@theunrepentantgeek theunrepentantgeek commented Jun 10, 2021

What this PR does / why we need it:

Currently resources only have Spec and Status properties, but we have a need (for storage versions) to have additional properties as well. This PR extends support to allow additional properties on resources, but treating Spec and Status as special cases.

First consumer will be for Storage versions where the original group-version-kind of the API type needs to be preserved.

How does this PR make you feel:
gif

If applicable:

  • this PR contains tests

@codecov-commenter
Copy link

codecov-commenter commented Jun 10, 2021

Codecov Report

Merging #1558 (65a3f4e) into master (a261848) will increase coverage by 0.09%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1558      +/-   ##
==========================================
+ Coverage   63.38%   63.47%   +0.09%     
==========================================
  Files         176      176              
  Lines       11670    11694      +24     
==========================================
+ Hits         7397     7423      +26     
+ Misses       3609     3607       -2     
  Partials      664      664              
Impacted Files Coverage Δ
hack/generator/pkg/astmodel/resource_type.go 74.42% <93.33%> (+3.41%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a261848...65a3f4e. Read the comment docs.

Copy link
Member

@babbageclunk babbageclunk left a comment

Choose a reason for hiding this comment

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

It's nice to review a couple of PRs with so few files! Lately everything seems to have 50 changed files.

This looks good but I think there's an oversight in the Properties() method.

statusProperty := NewPropertyDefinition("Status", "status", resource.status).
WithTag("json", "omitempty")
result = append(result, statusProperty)
result = append(result, resource.createStatusProperty())
}

return result
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't Properties() return the non-spec/status properties too?

Copy link
Member Author

Choose a reason for hiding this comment

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

And thus we prove that I need to write the test even for code I think I can't possibly get wrong! 😊

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@theunrepentantgeek theunrepentantgeek force-pushed the feature/resource-properties branch from d190653 to 65a3f4e Compare June 14, 2021 01:31
@theunrepentantgeek theunrepentantgeek merged commit 90da966 into master Jun 14, 2021
@theunrepentantgeek theunrepentantgeek deleted the feature/resource-properties branch June 14, 2021 02:15
@@ -24,6 +24,7 @@ type ResourceType struct {
status Type
isStorageVersion bool
owner *TypeName
properties map[PropertyName]*PropertyDefinition
Copy link
Member

Choose a reason for hiding this comment

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

@theunrepentantgeek - Sorry I missed looking at this PR on my Friday, but why do we need this change for the storage versions? The property doesn't have to be on the top level resource type I don't think. It really should be in spec in the storage version too, shouldn't it?

Maybe we can sync up offline or in the meeting today?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants