Skip to content
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

Fix bicep render on Windows #57

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/aosm/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ unreleased
* Take Oras 0.1.18 so above Workaround could be removed
* Take Oras 0.1.19 to fix NSD Artifact upload on Windows
* Support deploying multiple instances of the same NF in an SNS
* Fix CNF publish on Windows by using Linux style paths in rendered NFD bicep templates (bicep always requires Linux style paths).

0.2.0
++++++
Expand Down
11 changes: 5 additions & 6 deletions src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class NFApplicationConfiguration:
dependsOnProfile: List[str]
registryValuesPaths: List[str]
imagePullSecretsValuesPaths: List[str]
valueMappingsPath: Path
valueMappingsFile: str


@dataclass
Expand Down Expand Up @@ -295,7 +295,6 @@ def _write_nfd_bicep_file(self) -> None:
)

bicep_contents: str = template.render(
deployParametersPath=Path(SCHEMAS_DIR_NAME, DEPLOYMENT_PARAMETERS_FILENAME),
nf_application_configurations=self.nf_application_configurations,
)

Expand Down Expand Up @@ -382,7 +381,7 @@ def _generate_nf_application_config(
dependsOnProfile=helm_package.depends_on,
registryValuesPaths=list(registry_values_paths),
imagePullSecretsValuesPaths=list(image_pull_secrets_values_paths),
valueMappingsPath=self._jsonify_value_mappings(helm_package),
valueMappingsFile=self._jsonify_value_mappings(helm_package),
)

@staticmethod
Expand Down Expand Up @@ -768,8 +767,8 @@ def _get_chart_name_and_version(

return (chart_name, chart_version)

def _jsonify_value_mappings(self, helm_package: HelmPackageConfig) -> Path:
"""Yaml->JSON values mapping file, then return path to it."""
def _jsonify_value_mappings(self, helm_package: HelmPackageConfig) -> str:
"""Yaml->JSON values mapping file, then return the filename."""
assert self._tmp_dir
mappings_yaml_file = helm_package.path_to_mappings
mappings_dir = self._tmp_dir / CONFIG_MAPPINGS_DIR_NAME
Expand All @@ -784,4 +783,4 @@ def _jsonify_value_mappings(self, helm_package: HelmPackageConfig) -> Path:
json.dump(data, file, indent=4)

logger.debug("Generated parameter mappings for %s", helm_package.name)
return Path(CONFIG_MAPPINGS_DIR_NAME, f"{helm_package.name}-mappings.json")
return f"{helm_package.name}-mappings.json"
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroup
properties: {
// versionState should be changed to 'Active' once it is finalized.
versionState: 'Preview'
deployParameters: string(loadJsonContent('{{ deployParametersPath }}'))
{#- Note that all paths in bicep must be specified using the forward slash #}
{#- (/) character even if running on Windows. #}
{#- See https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/modules#local-file #}
deployParameters: string(loadJsonContent('schemas/deploymentParameters.json'))
networkFunctionType: 'ContainerizedNetworkFunction'
networkFunctionTemplate: {
nfviType: 'AzureArcKubernetes'
Expand Down Expand Up @@ -65,12 +68,12 @@ resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroup
releaseNamespace: '{{ configuration.chartName }}'
releaseName: '{{ configuration.chartName }}'
helmPackageVersion: '{{ configuration.chartVersion }}'
values: string(loadJsonContent('{{ configuration.valueMappingsPath }}'))
values: string(loadJsonContent('configMappings/{{ configuration.valueMappingsFile }}'))
}
}
}
{%- endfor %}
]
}
}
}
}
Loading