github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/ref-objects.yaml (about)

     1  # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
     2  # Definition source cue file: vela-templates/definitions/internal/ref-objects.cue
     3  apiVersion: core.oam.dev/v1beta1
     4  kind: ComponentDefinition
     5  metadata:
     6    annotations:
     7      definition.oam.dev/description: Ref-objects allow users to specify ref objects to use. Notice that this component type have special handle logic.
     8    labels:
     9      custom.definition.oam.dev/ui-hidden: "true"
    10    name: ref-objects
    11    namespace: {{ include "systemDefinitionNamespace" . }}
    12  spec:
    13    schematic:
    14      cue:
    15        template: |
    16          #K8sObject: {
    17          	// +usage=The resource type for the Kubernetes objects
    18          	resource?: string
    19          	// +usage=The group name for the Kubernetes objects
    20          	group?: string
    21          	// +usage=If specified, fetch the Kubernetes objects with the name, exclusive to labelSelector
    22          	name?: string
    23          	// +usage=If specified, fetch the Kubernetes objects from the namespace. Otherwise, fetch from the application's namespace.
    24          	namespace?: string
    25          	// +usage=If specified, fetch the Kubernetes objects from the cluster. Otherwise, fetch from the local cluster.
    26          	cluster?: string
    27          	// +usage=If specified, fetch the Kubernetes objects according to the label selector, exclusive to name
    28          	labelSelector?: [string]: string
    29          	...
    30          }
    31  
    32          output: {
    33          	if len(parameter.objects) > 0 {
    34          		parameter.objects[0]
    35          	}
    36          	...
    37          }
    38  
    39          outputs: {
    40          	for i, v in parameter.objects {
    41          		if i > 0 {
    42          			"objects-\(i)": v
    43          		}
    44          	}
    45          }
    46          parameter: {
    47          	// +usage=If specified, application will fetch native Kubernetes objects according to the object description
    48          	objects?: [...#K8sObject]
    49          	// +usage=If specified, the objects in the urls will be loaded.
    50          	urls?: [...string]
    51          }
    52    status:
    53      customStatus: |-
    54        if context.output.apiVersion == "apps/v1" && context.output.kind == "Deployment" {
    55        	ready: {
    56        		readyReplicas: *0 | int
    57        	} & {
    58        		if context.output.status.readyReplicas != _|_ {
    59        			readyReplicas: context.output.status.readyReplicas
    60        		}
    61        	}
    62        	message: "Ready:\(ready.readyReplicas)/\(context.output.spec.replicas)"
    63        }
    64        if context.output.apiVersion != "apps/v1" || context.output.kind != "Deployment" {
    65        	message: ""
    66        }
    67      healthPolicy: |-
    68        if context.output.apiVersion == "apps/v1" && context.output.kind == "Deployment" {
    69        	ready: {
    70        		updatedReplicas:    *0 | int
    71        		readyReplicas:      *0 | int
    72        		replicas:           *0 | int
    73        		observedGeneration: *0 | int
    74        	} & {
    75        		if context.output.status.updatedReplicas != _|_ {
    76        			updatedReplicas: context.output.status.updatedReplicas
    77        		}
    78        		if context.output.status.readyReplicas != _|_ {
    79        			readyReplicas: context.output.status.readyReplicas
    80        		}
    81        		if context.output.status.replicas != _|_ {
    82        			replicas: context.output.status.replicas
    83        		}
    84        		if context.output.status.observedGeneration != _|_ {
    85        			observedGeneration: context.output.status.observedGeneration
    86        		}
    87        	}
    88        	isHealth: (context.output.spec.replicas == ready.readyReplicas) && (context.output.spec.replicas == ready.updatedReplicas) && (context.output.spec.replicas == ready.replicas) && (ready.observedGeneration == context.output.metadata.generation || ready.observedGeneration > context.output.metadata.generation)
    89        }
    90        if context.output.apiVersion != "apps/v1" || context.output.kind != "Deployment" {
    91        	isHealth: true
    92        }
    93    workload:
    94      type: autodetects.core.oam.dev
    95