Concourse CI - array variable

6/15/2017

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?

-- Lord-Y
arrays
concourse
continuous-integration
kubernetes
kubernetes-helm

1 Answer

7/11/2017

I'm sorry, I cannot speak to anything helm based. I can speak for a concourse pipeline, though.

Concourse does not support providing params to tasks that are an array. params are passed in as environment variables to a running task, so they are transformed from YAML to a simple string key-value pair.

If you want to pass more complex information. There are two options:

  • encode the param as JSON/YAML so that it can be parsed as string from your tasks environment
  • provide the task an input from a resource, where a file can be provided -- for example an s3 resource with the contents of the loadBalanceSourceRanges

These programmatic ways are examples I've used before to accomplish passing more complex data (ie arrays) to a task.

-- jtarchie
Source: StackOverflow