github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/collect-service-endpoints.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/collect-service-endpoints.cue
     3  apiVersion: core.oam.dev/v1beta1
     4  kind: WorkflowStepDefinition
     5  metadata:
     6    annotations:
     7      custom.definition.oam.dev/category: Application Delivery
     8      definition.oam.dev/description: Collect service endpoints for the application.
     9    name: collect-service-endpoints
    10    namespace: {{ include "systemDefinitionNamespace" . }}
    11  spec:
    12    schematic:
    13      cue:
    14        template: |
    15          import (
    16          	"vela/op"
    17          	"vela/ql"
    18          	"strconv"
    19          )
    20  
    21          collect: ql.#CollectServiceEndpoints & {
    22          	app: {
    23          		name:      *context.name | string
    24          		namespace: *context.namespace | string
    25          		if parameter.name != _|_ {
    26          			name: parameter.name
    27          		}
    28          		if parameter.namespace != _|_ {
    29          			namespace: parameter.namespace
    30          		}
    31          		filter: {
    32          			if parameter.components != _|_ {
    33          				components: parameter.components
    34          			}
    35          		}
    36          	}
    37          } @step(1)
    38  
    39          outputs: {
    40          	eps_port_name_filtered: *[] | [...]
    41          	if parameter.portName == _|_ {
    42          		eps_port_name_filtered: collect.list
    43          	}
    44          	if parameter.portName != _|_ {
    45          		eps_port_name_filtered: [ for ep in collect.list if parameter.portName == ep.endpoint.portName {ep}]
    46          	}
    47  
    48          	eps_port_filtered: *[] | [...]
    49          	if parameter.port == _|_ {
    50          		eps_port_filtered: eps_port_name_filtered
    51          	}
    52          	if parameter.port != _|_ {
    53          		eps_port_filtered: [ for ep in eps_port_name_filtered if parameter.port == ep.endpoint.port {ep}]
    54          	}
    55          	eps:       eps_port_filtered
    56          	endpoints: *[] | [...]
    57          	if parameter.outer != _|_ {
    58          		tmps: [ for ep in eps {
    59          			ep
    60          			if ep.endpoint.inner == _|_ {
    61          				outer: true
    62          			}
    63          			if ep.endpoint.inner != _|_ {
    64          				outer: !ep.endpoint.inner
    65          			}
    66          		}]
    67          		endpoints: [ for ep in tmps if (!parameter.outer || ep.outer) {ep}]
    68          	}
    69          	if parameter.outer == _|_ {
    70          		endpoints: eps_port_filtered
    71          	}
    72          }
    73  
    74          wait: op.#ConditionalWait & {
    75          	continue: len(outputs.endpoints) > 0
    76          } @step(2)
    77  
    78          value: {
    79          	if len(outputs.endpoints) > 0 {
    80          		endpoint: outputs.endpoints[0].endpoint
    81          		_portStr: strconv.FormatInt(endpoint.port, 10)
    82          		url:      "\(parameter.protocal)://\(endpoint.host):\(_portStr)"
    83          	}
    84          }
    85  
    86          parameter: {
    87          	// +usage=Specify the name of the application
    88          	name?: string
    89          	// +usage=Specify the namespace of the application
    90          	namespace?: string
    91          	// +usage=Filter the component of the endpoints
    92          	components?: [...string]
    93          	// +usage=Filter the port of the endpoints
    94          	port?: int
    95          	// +usage=Filter the port name of the endpoints
    96          	portName?: string
    97          	// +usage=Filter the endpoint that are only outer
    98          	outer?: bool
    99          	// +usage=The protocal of endpoint url
   100          	protocal: *"http" | "https"
   101          }
   102