github.com/oam-dev/kubevela@v1.9.11/vela-templates/definitions/internal/workflowstep/read-object.cue (about)

     1  import (
     2  	"vela/op"
     3  )
     4  
     5  "read-object": {
     6  	type: "workflow-step"
     7  	annotations: {
     8  		"category": "Resource Management"
     9  	}
    10  	description: "Read Kubernetes objects from cluster for your workflow steps"
    11  }
    12  template: {
    13  	output: {
    14  		if parameter.apiVersion == _|_ && parameter.kind == _|_ {
    15  			op.#Read & {
    16  				value: {
    17  					apiVersion: "core.oam.dev/v1beta1"
    18  					kind:       "Application"
    19  					metadata: {
    20  						name: parameter.name
    21  						if parameter.namespace != _|_ {
    22  							namespace: parameter.namespace
    23  						}
    24  					}
    25  				}
    26  				cluster: parameter.cluster
    27  			}
    28  		}
    29  		if parameter.apiVersion != _|_ || parameter.kind != _|_ {
    30  			op.#Read & {
    31  				value: {
    32  					apiVersion: parameter.apiVersion
    33  					kind:       parameter.kind
    34  					metadata: {
    35  						name: parameter.name
    36  						if parameter.namespace != _|_ {
    37  							namespace: parameter.namespace
    38  						}
    39  					}
    40  				}
    41  				cluster: parameter.cluster
    42  			}
    43  		}
    44  	}
    45  	parameter: {
    46  		// +usage=Specify the apiVersion of the object, defaults to 'core.oam.dev/v1beta1'
    47  		apiVersion?: string
    48  		// +usage=Specify the kind of the object, defaults to Application
    49  		kind?: string
    50  		// +usage=Specify the name of the object
    51  		name: string
    52  		// +usage=The namespace of the resource you want to read
    53  		namespace?: *"default" | string
    54  		// +usage=The cluster you want to apply the resource to, default is the current control plane cluster
    55  		cluster: *"" | string
    56  	}
    57  }