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
Support defining extra resources and functions #625
Conversation
Similar to the existing `ExtraTypes` field, add `ExtraResources` and `ExtraFunctions` fields to `ProviderInfo` to support defining extra schema for additional resources and functions. These could be for overlays or additional resources and/or functions implemented in a "multiplexed" provider.
ExtraResources map[string]pschema.ResourceSpec // a map of Pulumi token to schema type for extra resources. | ||
ExtraFunctions map[string]pschema.FunctionSpec // a map of Pulumi token to schema type for extra functions. |
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.
ExtraResources
and ExtraFunctions
are the only additions here.
for token, res := range g.info.ExtraResources { | ||
if _, defined := spec.Resources[token]; defined { | ||
return pschema.PackageSpec{}, fmt.Errorf("failed to define extra resources: %v is already defined", token) | ||
} | ||
spec.Resources[token] = res | ||
} | ||
|
||
for token, fun := range g.info.ExtraFunctions { | ||
if _, defined := spec.Functions[token]; defined { | ||
return pschema.PackageSpec{}, fmt.Errorf("failed to define extra functions: %v is already defined", token) | ||
} | ||
spec.Functions[token] = fun | ||
} | ||
|
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.
These loops are equivalent to the loop above on line 302 for ExtraTypes
.
Diff for pulumi-azuread with merge commit 222736f |
Diff for pulumi-random with merge commit 222736f |
Diff for pulumi-gcp with merge commit 222736f |
Diff for pulumi-azure with merge commit 222736f |
Diff for pulumi-aws with merge commit 222736f |
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.
Got some time to try this out, and it works beautifully as expected.
Thank you!
Similar to the existing
ExtraTypes
field, addExtraResources
andExtraFunctions
fields toProviderInfo
to support defining extra schema for additional resources and functions. These could be for overlays or additional resources and/or functions implemented in a "multiplexed" provider.