How would one add a securityContext to a container...
# general
c
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
I think you have to return the resource
c
None of their examples show returning anything
Did something change and none of their documentation got updated?
l
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
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
where are you specifying transformatinos
l
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
signature for the helm one is void return
c
Yeah, it’s a bit confusing that there are 2 different transformations, one for helm and one for everything else.