# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/depends-on-app.cue
apiVersion: core.oam.dev/v1beta1
kind: WorkflowStepDefinition
metadata:
  annotations:
    definition.oam.dev/description: Wait for the specified Application to complete.
  name: depends-on-app
  namespace: {{ include "systemDefinitionNamespace" . }}
spec:
  schematic:
    cue:
      template: |
        import (
        	"vela/op"
        	"encoding/yaml"
        )

        dependsOn: op.#Read & {
        	value: {
        		apiVersion: "core.oam.dev/v1beta1"
        		kind:       "Application"
        		metadata: {
        			name:      parameter.name
        			namespace: parameter.namespace
        		}
        	}
        }
        load: op.#Steps & {
        	if dependsOn.err != _|_ {
        		configMap: op.#Read & {
        			value: {
        				apiVersion: "v1"
        				kind:       "ConfigMap"
        				metadata: {
        					name:      parameter.name
        					namespace: parameter.namespace
        				}
        			}
        		}         @step(1)
        		template: configMap.value.data["application"]
        		apply:    op.#Apply & {
        			value: yaml.Unmarshal(template)
        		}     @step(2)
        		wait: op.#ConditionalWait & {
        			continue: apply.value.status.status == "running"
        		} @step(3)
        	}

        	if dependsOn.err == _|_ {
        		wait: op.#ConditionalWait & {
        			continue: dependsOn.value.status.status == "running"
        		}
        	}
        }
        parameter: {
        	// +usage=Specify the name of the dependent Application
        	name: string
        	// +usage=Specify the namespace of the dependent Application
        	namespace: string
        }

