-
Notifications
You must be signed in to change notification settings - Fork 227
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 new transforms docs #11851
Add new transforms docs #11851
Conversation
Your site preview for commit dbac5d8 is ready! 🎉 http://www-production-pulumi-docs-origin-pr-11851-dbac5d83.s3-website.us-west-2.amazonaws.com. |
length := rta.Props["length"].(pulumi.Float64Output) | ||
rta.Props["length"] = length.ApplyT(func(v float64) float64 { return v * 2 }) |
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.
I think it would be great to expand on how to transform the props, like explain that the values are encapsulated as Outputs, that you should expect variations related to secretness (should you?), and that you transform the outputs as explained elsewhere.
Here's an example of how to add a Kubernetes annotation. Would be awesome to show an example like this for each SDK.
const applyPatchForceAnnotation = async (args: pulumi.ResourceTransformArgs) => {
switch(args.type) {
case "kubernetes:helm.sh/v4:Chart":
break;
default:
args.props.metadata.annotations = {
"pulumi.com/patchForce": "true",
...args.props.metadata.annotations
}
}
return {
props: args.props,
opts: args.opts,
};
};
// Use Helm to install the Nginx ingress controller
const ingressController = new kubernetes.helm.v4.Chart("ingresscontroller", {
chart: "nginx-ingress",
namespace: ingressNs.metadata.name,
repositoryOpts: {
repo: "https://helm.nginx.com/stable",
},
skipCrds: false,
values: {
controller: {
enableCustomResources: true,
appprotect: {
enable: false,
},
appprotectdos: {
enable: false,
},
service: {
extraLabels: appLabels,
},
},
},
version: "0.14.1",
}, {transforms: [applyPatchForceAnnotation]});
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.
A similar example in Python:
def apply_patchforce_annotation(args: ResourceTransformArgs):
if not args.type_ == "kubernetes:helm.sh/v4:Chart":
if not 'metadata' in args.props:
args.props['metadata'] = {}
if not 'annotations' in args.props['metadata']:
args.props['metadata']['annotations'] = {}
args.props['metadata']['annotations']['pulumi.com/patchForce'] = 'true'
return ResourceTransformResult(
props=args.props,
opts=args.opts)
ingresscontroller = kubernetes.helm.v4.Chart(
"ingresscontroller",
chart="nginx-ingress",
namespace=ingress_ns.metadata.name,
repository_opts=kubernetes.helm.v3.RepositoryOptsArgs(
repo="https://helm.nginx.com/stable",
),
version="0.14.1",
opts=pulumi.ResourceOptions(transforms=[apply_patchforce_annotation])
)
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.
I think it would be great to expand on how to transform the props, like explain that the values are encapsulated as Outputs, that you should expect variations related to secretness (should you?), and that you transform the outputs as explained elsewhere.
Agree! It's somewhat shown in some of the examples, but I'd like to expand on this as a fast follow.
Would be awesome to show an example like this for each SDK.
Yes. Haven't had a chance to port to each language, but would love to have more examples to show.
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.
A few things I noticed while experimenting with transforms based of these docs.
dbac5d8
to
23ed418
Compare
Your site preview for commit 23ed418 is ready! 🎉 http://www-testing-pulumi-docs-origin-pr-11851-23ed418b.s3-website.us-west-2.amazonaws.com. |
Adds docs for the new transforms APIs. Ported from pulumi/pulumi-hugo#4044.