Concourse CI - array variable

时间:2017-06-15 10:24:59

标签: arrays continuous-integration kubernetes concourse kubernetes-helm

I'm trying to figure out how to create an array with some CIDR ip address in order to have the same array in my pipeline. So here is an example var file:

whitelist-ip-ranges: |-
- 10.0.0.0/24
- 11.0.0.0/24
- 12.0.0.0/24

My pipeline is like:

....
....
....
params:
     variables:
        loadBalancerSourceRanges:
          {{whitelist-ip-ranges}}

And I want it to be:

....
....
....
params:
     variables:
        loadBalancerSourceRanges:
          - 10.0.0.0/24
          - 11.0.0.0/24
          - 12.0.0.0/24

or

....
....
....
params:
     variables:
        loadBalancerSourceRanges: [10.0.0.0/24,11.0.0.0/24,12.0.0.0/24]

Inside my helm template I have my values.yaml file I have of course:

loadBalancerSourceRanges: null

and it will be override by the pipeline. And finaly, in my service file I'm making a loop:

{{if .Values.loadBalancerSourceRanges}}
  loadBalancerSourceRanges:
    {{range $rangeList := .Values.loadBalancerSourceRanges}}
    - {{ $rangeList }}
    {{end}}
{{end}}

Does any of you guys was able to do something like that?

1 个答案:

答案 0 :(得分:3)

对不起,我不能以helm为基础说话。不过,我可以代表一个大厅管道。

Concourse不支持向作为数组的任务提供paramsparams作为环境变量传递给正在运行的任务,因此它们从YAML转换为简单的字符串键值对。

如果您想传递更复杂的信息。有两种选择:

  • 将param编码为JSON / YAML,以便可以从任务环境中将其解析为字符串
  • 从资源中提供输入,其中可以提供文件 - 例如,具有loadBalanceSourceRanges
  • 内容的s3资源

这些编程方式是我之前用于完成将更复杂的数据(即数组)传递给任务的示例。