apiVersion: sonataflow.org/v1alpha08
kind: SonataFlow
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"sonataflow.org/v1alpha08","kind":"SonataFlow","metadata":{"annotations":{"sonataflow.org/description":"Create GitLab merge request","sonataflow.org/expressionLang":"jq","sonataflow.org/profile":"gitops","sonataflow.org/version":"1.0"},"creationTimestamp":null,"labels":{"app":"gl-pr","app.kubernetes.io/component":"serverless-workflow","app.kubernetes.io/managed-by":"sonataflow-operator","app.kubernetes.io/name":"gl-pr","sonataflow.org/workflow-app":"gl-pr","sonataflow.org/workflow-namespace":""},"name":"gl-pr","namespace":"sonataflow-infra"},"spec":{"flow":{"dataInputSchema":{"failOnValidationErrors":true,"schema":"schemas/basic__main-schema.json"},"functions":[{"name":"getBranchSHA","operation":"specs/gitlab.yaml#getBranchSHA","type":"rest"},{"name":"createCommit","operation":"specs/gitlab.yaml#createCommit","type":"rest"},{"name":"createBlob","operation":"specs/gitlab.yaml#createBlob","type":"rest"},{"name":"createBranch","operation":"specs/gitlab.yaml#createBranch","type":"rest"},{"name":"getCommitDetails","operation":"specs/gitlab.yaml#getCommitDetails","type":"rest"},{"name":"createMergeRequest","operation":"specs/gitlab.yaml#createMergeRequest","type":"rest"},{"name":"print","operation":"sysout","type":"custom"},{"name":"createNewBlob","operation":"{\"action\": \"create\", \"file_path\": \"test.txt\", \"content\": \"TEST\"}","type":"expression"},{"name":"successResult","operation":"{ \"result\": { \"message\": \"MR created\", \"outputs\":[ { \"key\": \"MR_URL\", \"value\": .mrURL.web_url, \"format\":\"link\" } ] } }","type":"expression"}],"start":{"stateName":"CreateBranch"},"states":[{"actionMode":"sequential","actions":[{"actionDataFilter":{"toStateData":".latestSHA","useResults":true},"functionRef":{"arguments":{"branch":".baseBranch","project_id":".project_id"},"invoke":"sync","refName":"getBranchSHA"},"name":"GetHeadSha"},{"actionDataFilter":{"useResults":true},"functionRef":{"arguments":{"branch":".targetBranch","project_id":".project_id","ref":".baseBranch"},"invoke":"sync","refName":"createBranch"},"name":"createBranch"},{"actionDataFilter":{"toStateData":".commit","useResults":true},"functionRef":{"arguments":{"project_id":".project_id","sha":".latestSHA.commit.id"},"invoke":"sync","refName":"getCommitDetails"},"name":"getCommitDetails"}],"name":"CreateBranch","transition":{"nextState":"CreateFiles"},"type":"operation"},{"actionMode":"sequential","actions":[{"actionDataFilter":{"toStateData":".blobs","useResults":true},"functionRef":{"invoke":"sync","refName":"createNewBlob"},"name":"createNewBlob"}],"name":"CreateFiles","transition":{"nextState":"CreateCommit"},"type":"operation"},{"actionMode":"sequential","actions":[{"actionDataFilter":{"toStateData":".newCommit","useResults":true},"functionRef":{"arguments":{"actions":[".blobs"],"branch":".targetBranch","commit_message":"Added/Updated multiple files via API","project_id":".project_id"},"invoke":"sync","refName":"createCommit"},"name":"createCommit"}],"name":"CreateCommit","transition":{"nextState":"CreateMR"},"type":"operation"},{"actionMode":"sequential","actions":[{"actionDataFilter":{"toStateData":".mrURL","useResults":true},"functionRef":{"arguments":{"description":"","project_id":".project_id","source_branch":".targetBranch","target_branch":".baseBranch","title":"Automated MR"},"invoke":"sync","refName":"createMergeRequest"},"name":"createMergeRequest"},{"actionDataFilter":{"useResults":true},"functionRef":{"invoke":"sync","refName":"successResult"},"name":"setOutput"}],"end":{"terminate":true},"name":"CreateMR","type":"operation"}]},"persistence":{"postgresql":{"secretRef":{"name":"sonataflow-psql-postgresql","passwordKey":"postgres-password","userKey":"postgres-username"},"serviceRef":{"databaseName":"sonataflow","databaseSchema":"gl-pr","name":"sonataflow-psql-postgresql","port":5432}}},"podTemplate":{"container":{"env":[{"name":"JAVA_TOOL_OPTIONS","value":"-Djavax.net.ssl.trustStore=/cacerts/cacerts -Djavax.net.ssl.trustStorePassword=changeit"},{"name":"NODE_EXTRA_CA_CERTS","value":"/certs/gitlab.crt"},{"name":"NOTIFICATIONS_BEARER_TOKEN","valueFrom":{"secretKeyRef":{"key":"NOTIFICATIONS_BEARER_TOKEN","name":"gl-pr-secrets"}}}],"envFrom":[{"secretRef":{"name":"gl-pr-secrets"}}],"image":"quay.io/orchestrator/gl-pr","resources":{},"volumeMounts":[{"mountPath":"/cacerts","name":"target-cacerts"}]},"initContainers":[{"command":["/bin/sh","-c","cat $JAVA_HOME/lib/security/cacerts \u003e /work/cacerts \u0026\u0026 \\\nchmod +w /work/cacerts \u0026\u0026 \\\nkeytool -importcert -noprompt \\\n  -alias gitlab-cert \\\n  -file /certs/gitlab.crt \\\n  -keystore /work/cacerts \\\n  -storepass changeit\n"],"image":"registry.access.redhat.com/ubi9/openjdk-17","name":"generate-cacerts","volumeMounts":[{"mountPath":"/certs","name":"gitlab-cert"},{"mountPath":"/work","name":"target-cacerts"}]}],"volumes":[{"configMap":{"name":"gitlab-cert"},"name":"gitlab-cert"},{"emptyDir":{},"name":"target-cacerts"}]},"resources":{"configMaps":[{"configMap":{"name":"01-gl-pr-resources-schemas"},"workflowPath":"schemas"},{"configMap":{"name":"02-gl-pr-resources-specs"},"workflowPath":"specs"}]}},"status":{"address":{},"lastTimeRecoverAttempt":null}}
    sonataflow.org/description: Create GitLab merge request
    sonataflow.org/expressionLang: jq
    sonataflow.org/profile: gitops
    sonataflow.org/version: '1.0'
  resourceVersion: '8724791'
  name: gl-pr
  uid: 7e0c8c10-3b02-4ddc-a939-933cbd55769c
  creationTimestamp: '2025-07-27T10:57:09Z'
  generation: 5
  managedFields:
    - apiVersion: sonataflow.org/v1alpha08
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:finalizers':
            .: {}
            'v:"workflow-deletion"': {}
      manager: manager
      operation: Update
      time: '2025-07-27T10:57:09Z'
    - apiVersion: sonataflow.org/v1alpha08
      fieldsType: FieldsV1
      fieldsV1:
        'f:metadata':
          'f:annotations':
            .: {}
            'f:kubectl.kubernetes.io/last-applied-configuration': {}
            'f:sonataflow.org/description': {}
            'f:sonataflow.org/expressionLang': {}
            'f:sonataflow.org/profile': {}
            'f:sonataflow.org/version': {}
          'f:labels':
            .: {}
            'f:app': {}
            'f:app.kubernetes.io/component': {}
            'f:app.kubernetes.io/managed-by': {}
            'f:app.kubernetes.io/name': {}
            'f:sonataflow.org/workflow-app': {}
            'f:sonataflow.org/workflow-namespace': {}
        'f:spec':
          .: {}
          'f:flow':
            .: {}
            'f:dataInputSchema':
              .: {}
              'f:failOnValidationErrors': {}
              'f:schema': {}
            'f:functions': {}
            'f:start':
              .: {}
              'f:stateName': {}
            'f:states': {}
          'f:persistence':
            .: {}
            'f:dbMigrationStrategy': {}
            'f:postgresql':
              .: {}
              'f:secretRef':
                .: {}
                'f:name': {}
                'f:passwordKey': {}
                'f:userKey': {}
              'f:serviceRef':
                .: {}
                'f:databaseName': {}
                'f:databaseSchema': {}
                'f:name': {}
                'f:port': {}
          'f:podTemplate':
            .: {}
            'f:container':
              .: {}
              'f:env': {}
              'f:envFrom': {}
              'f:image': {}
              'f:resources': {}
              'f:volumeMounts': {}
            'f:initContainers': {}
            'f:volumes': {}
          'f:resources':
            .: {}
            'f:configMaps': {}
      manager: kubectl-client-side-apply
      operation: Update
      time: '2025-07-27T11:07:53Z'
    - apiVersion: sonataflow.org/v1alpha08
      fieldsType: FieldsV1
      fieldsV1:
        'f:status':
          .: {}
          'f:address': {}
          'f:conditions': {}
          'f:flowCRC': {}
          'f:lastTimeStatusNotified': {}
          'f:observedGeneration': {}
          'f:platform':
            .: {}
            'f:name': {}
            'f:namespace': {}
          'f:services':
            .: {}
            'f:dataIndexRef':
              .: {}
              'f:url': {}
            'f:jobServiceRef':
              .: {}
              'f:url': {}
      manager: manager
      operation: Update
      subresource: status
      time: '2025-07-27T11:40:54Z'
  namespace: sonataflow-infra
  finalizers:
    - workflow-deletion
  labels:
    app: gl-pr
    app.kubernetes.io/component: serverless-workflow
    app.kubernetes.io/managed-by: sonataflow-operator
    app.kubernetes.io/name: gl-pr
    sonataflow.org/workflow-app: gl-pr
    sonataflow.org/workflow-namespace: ''
spec:
  flow:
    dataInputSchema:
      failOnValidationErrors: true
      schema: schemas/basic__main-schema.json
    functions:
      - name: getBranchSHA
        operation: specs/gitlab.yaml#getBranchSHA
        type: rest
      - name: createCommit
        operation: specs/gitlab.yaml#createCommit
        type: rest
      - name: createBlob
        operation: specs/gitlab.yaml#createBlob
        type: rest
      - name: createBranch
        operation: specs/gitlab.yaml#createBranch
        type: rest
      - name: getCommitDetails
        operation: specs/gitlab.yaml#getCommitDetails
        type: rest
      - name: createMergeRequest
        operation: specs/gitlab.yaml#createMergeRequest
        type: rest
      - name: print
        operation: sysout
        type: custom
      - name: createNewBlob
        operation: '{"action": "create", "file_path": "test.txt", "content": "TEST"}'
        type: expression
      - name: successResult
        operation: '{ "result": { "message": "MR created", "outputs":[ { "key": "MR_URL", "value": .mrURL.web_url, "format":"link" } ] } }'
        type: expression
    start:
      stateName: CreateBranch
    states:
      - actionMode: sequential
        actions:
          - actionDataFilter:
              toStateData: .latestSHA
              useResults: true
            functionRef:
              arguments:
                branch: .baseBranch
                project_id: .project_id
              invoke: sync
              refName: getBranchSHA
            name: GetHeadSha
          - actionDataFilter:
              useResults: true
            functionRef:
              arguments:
                branch: .targetBranch
                project_id: .project_id
                ref: .baseBranch
              invoke: sync
              refName: createBranch
            name: createBranch
          - actionDataFilter:
              toStateData: .commit
              useResults: true
            functionRef:
              arguments:
                project_id: .project_id
                sha: .latestSHA.commit.id
              invoke: sync
              refName: getCommitDetails
            name: getCommitDetails
        name: CreateBranch
        transition:
          nextState: CreateFiles
        type: operation
      - actionMode: sequential
        actions:
          - actionDataFilter:
              toStateData: .blobs
              useResults: true
            functionRef:
              invoke: sync
              refName: createNewBlob
            name: createNewBlob
        name: CreateFiles
        transition:
          nextState: CreateCommit
        type: operation
      - actionMode: sequential
        actions:
          - actionDataFilter:
              toStateData: .newCommit
              useResults: true
            functionRef:
              arguments:
                actions:
                  - .blobs
                branch: .targetBranch
                commit_message: Added/Updated multiple files via API
                project_id: .project_id
              invoke: sync
              refName: createCommit
            name: createCommit
        name: CreateCommit
        transition:
          nextState: CreateMR
        type: operation
      - actionMode: sequential
        actions:
          - actionDataFilter:
              toStateData: .mrURL
              useResults: true
            functionRef:
              arguments:
                description: ''
                project_id: .project_id
                source_branch: .targetBranch
                target_branch: .baseBranch
                title: Automated MR
              invoke: sync
              refName: createMergeRequest
            name: createMergeRequest
          - actionDataFilter:
              useResults: true
            functionRef:
              invoke: sync
              refName: successResult
            name: setOutput
        end:
          terminate: true
        name: CreateMR
        type: operation
  persistence:
    dbMigrationStrategy: service
    postgresql:
      secretRef:
        name: sonataflow-psql-postgresql
        passwordKey: postgres-password
        userKey: postgres-username
      serviceRef:
        databaseName: sonataflow
        databaseSchema: gl-pr
        name: sonataflow-psql-postgresql
        port: 5432
  podTemplate:
    container:
      env:
        - name: JAVA_TOOL_OPTIONS
          value: '-Djavax.net.ssl.trustStore=/cacerts/cacerts -Djavax.net.ssl.trustStorePassword=changeit'
        - name: NODE_EXTRA_CA_CERTS
          value: /certs/gitlab.crt
        - name: NOTIFICATIONS_BEARER_TOKEN
          valueFrom:
            secretKeyRef:
              key: NOTIFICATIONS_BEARER_TOKEN
              name: gl-pr-secrets
      envFrom:
        - secretRef:
            name: gl-pr-secrets
      image: quay.io/orchestrator/gl-pr
      resources: {}
      volumeMounts:
        - mountPath: /cacerts
          name: target-cacerts
    initContainers:
      - command:
          - /bin/sh
          - '-c'
          - |
            cat $JAVA_HOME/lib/security/cacerts > /work/cacerts && \
            chmod +w /work/cacerts && \
            keytool -importcert -noprompt \
              -alias gitlab-cert \
              -file /certs/gitlab.crt \
              -keystore /work/cacerts \
              -storepass changeit
        image: registry.access.redhat.com/ubi9/openjdk-17
        name: generate-cacerts
        volumeMounts:
          - mountPath: /certs
            name: gitlab-cert
          - mountPath: /work
            name: target-cacerts
    volumes:
      - configMap:
          name: gitlab-cert
        name: gitlab-cert
      - emptyDir: {}
        name: target-cacerts
  resources:
    configMaps:
      - configMap:
          name: 01-gl-pr-resources-schemas
        workflowPath: schemas
      - configMap:
          name: 02-gl-pr-resources-specs
        workflowPath: specs
status:
  address: {}
  conditions:
    - lastUpdateTime: '2025-07-27T10:57:09Z'
      reason: BuildSkipped
      status: 'False'
      type: Built
    - lastUpdateTime: '2025-07-27T11:10:53Z'
      status: 'True'
      type: Running
  flowCRC: 1378932198
  lastTimeStatusNotified: '2025-07-27T11:10:53Z'
  observedGeneration: 5
  platform:
    name: sonataflow-platform
    namespace: sonataflow-infra
  services:
    dataIndexRef:
      url: 'http://sonataflow-platform-data-index-service.sonataflow-infra'
    jobServiceRef:
      url: 'http://sonataflow-platform-jobs-service.sonataflow-infra'
