-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal/Feature Request: Enable comments and full language support for ARM templates #8937
Comments
I think I would rather do this change just for ARM templates somewhere around here:
or Note: get_file_json() uses shell_safe_json_parse() internally. So I think I would make change for ARM templates first, or just modify get_file_json to support loading json from both files and uris. |
Thanks for the reply, I've not got any scope to pick this up currently as I'm on a different project. Happy for anyone else to tackle this or I might try and loop back round at some point in the future. |
Some further investigation: (1) It seems like commentjson has some issues, I have submitted a bug report here: Basically it won't be able to parse following line as it interpret # as comment:
It will return an error, as it thinks there's comment in the line above. (2) secondly removing ARM specific parts -- "[ … ]" -- is not going to help when loading json from local files, as we would have to somehow reinsert them into template after parsing. (there's some magic going on). Instead I am going to modify shell_safe_json_parse to:
|
Is your feature request related to a problem?
Currently the following template will fail to deploy via the CLI but will succeed if sent directly to the
ARM
API endpoints.https://github.com/opencb/opencga/blob/0d4c942d71894a16aa30b498ecb2c77318449cd8/opencga-app/app/scripts/azure/arm/daemonvm/azuredeploy.jsonc
There are 2 reasons for this failure.
JSON
contains commentsARM
language aren't validJSON
but ARE validARM
templates.For example, the following is valid
ARM
but not validJSON
as the value splits over multiple lines.When submitted to the
ARM
endpoint the content of"[ here including multi-line ]"
is processed by theARM
language then re-inserted into the template.Describe the solution you'd like
In Powershell this is handled correctly and when talking to the
ARM
team they mentioned there is a desire to unify the approaches to give consistency.Looking at the code in the CLI I'd like to submit a PR moving the
ARM
template code to using commentsjson to allow the processing of theJSON
files correctly.So I'd update the utils function here to use
commentjson
(for this change to be handled in all resource not just ARM) or just update the ARM specific code.Then have a simple regex (sudo code) function which would strip out the
ARM
specific lines before using theutils
loader. This would allow theJSON
to be validated but not trip it up onARM
language elements. Then once theJSON
is validated re-insert theARM
language chunks before sending to theARM API
.** Why would we want these? **
ARM templates become seriously large for big deployments. Being able to comment and split inputs over multiple lines makes the difference between usable and big ball of mess.
For example see: (hint scroll right on the first one)
vs
Describe alternatives you've considered
For comments in the
JSON
it's possible to use a pre-processing step and I considered this but for theARM
language components this doesn't work as easily and very much feels like it should be supported in the built in tooking.Additional context
I've been in conversation with @alex-frankel and @bmoore-msft regarding the approach to this issue.
The text was updated successfully, but these errors were encountered: