diff --git a/src/aosm/HISTORY.rst b/src/aosm/HISTORY.rst index 91498640b94..bfc6662f618 100644 --- a/src/aosm/HISTORY.rst +++ b/src/aosm/HISTORY.rst @@ -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 ++++++ diff --git a/src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py b/src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py index d1cd1be1620..3a8a688ee46 100644 --- a/src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py +++ b/src/aosm/azext_aosm/generate_nfd/cnf_nfd_generator.py @@ -59,7 +59,7 @@ class NFApplicationConfiguration: dependsOnProfile: List[str] registryValuesPaths: List[str] imagePullSecretsValuesPaths: List[str] - valueMappingsPath: Path + valueMappingsFile: str @dataclass @@ -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, ) @@ -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 @@ -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 @@ -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" diff --git a/src/aosm/azext_aosm/generate_nfd/templates/cnfdefinition.bicep.j2 b/src/aosm/azext_aosm/generate_nfd/templates/cnfdefinition.bicep.j2 index 493630937bc..8396447065a 100644 --- a/src/aosm/azext_aosm/generate_nfd/templates/cnfdefinition.bicep.j2 +++ b/src/aosm/azext_aosm/generate_nfd/templates/cnfdefinition.bicep.j2 @@ -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' @@ -65,7 +68,7 @@ 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 }}')) } } } @@ -73,4 +76,4 @@ resource nfdv 'Microsoft.Hybridnetwork/publishers/networkfunctiondefinitiongroup ] } } -} \ No newline at end of file +}