Skip to content
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

Regex matching not behaving as expected #35

Open
ashishkurian opened this issue Dec 3, 2024 · 0 comments
Open

Regex matching not behaving as expected #35

ashishkurian opened this issue Dec 3, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ashishkurian
Copy link

What happened?

I tried the latest version v0.2.1 of the function sequencer to have regex matching of resource names. However it does not seem to be working.

How can we reproduce it?

I am using the following composition to have control over the sequence of resource creation. I want EksClusterId-Ashtest to be created before EksUserArn-Ashtest. However, with the following regex matching, both the resources are created concurrently. As soon as I specify the exact names of the resources instead of a regex matching, the sequence is followed.

---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: xcastaicommon.mycompany.com
spec:
  compositeTypeRef:
    apiVersion: mycompany.com/v1alpha1
    kind: XCastAICommon
  environment:
    environmentConfigs:
    - type: Reference
      ref:
        name: iaws-main
    - type: Reference
      ref:
        name: iaws-auto
  mode: Pipeline
  pipeline:
  - step: castai-ekscluster
    functionRef:
      name: function-go-templating
    input:
      apiVersion: gotemplating.fn.crossplane.io/v1beta1
      kind: GoTemplate
      source: Inline
      inline:
        template: |
          {{- $accountId          := printf "%q" (.observed.composite.resource.spec.genericParameters.accountID) }}
          {{- $region             := .observed.composite.resource.spec.genericParameters.region }}
          {{- $eksClusterName     := .observed.composite.resource.spec.genericParameters.eksClusterName }}
          {{- $deletionPolicy     := .observed.composite.resource.spec.genericParameters.deletionPolicy }}
          {{- $providerConfigRef  := .observed.composite.resource.spec.genericParameters.providerConfig }}
          ---
          apiVersion: castai.upbound.io/v1alpha1
          kind: EksClusterId
          metadata:
            annotations:
              gotemplating.fn.crossplane.io/composition-resource-name: EksClusterId-Ashtest
            labels:
              cast-ai-cluster: {{$eksClusterName}}
          spec:
            deletionPolicy: {{$deletionPolicy}}
            providerConfigRef:
              name: {{$providerConfigRef}}
            forProvider:
              region: {{$region}}
              accountId: {{$accountId}}
              clusterName: {{$eksClusterName}}            
  - step: castai-eksuserarn
    functionRef:
      name: function-go-templating
    input:
      apiVersion: gotemplating.fn.crossplane.io/v1beta1
      kind: GoTemplate
      source: Inline
      inline:
        template: |
          {{- $deletionPolicy     := .observed.composite.resource.spec.genericParameters.deletionPolicy }}
          {{- $providerConfigRef  := .observed.composite.resource.spec.genericParameters.providerConfig }}
          {{ $managedresources    := .observed.resources | default dict }}
          {{ $EksClusterId        := get $managedresources "EksClusterId-Ashtest" | default dict }}
          {{ $EksClusterIdId      := dig "resource" "status" "atProvider" "id" "defaultvalue" $EksClusterId }}
          ---
          apiVersion: castai.upbound.io/v1alpha1
          kind: EksUserArn
          metadata:
            annotations:
              gotemplating.fn.crossplane.io/composition-resource-name: EksUserArn-Ashtest
          spec:
            deletionPolicy: {{$deletionPolicy}}
            providerConfigRef:
              name: {{$providerConfigRef}}
            forProvider:
              clusterId: {{$EksClusterIdId}}
  - step: automatically-detect-ready-composed-resources
    functionRef:
      name: function-auto-ready
  - step: sequence-creation
    functionRef:
      name: function-sequencer
    input:
      apiVersion: sequencer.fn.crossplane.io/v1beta1
      kind: Input
      rules:
        - sequence:
          - ^EksClusterId-.*$
          - ^EksUserArn-.*$

What environment did it happen in?

Function version: v0.2.1

@ashishkurian ashishkurian added the bug Something isn't working label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant