cloudfoundry-incubator / spiff

declarative BOSH deployment manifest builder
Apache License 2.0
64 stars 44 forks source link

Spiff removes quotes #66

Closed axelaris closed 9 years ago

axelaris commented 9 years ago

I've tried to use spiff to generate deploy manifest for RabbitMQ server. And I was unpleasantly surprised with it's automatic removing quotes feature. Please check:

$ cat rabbit.yml 
  rabbitmq:
    user: "rabbit"
    password: "with space"
    exchange: "amq.direct"
    host: "192.168.1.1"

$ spiff m rabbit.yml 
rabbitmq:
  exchange: amq.direct
  host: 192.168.1.1
  password: with space
  user: rabbit

Please note, that some services like RabbitMQ requires to use quotes with values containing characters like spaces or dots. So now I can't use Spiff to generate manifests for RabitMQ. Is there any way to prevent Spiff to remove quotes? Why it's does it at all?

cf-gitbot commented 9 years ago

We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/101205756.

vito commented 9 years ago

Both forms are the exact same thing as far as YAML is concerned. If you want actual quotes in the value you'll need to wrap it twice, e.g. "\"foo bar\"".

On Thu, Aug 13, 2015, 7:05 AM cf-gitbot notifications@github.com wrote:

We have created an issue in Pivotal Tracker to manage this. You can view the current status of your issue at: https://www.pivotaltracker.com/story/show/101205756.

— Reply to this email directly or view it on GitHub https://github.com/cloudfoundry-incubator/spiff/issues/66#issuecomment-130685481 .

Amit-PivotalLabs commented 9 years ago

@vito is correct.

@axelaris can you explain why you need quotes there? The two are equivalent in terms of YAML, BOSH will interpret the two manifests identically. Are you seeing actual issues where this is not the case?

axelaris commented 9 years ago

Thank you for feedback, guys, but your solution with double quotes does not work :-( Here is my stub file:

  rabbitmq:
    exchange: "\"amq.direct\""

Here is final YML file, rendered by Spiff:

  rabbitmq:
    exchange: '"amq.direct"'

And here is config that I found on the instance, after BOSH deploy:

        rabbitmq {
                exchange => ""amq.direct""

As you can see, finally we have double quotes instead of single, and of course service is failed to start:

Error: Expected one of #, {, } at line 19, column 17 (byte 167) after output {

    rabbitmq {
        exchange => ""

Regarding your question why I need quotes at all. When I do not use quotes, service is failed to start, because value contain a dot:

Error: Expected one of #, {, } at line 11, column 26 (byte 170) after input {

    rabbitmq {        
          exchange => amq

I've put quotes in the stub file:

  rabbitmq:
    exchange: "amq.direct"

But spiff removes it:

  rabbitmq:
    exchange: amq.direct
vito commented 9 years ago

Doubling up the quotes looks like it worked, and now it's the job templates that are blowing up. They're probably just doing something like "<%= p("foo") %>" which blows up when foo has quotes in it. If that were instead <%= p("foo").inspect %> it should work. You may get future weirdness as you're interpolating Ruby strings into some other config format, so the escape sequences may be different, but it probably won't matter.

axelaris commented 9 years ago

Thank you, @vito ! Appreciate your help. Issue is fixed, case closed.