Updated on 2023-08-11 GMT+08:00

concat

During template compilation, the concat function is often used. For example, you may obtain an IP address from the VM result and a listening port number from the APP result, and then print the final and intuitive HTTP access address in the output of the template.

The concat function is a built-in function and used to convert descriptions into strings and concatenate them. It can be embedded with the get_attribute and get_input functions.

In the current version, concat can only be defined in the outputs section. It cannot be defined in the node_templates section or embedded with the get_attribute function.

Syntax

concat: [args, {get_attribute:[...]}, {get_input: [...]} ]

Parameters

Table 1 Parameters

Parameter

Description

args

Any user-defined field. The value can be an integer, Boolean value, or string.

Example:

concat: ["string example", 100, -10, true, false], {get_attribute: [...]}, {get_input: [...]}

There is no sequence requirement for the preceding three parameters.

Return Value

Strings that are successfully concatenated are returned.

Examples

properties:
  package:
    image: {get_input: magento-image}
    imagePullPolicy: {get_input: imagePullPolicy}
      env:
        - name: MYSQL_HOST # Specifies where MySQL is located.
          value:
            concat:
              - {get_input: mysql-name}
              - .default.svc.cluster.local # Actual address of MySQL, which is an internal domain name of Kubernetes.
        - name: MYSQL_USER
            value: {get_input: mysql-user}
        - name: MYSQL_PASSWORD
            value: {get_input: mysql-password}
        - name: MYSQL_DATABASE
            value: {get_input: mysql-database}
        - name: ACCESS_URL
            value: 
              concat:
                - "http://"
                - {get_input: magento-EIP}
                - ":"
                - {get_input: magento-EPORT-s}