apiVersion: core.oam.dev/v1beta1
kind: WorkflowStepDefinition
metadata:
  name: create-ack
  namespace: vela-system
spec:
  schematic:
    cue:
      template: |
        import (
        	"vela/op"
        	"encoding/base64"
        )

        configuration: op.#Load & {
        	component: parameter.component
        }

        apply: op.#Apply & {
        	value: {
        		configuration.value.workload
        	}
        }

        wait: op.#ConditionalWait & {
        	continue: apply.value.status.state == "Available"
        }

        secretName:      apply.value.spec.writeConnectionSecretToRef.name
        secretNamespace: apply.value.spec.writeConnectionSecretToRef.namespace

        ackConn: op.#Read & {
        	value: {
        		apiVersion: "v1"
        		kind:       "Secret"
        		metadata: {
        			name:      secretName
        			namespace: secretNamespace
        		}
        	}
        }

        parameter: {
        	component: string
        }

        connInfo: {
        	clusterName:      base64.Decode(null, ackConn.value.data["name"])
        	clusterCACert:    base64.Decode(null, ackConn.value.data["cluster_ca_cert"])
        	clientCert:       base64.Decode(null, ackConn.value.data["client_cert"])
        	clientKey:        base64.Decode(null, ackConn.value.data["client_key"])
        	clusterAPIServer: base64.Decode(null, ackConn.value.data["api_server_internet"])
        }




