crossplane-contrib / crossplane-contrib/function-kro

Allow dynamic keys for Labels and Annotations

Open
#101 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
23
Forks
8
Avg merge
14h 29m
Merged PRs (30d)
1

Description

### What problem are you facing?
We use `Labels` to store metadata-information, such as `serviceIds` on our resources. At the moment some of our `ServiceProviders` are experimenting with `function-kro` and hit a limitation where they need to be able to dynamically write label-keys, but `function-kro` does not support this at the moment and treats the `template-value` as a string.

### How could this Function help solve your problem?

We would need the following to work, in order to fully switch from `function-go-templating` to `function-kro`

```diff
- id: dnsRecords
forEach:
- idx: '${lists.range(mongodballocation.status.atProvider.mongosNum)}'
includeWhen:
- '${size(release.spec.?forProvider.?values.?mongoSIPs.orValue([])) == mongodballocation.status.atProvider.mongosNum}'
template:
apiVersion: example.cloud/v1
kind: ProviderDNSRecord
metadata:
name: '${schema.metadata.name + "-" + schema.spec.organization + "-" + mongodballocation.status.atProvider.targetCluster + "-mongos-" + string(idx)}'
labels:
+ '${ "serviceid.example.cloud/" + "envConfig.data.serviceID"} : ""
spec:
zonename: '${envConfig.data.dnsZone + "." + schema.spec.stage}'
name: '${schema.metadata.name + "-" + schema.spec.organization + "-" + mongodballocation.status.atProvider.targetCluster + "-mongos-" + string(idx)}'
type: a
content: '${release.spec.forProvider.values.mongoSIPs[idx]}'
ttl: 600
```

#### Possible Contribution
In order to check if it is possible at all, i forked the function and used CoPilot to do the changes. If you are interested, I can open a PR and discuss the code with you.

https://github.com/mattagohni/function-kro

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the YAML example in the issue and the linked fork, https://github.com/mattagohni/function-kro, to understand how dynamic label and annotation keys are handled. Done means expressions can produce label or annotation keys while preserving the requested values, allowing this example to work without treating the key expression as a string.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.