Skip to content

bug: .spec.related[*].object.selector.matchLabels does not resolve .ClusterName and .ClusterPath #90

@SimonTheLeg

Description

@SimonTheLeg

Describe the bug

From documentation https://docs.kcp.io/api-syncagent/main/publish-resources/templating/ Section "Related Object Label Selectors", the fields .ClusterName and .ClusterPath should be available inside .spec.related[*].object.selector.matchLabels. But when creating an object using them, they resolve to empty string.

Steps To Reproduce

Easiest way to reproduce this by creating an object which would be valid if .ClusterName resolves and invalid if it doesn't. So for example something like this:

  related:
    - identifier: database-credentials
      origin: service
      kind: Secret
      object:
        selector:
          matchLabels:
            # this will result in the string "-bla" in the error logs
            syncagent.kcp.io/selector: '{{ .ClusterName }}-bla'

This then results in an error in syncagent logs, saying that "-bla" is not a valid name. Note in the same example in .spec.naming.name resolves fine. Here is the full object for reference

apiVersion: syncagent.kcp.io/v1alpha1
kind: PublishedResource
metadata:
  name: databases.internal.example
spec:
  resource:
    kind: MySQLDatabase
    apiGroup: database.example.crossplane.io
    versions: [v1]
  naming:
    # need to adjust it to prevent collisions (normally clustername is the namespace)
    name: "{{ .ClusterName }}-{{ .Object.metadata.name | sha3short }}"
  related:
    - identifier: database-credentials
      origin: service
      kind: Secret
      object:
        selector:
          matchLabels:
            # this will result in the string "-bla" in the error logs
            syncagent.kcp.io/selector: '{{ .ClusterName }}-bla'
          rewrite:
            template:
              template: "{{ .Value }}"
        namespace:
          template:
            template: "default"

Expected Behaviour

Should corerctly resolve the ClusterName in the aforementioned example

Additional Context

No response

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions