-
Notifications
You must be signed in to change notification settings - Fork 915
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
Is there a way to limit or slice a given string to a length in compositions #5492
Comments
One option would be to use the apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: example
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1beta1
kind: XR
mode: Pipeline
pipeline:
- step: render-resources
functionRef:
name: function-go-templating
input:
apiVersion: gotemplating.fn.crossplane.io/v1beta1
kind: GoTemplate
source: Inline
inline:
template: |
{{ $roleTrimmed := substr 0 63 .observed.composite.resource.spec.roleName }}
apiVersion: iam.aws.upbound.io/v1beta1
kind: Role
metadata:
annotations:
gotemplating.fn.crossplane.io/composition-resource-name: role
spec:
forProvider:
roleName: {{ $roleTrimmed | toYaml }}
- step: automatically-detect-ready-composed-resources
functionRef:
name: function-auto-ready |
@jaylevin let me try that :) So composite function pipeline's works in conjunction with existing resources described in the composition? |
|
You can run the |
@bobh66 @jaylevin My use case was creating s3 with pod identity. I wanted to use the composite function for the role resource and keep everything else as is. Based on the documentation we cannot have mode as both Pipeline and Resources (unless i missed something). It can only be one. I wanted to adjust my existing composition to accomodate the below composite function.
So I guess i will have to migrate the below composition to make use of composition function. My existing composition (without composition function) is below
|
As described above: #5492 (comment) convert your existing composition to function patch&transform and then add your go-templating function to the pipeline |
Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as |
I have not tested it but I wonder if the regex transform would work - something like:
I think that says to match the first 63 characters of the serviceAccountName field, but again I have not tested it. |
Hello,
I am accepting a service name from my developer in the claim. This string is used to create the role. There are use cases where the string is longer than 64 char (string limit of a role name). I have an opa policy to invalidate such claims.
But if its possible to trim the string to 64 characters, I can use that to create the role.
Regards
Ashish
The text was updated successfully, but these errors were encountered: