happytal / substitute-variables

Azure DevOps task for substituting variables in plain JSON and YAML files
MIT License
1 stars 0 forks source link

Unexpected edits to yaml file #2

Closed JChaneyGuardian closed 3 years ago

JChaneyGuardian commented 3 years ago

I was trying to use the AzureDev Ops task to update some yaml files for mule. Mule requires all yaml properties to be strings. The task replaced the values but removed the double quotes I had around the values it replaced. The lines that were not replace it changed the double-quotes to single quotes. example:

before ----

server:
     host: ""
     port: "443"

variables--- server.host = "myserver.com"

after -----

server:
     host: myserver.com
     port: '443'
fhervieux commented 3 years ago

The task rewrites yaml files entirely so it is expected that even properties not replaced can be printed differently as long as they keep their initial type. In your exemple, myserver.com is not quoted because it is interpreted as a string, whereas 443 is quoted because without quotes its type would change from string to number. Single quotes instead of double quotes are an arbitrary choice but it does not change how the value should be interpreted.

A parser compliant with standard yaml should give you the expected result when parsing the output of your example (i.e. both host and port are strings). I am not familiar with Mule and I did not find any reference to this issue in their documentation. Maybe they have additional requirements regarding the content of the yaml file. Do you know if quotes are mandatory on all strings? Do they need to be double quotes?

JChaneyGuardian commented 3 years ago

You are right. This was just an example of my inexperience with Yaml. Mule does require every property to be a string, but, as you said it's only the values that are digits that need to be quoted.

I did some testing this morning and I was able to safely remove the double quotes from my string values, and change my numeric values to be single quoted.

Sorry for the confusion.

Thanks,