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

[codegen/go] Simplify object default applies. #8539

Merged
merged 3 commits into from
Dec 3, 2021

Conversation

pgavlin
Copy link
Member

@pgavlin pgavlin commented Dec 3, 2021

The overall goal of this change is to avoid unnecessary conversions
between pointer and non-pointer output types. The use of these
conversions requires that we always generate the pointer variant of an
object type, which impedes #7943's ability to omit these types. Instead,
we can let the return type of the callback match the argument type and
return the dereferenced result of foo.Defaults() if necessary.

These changes also simplify the generated code somewhat in order to
avoid introducing additional variables.

The overall goal of this change is to avoid unnecessary conversions
between pointer and non-pointer output types. The use of these
conversions requires that we always generate the pointer variant of an
object type, which impedes #7943's ability to omit these types. Instead,
we can let the return type of the callback match the argument type and
return the dereferenced result of `foo.Defaults()` if necessary.

These changes also simplify the generated code somewhat in order to
avoid introducing additional variables.
@pgavlin pgavlin requested a review from iwahbe December 3, 2021 00:30
@pgavlin pgavlin requested a review from justinvp December 3, 2021 00:31
@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azuread with merge commit 427f556

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-random with merge commit 427f556

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-random with merge commit 92c0d10

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azuread with merge commit 92c0d10

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-kubernetes with merge commit 427f556

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-kubernetes with merge commit 92c0d10

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-gcp with merge commit 92c0d10

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-gcp with merge commit 427f556

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azure with merge commit 92c0d10

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azure with merge commit 427f556

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-aws with merge commit 92c0d10

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-aws with merge commit 427f556

@codecov
Copy link

codecov bot commented Dec 3, 2021

Codecov Report

Merging #8539 (457dc13) into master (05e26e3) will decrease coverage by 0.00%.
The diff coverage is 92.85%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8539      +/-   ##
==========================================
- Coverage   58.63%   58.62%   -0.01%     
==========================================
  Files         634      634              
  Lines       96865    96844      -21     
  Branches     1378     1378              
==========================================
- Hits        56794    56779      -15     
+ Misses      36808    36799       -9     
- Partials     3263     3266       +3     
Impacted Files Coverage Δ
pkg/codegen/go/gen.go 88.40% <92.85%> (-0.10%) ⬇️
...k/dotnet/Pulumi/Deployment/TaskMonitoringHelper.cs 96.29% <0.00%> (-3.71%) ⬇️
sdk/go/common/resource/properties.go 82.59% <0.00%> (-1.11%) ⬇️
pkg/codegen/hcl2/model/type_object.go 89.18% <0.00%> (-0.55%) ⬇️
sdk/go/common/util/ciutil/github_actions.go 73.52% <0.00%> (+38.23%) ⬆️

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 05e26e3...457dc13. Read the comment docs.

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

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

2 nits, Otherwise LGTM.

  1. I would love to see some comments describing outputType and outputTypeImpl (and why the both exist).
  2. My understanding is that this cleans up only our internal implementation of Defaults. Do we need a changelog entry for this? (I'm genuinely asking. I've heard conflicting definitions of "changelog worthy)

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azure-native with merge commit 427f556

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azure-native with merge commit 92c0d10

@pgavlin
Copy link
Member Author

pgavlin commented Dec 3, 2021

My understanding is that this cleans up only our internal implementation of Defaults. Do we need a changelog entry for this? (I'm genuinely asking. I've heard conflicting definitions of "changelog worthy)

These days I think that we should be adding CL entries for all codegen changes, especially to help @pulumi/platform-integrations and @pulumi/native-providers understand that sort of changes to expect in the generated SDKs.

@pgavlin
Copy link
Member Author

pgavlin commented Dec 3, 2021

I would love to see some comments describing outputType and outputTypeImpl (and why the both exist).

Done.

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azuread with merge commit 3ec6d3f

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-random with merge commit 3ec6d3f

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-kubernetes with merge commit 3ec6d3f

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-gcp with merge commit 3ec6d3f

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azure with merge commit 3ec6d3f

@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-aws with merge commit 3ec6d3f

@emiliza emiliza added capacity/quality kind/task Work that's part of an ongoing epic size/S Estimated effort to complete (1-2 days). labels Dec 3, 2021
@emiliza emiliza added this to the 0.65 milestone Dec 3, 2021
@github-actions
Copy link

github-actions bot commented Dec 3, 2021

Diff for pulumi-azure-native with merge commit 3ec6d3f

@pgavlin pgavlin merged commit abfae57 into master Dec 3, 2021
@pulumi-bot pulumi-bot deleted the pgavlin/simpler-go-defaults branch December 3, 2021 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Work that's part of an ongoing epic size/S Estimated effort to complete (1-2 days).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants