geofffranks / spruce

A BOSH template merge tool
MIT License
433 stars 78 forks source link

Cartesian product with a space #329

Closed tamanna2702 closed 4 years ago

tamanna2702 commented 4 years ago

I am trying the below as I need a space just after the colon:


---
meta:
  hosts:
    - a.example.com
    - b.example.com
    - c.example.com
  port: 8088

hosts: (( cartesian-product meta.hosts ":" " " meta.port ))

But Spruce seems to add single quotes to the results:

hosts:

Also, I tried the below :


---
meta:
  hosts:
    - a.example.com
    - b.example.com
    - c.example.com
  port: 8088

hosts: (( cartesian-product meta.hosts ": " meta.port ))

But I get the below error:

file1.yml: unmarshal []byte to yaml failed: yaml: line 8: mapping values are not → allowed in this context

geofffranks commented 4 years ago

This is intended. Cartesian product outputs a string, which in the context you’re generating requires quoting in the yaml file to remain a string, otherwise the output would be a list of yaml objects rather than strings, due to the colon-spca syntax you’re generating

Sent from my iPhone

On Jun 9, 2020, at 12:25 PM, TAnna notifications@github.com wrote:

 I am trying the below as I need a space just after the colon:


meta: hosts:

  • a.example.com
  • b.example.com
  • c.example.com port: 8088

hosts: (( cartesian-product meta.hosts ":" " " meta.port )) But Spruce seems to add single quotes to the results:

hosts:

'a.example.com: 8088' 'b.example.com: 8088' 'c.example.com: 8088' Also, I tried the below :


meta: hosts:

  • a.example.com
  • b.example.com
  • c.example.com port: 8088

hosts: (( cartesian-product meta.hosts ": " meta.port )) But I get the below error:

file1.yml: unmarshal []byte to yaml failed: yaml: line 8: mapping values are not → allowed in this context

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

tamanna2702 commented 4 years ago

In my use case, I do need a list of yaml objects using the cartesian product. That is why I need the space. Do you reckon this can be done somehow?

geofffranks commented 4 years ago

I don't believe there is anything that does this in spruce currently. This seems like it's a request identical to #212, so I'm going to close this as a duplicate, but if you want to submit a PR to enable this, it will be more than welcome 😄