-
Notifications
You must be signed in to change notification settings - Fork 3.3k
{Release} Hotfix: TS Multiline String Support for Template Inputs #15760
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
{Release} Hotfix: TS Multiline String Support for Template Inputs #15760
Conversation
|
TS Multiline String Support |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
May I ask if there is a requirement in the design for template spec that it cannot be modified on the client side, but should be sent directly to the service side? |
@zhoxing-ms There is no requirement for this in Template Spec; template specs takes in a valid json object. |
| template_content = read_file_content(abs_local_path) | ||
| sanitized_template = _remove_comments_from_json(template_content) | ||
| template_json = json.loads(json.dumps(sanitized_template)) | ||
| template_json = json.loads(json.dumps(process_template(template_content))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
json.loads(json.dumps(
Why serialize and then deserialize the object from process_template() ? The data returned by process_template has been deserialized~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data returned by process_template is a ordered dictionary due to shell_safe_json_parse, the template_json needs to be a json object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
Juliehzl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add test for the scenario?
| displayName: 'Use Python 3' | ||
| inputs: | ||
| versionSpec: 3.x | ||
| versionSpec: 3.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could revert this file as this PR #15804 has fixed the build issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or merge from release to get a clear branch history.
Description
Customer reported template specs issue (Azure/template-specs#37) where the contents of multiline strings were replaced with #Azure CLI#. This was the result of the _remove_comments_from_json function used to process the template input. This function is typically used in deployments for processing template inputs; multiline strings are processed to prompt for parameters. The full functionality is not needed for creating a template spec from a template input therefore the function has been replaced by process_template_spec in _packing_engine.py.
Example:
Template Input:
{
"variables": {
"myVar": "[if(equals(parameters('kind'), ''),
variables('resources')[variables('provider')][variables('resourceType')],
variables('resources')[variables('provider')][variables('resourceType')][parameters('kind')]))]"
}
}
Template Specs Created:
{
"variables": {
"myVar": "#Azure Cli#"
}
}
Testing Guide
az ts create -g resource_group --name Issue37 -v 1.0 -l westus --template-file original.json
--> Multiline strings starting on lines 2644, 2657, and 2661 should not be replaced by "#Azure CLI#"
-->Can compare template spec created with postTsCreation.json (showcases issue).
Issue37Templates.zip