The Combine patches enable us to include multiple string values into a single patch. For this example, I’ll focus on CombineFromComposite, you can infer the CombineToComposite patch from the previous ToCompositeFieldPath post.
With CombineFromComposite, we pass multiple XR fields to a single patch. They are referenced (in order defined) by the ‘%s’ syntax. There isn’t an example of this in the platform reference repo I’ve used in previous posts, so I will use excerpts from a config I will post in an upcoming post (Configuring AWS IRSA with Crossplane).
Below you see an example of a CombineFromComposite patch. I am taking four values that exist at the XR spec.values level, and patching them into a string (in this case, an aws IAM role definition). With this patch type, you have to be very precise. The order in which you define your variables is the order you need to place the ‘%s’ in.
As you can see, my first two variables are spec.values.accountID and spec.values.oidc. On line 121, I use %s twice for the first time. This patches in the values of spec.values.accountID and spec.values.oidc from the XR to the string, respectively. Later in the patch (on line 126) I patch the other two variables in.
This patch type is useful when we need to accumulate/combine multiple fields into a single resource template or nested XR. In the example above, I’m using it to define an aws Role for EKS IRSA.
That’s all for patches. Patches and Transforms can be referenced in the docs for Crossplane. If you fully comprehend and understand Crossplane Providers, XRD, XRC, XR, Composition, Patches, and Transforms, you’re in great shape. If not, read back on my previous posts. My upcoming posts will focus on specific configurations, beginning with AWS IRSA and Helm charts.