https://pulumi.com logo
#general
Title
# general
c

cool-egg-852

04/07/2020, 2:40 PM
How would one add a securityContext to a container as a transformation?
Copy code
transformations: [
      (resource: any) => {
        if (resource.metadata.name === 'kong-external-kong' && resource.kind === 'Deployment') {
          resource.spec.template.spec.containers[0].securityContext = {
            capabilities: {
              drop: ['ALL'],
              add: ['NET_BIND_SERVICE'],
            },
            allowPrivilegeEscalation: true,
          };
        }
      },
    ],
doesn’t seem to work
Copy code
TSError: ⨯ Unable to compile TypeScript:
    chart.ts(58,7): error TS2322: Type '(resource: any) => void' is not assignable to type 'ResourceTransformation'.
      Type 'void' is not assignable to type 'ResourceTransformationResult'.
    chart.ts(122,7): error TS2322: Type '(resource: any) => void' is not assignable to type 'ResourceTransformation'.
      Type 'void' is not assignable to type 'ResourceTransformationResult'.
c

clean-eve-27532

04/07/2020, 2:45 PM
I think you have to return the resource
c

cool-egg-852

04/07/2020, 2:45 PM
None of their examples show returning anything
Did something change and none of their documentation got updated?
l

limited-rainbow-51650

04/07/2020, 2:47 PM
A transformation is a function taking in
args
and returning
ResourceTransformationResult
or
undefined
. Your signature differs from that
Copy code
type ResourceTransformation = (args: ResourceTransformationArgs) => ResourceTransformationResult | undefined;
c

cool-egg-852

04/07/2020, 2:47 PM
Yeah, I think they changed this and didn’t follow semver
There is no returns there
This is how it always was.
aah, you know what, I’m getting confused by helm transformations and resource transformations.
Unfortunately they are 2 completely different concepts
b

busy-umbrella-36067

04/07/2020, 2:49 PM
where are you specifying transformatinos
l

limited-rainbow-51650

04/07/2020, 2:49 PM
Well, they are in the middle of preparing their 2.0 release and need to update code and documentation for core and all the providers.
b

busy-umbrella-36067

04/07/2020, 2:49 PM
signature for the helm one is void return
c

cool-egg-852

04/07/2020, 2:50 PM
Yeah, it’s a bit confusing that there are 2 different transformations, one for helm and one for everything else.
7 Views