boilr icon indicating copy to clipboard operation
boilr copied to clipboard

Allow multiple values for a single option

Open andrewhowdencom opened this issue 9 years ago • 4 comments

This is a feature request.

The use case is as follows: I use boilr to create various kinds of configuration files, such as configuration for Kubernetes deployments or XML configuration for Magento. In both these kinds of configuration, there's the possibility to have multiple values under a single "option". Below is an example of Volumes in Kubernetes, where you might have multiple assigned to each pod:

  role: "{{ Role | toLower }}"
    spec:
      volumes:
      # Record 1
      - name: "{{ Service | toLower }}-etc-conf-d"
        {{ VolumeType }}:
          {{ if eq VolumeType "HostVolume" }}path: /data/{{ Service | toLower }}/
          {{ else if eq VolumeType "ConfigMap"}}name: "{{ Service | toLower }}-etc-conf-d"
          {{ end }}
      # Record 2
      - name: "{{ Service | toLower }}-data"
        {{ VolumeType }}:
          {{ if eq VolumeType "HostVolume" }}path: /data/{{ Service | toLower }}/
          {{ else if eq VolumeType "ConfigMap"}}name: "{{ Service | toLower }}-etc-conf-d"
          {{ end }}

https://github.com/littlemanco/boilr-k8sdeployment/blob/master/template/50-%7B%7B%20Service%20%7C%20toLower%20%7D%7D.dep.yml#L48-L52

The ideal here would be to a foreach iteration of a set of values, such as

{ 
  "Volumes": [
    { 
      "VolumeName": "ExampleVolumeName",
      "VolumeType": [
        "HostVolume", 
        "ConfigMap"
      ]
    }
  ],
  ... // record 2, record 3, {n}
}

At the moment, I'm just commenting out stubs of the configuration that I need replicated many times, as you can see in the template above.

I'm writing this hastily as I'm waiting for a report to complete, so if it's at all unclear, please let me know. I also understand that it'd be considerable work, so you're welcome to decline the request!

Cheers,

andrewhowdencom avatar Jun 29 '16 05:06 andrewhowdencom

Thank you for the detailed request Andrew.

I was thinking about this one as well, but one problem is that JSON has limited types and we're using the list type for choices at the moment. I'll see what I can do about this one.

In the meanwhile feel free to add your boilr templates to the wiki template index, it's editable by everyone

tmrts avatar Jul 01 '16 05:07 tmrts

It just occured to me that the dictionary lists, like your example, might be the best type for the foreach iteration. But, I don't want to use implicit typing too much, however using a DSL would also be harder since everybody knows JSON. For this case I'll continue with the implicit typing

tmrts avatar Jul 01 '16 06:07 tmrts

I appreciate you taking the time to think about it. This tool has rapidly made it into my standard toolkit! It's excellent. If I had the time to contribute more, I would.

I'll add the templates I create to the wiki.

andrewhowdencom avatar Jul 02 '16 05:07 andrewhowdencom

I'm very happy to hear that you found boilr useful!

You don't have to submit PRs to contribute to boilr, even reporting the issues is of tremendous value to me, thank you :)

tmrts avatar Jul 03 '16 18:07 tmrts