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

Do not wipe the version when generating schemas for dynamic providers #2727

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

guineveresaenger
Copy link
Contributor

@guineveresaenger guineveresaenger commented Dec 11, 2024

#2664 introduced using the full Generator for schema gen.
This added a call to UnstableGenerateFromSchema, which removes the version field from the package spec, a feature intended to make local builds stable.
This pull request re-adds the version in SchemaPostProcessor.

Copy link

codecov bot commented Dec 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.63%. Comparing base (334d6b7) to head (c808b54).
Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2727      +/-   ##
==========================================
+ Coverage   69.53%   69.63%   +0.10%     
==========================================
  Files         301      301              
  Lines       38655    38725      +70     
==========================================
+ Hits        26878    26968      +90     
+ Misses      10257    10241      -16     
+ Partials     1520     1516       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@guineveresaenger guineveresaenger requested review from iwahbe and a team December 11, 2024 19:33
Comment on lines 1012 to 1016
// For pulumi-owned (not dynamically bridged) providers, omit the version so that the spec is stable
// if the version is e.g. derived from the current Git commit hash.
if strings.Contains(g.info.Repository, "pulumi") {
pulumiPackageSpec.Version = ""
}
Copy link
Member

Choose a reason for hiding this comment

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

The check doesn't do what the comment says. Specifically, it doesn't test pulumi-owned. I'm concerned that this will break external users who set .Repository to the wrong value (or didn't set it). Can we add restoring the version to the post-process script instead?

 dynamic/info.go | 1 +
 dynamic/main.go | 1 +
 2 files changed, 2 insertions(+)

diff --git a/dynamic/info.go b/dynamic/info.go
index d5b05fbc..76fea320 100644
--- a/dynamic/info.go
+++ b/dynamic/info.go
@@ -79,6 +79,7 @@ func providerInfo(ctx context.Context, p run.Provider, value parameterize.Value)
 				},
 				Parameter: value.Marshal(),
 			}
+			spec.Version = p.Version()
 		},
 	}
 	// Add presumed best-effort GitHub org to the provider info.
diff --git a/dynamic/main.go b/dynamic/main.go
index 0a97b970..ce8e387b 100644
--- a/dynamic/main.go
+++ b/dynamic/main.go
@@ -62,6 +62,7 @@ func initialSetup() (info.Provider, pfbridge.ProviderMetadata, func() error) {
 			spec.Attribution = ""
 			spec.Provider = schema.ResourceSpec{}
 			spec.Language = nil
+			spec.Version = version.Version()
 		},
 	}
 

@guineveresaenger
Copy link
Contributor Author

guineveresaenger commented Dec 12, 2024

Hmmm, this doesn't actually seem like it fixes the schemas.
edit: it looks like we don't have access to info.Version in initialSetup yet, so directly writing to the generated package spec seems the way to go here.

@guineveresaenger guineveresaenger marked this pull request as ready for review December 12, 2024 20:01
dynamic/main.go Show resolved Hide resolved
@guineveresaenger guineveresaenger merged commit 1433ab4 into master Dec 12, 2024
17 checks passed
@guineveresaenger guineveresaenger deleted the guin/fix-version branch December 12, 2024 21:40
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v3.98.0.

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.

3 participants