-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add parameterized provider support to YAML #616
Conversation
dac6515
to
01ae27b
Compare
3d644fa
to
da2797b
Compare
da2797b
to
9bda4c0
Compare
5d5a867
to
4b46d23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments but I think this is good to go. One thing I think of is if we'd ever want to put multiple packages in a single lock file, but I think this is fine -- we could introduce a top-level packages
key and look for that first (optionally bumping the lockfile version).
@@ -0,0 +1,162 @@ | |||
// Copyright 2024, Pulumi Corporation. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self -- we should sort the licence headers in this repo
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type ParameterizationDecl struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some doc comments on the public interface structs would be nice I reckon.
pkg/pulumiyaml/packages/file.go
Outdated
Parameterization *ParameterizationDecl `yaml:"parameterization,omitempty"` | ||
} | ||
|
||
func (p *PackageDecl) Valid() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth changing this to Validate() error
so we can have better failure reasons?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could do now we've got PackageDeclartionVersion. I was worried about err'ing on too many files before.
pkg/pulumiyaml/packages/file.go
Outdated
func SearchPackageDecls(directory string) ([]PackageDecl, error) { | ||
if directory == "" { | ||
directory = "." | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any benefit to doing this rather than letting the caller just specify "."
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, lets be strict.
pkg/pulumiyaml/run.go
Outdated
@@ -343,6 +378,14 @@ func (r *Runner) setDefaultProviders() { | |||
contract.IgnoreError(diags) | |||
} | |||
|
|||
// Set the runners package descriptors from the templates package decls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Set the runners package descriptors from the templates package decls. | |
// Set the runner's package descriptors from the templates package decls. |
pkg/pulumiyaml/run.go
Outdated
// Register package refs for all packages we know upfront | ||
packageDescriptors, err := packages.ToPackageDescriptors(r.t.Packages) | ||
r.packageDescriptors = packageDescriptors | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we always set even if there is an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not
pkg/pulumiyaml/run.go
Outdated
} | ||
|
||
var parameterization *pulumirpc.Parameterization | ||
if pkg.Parameterization != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor but we could combine these ifs to avoid the double check (cheap as it is). Happy either way. Same is true of ToPackageDescriptors
earlier too if we feel like it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
This PR has been shipped in release v1.11.0. |
This adds parameterized provider support to YAML.
This is done via new "package declaration" files, which are generated by
gen-sdk
. On startup the yaml runtime searches for these files and will use them to register provider packages with the engine. These can include parameterized values, thus supporting parameterized providers.The schema loader code paths have also been updated to use these package declarations to allow type checking of resources from parameterized packages as well.
Fixes #626.