-
Notifications
You must be signed in to change notification settings - Fork 39
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
Cannot use array parameter #214
Comments
To understand this better, in your GitHub workflow, this section:
This is essentially going to be directly added to the underlying AzCli command:
The
The value of
So the result is that the underlying AzCli command is going to be something like:
Because there are no quotes around the parameter, it's going to be interpreted as:
|
Here is what I would try based on my above understanding: Setting:
Using:
The double quotes in the "set" command will be consumed, so the underlying variable will not contain them. This means I need to explicitly add them back in the "using" block, to ensure the full JSON string is interpreted as the parameter value. I picked single quotes for the inner JSON because AzCli understands them, and it avoids having to worry about escaping. |
Works a treat. Thank you! |
(Similar to other open issues, but maybe I can describe this a little better)
If I try:
gh variable set IPLIST --env dev --body '{[ ["Somewhere", "xx.yy.zz.xx"], ["Somewhere else", "xx.yy.zz.xx"] ]}'
What is logged:
ipList={[ ["Somewhere", "xx.yy.zz.xx"], ["Somewhere else", "xx.yy.zz.xx"] ]}
This should work:
gh variable set IPLIST --env dev --body '[ ["Somewhere", "xx.yy.zz.xx"], ["Somewhere else", "xx.yy.zz.xx"] ]'
ipList=[ ["Somewhere", "xx.yy.zz.xx"], ["Somewhere else", "xx.yy.zz.xx"] ]
Try with a surrounding quote:
gh variable set IPLIST --env dev --body '''[ ["Somewhere", "xx.yy.zz.xx"], ["Somewhere else", "xx.yy.zz.xx"] ]'''
ipList='[ ["Somewhere", "xx.yy.zz.xx"], ["Somewhere else", "xx.yy.zz.xx"] ]'
The json parameter files look promising. Try putting that into a string:
gh variable set IPLIST --env dev --body '{"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": {"iplist": { "value": [["", ""] ]}}}'
What follows is what is passed on to the action. Notice that $schema is still inside double quotes:
ipList={"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": {"iplist": { "value": [["", ""] ]}}}
Escape the quotes?
ipList={\"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#\", \"contentVersion\": \"1.0.0.0\", \"parameters\": {\"iplist\": { \"value\": [[\"\", \"\"] ]}}}
So now it is randomly dropping characters from the input. The parser needs work.
The "json parameter file as a string" approach is just desperation on my part. I am definitively barking up the wrong tree. A workaround would be to have separate json parameter files for each environment, but cannot use that approach with secrets.
The text was updated successfully, but these errors were encountered: