Skip to content

Commit

Permalink
Merge pull request #18 from jddarby/jl/change-value-mappings
Browse files Browse the repository at this point in the history
Move Value Mappings to Outside Helm Package
  • Loading branch information
jordlay authored Jun 2, 2023
2 parents 938b02e + 65ac401 commit 371a1ea
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/aosm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ For CNFs, you must provide helm packages with an associated schema. When filling
{
"name": "A",
"path_to_chart": "Path to package A",
"path_to_mappings": "Path to package A mappings",
"depends_on": [
"Names of the Helm packages this package depends on"
]
},
{
"name": "B",
"path_to_chart": "Path to package B",
"path_to_mappings": "Path to package B mappings",
"depends_on": [
"Names of the Helm packages this package depends on"
]
Expand Down
4 changes: 4 additions & 0 deletions src/aosm/azext_aosm/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
"path_to_chart": (
"File path of Helm Chart on local disk. Accepts .tgz, .tar or .tar.gz"
),
"path_to_mappings": (
"File path of value mappings on local disk. Accepts .yaml or .yml"
),
"helm_depends_on": (
"Names of the Helm packages this package depends on. "
"Leave as an empty array if no dependencies"
Expand Down Expand Up @@ -149,6 +152,7 @@ def build_output_folder_name(self) -> str:
class HelmPackageConfig:
name: str = DESCRIPTION_MAP["helm_package_name"]
path_to_chart: str = DESCRIPTION_MAP["path_to_chart"]
path_to_mappings: str = DESCRIPTION_MAP["path_to_mappings"]
depends_on: List[str] = field(
default_factory=lambda: [DESCRIPTION_MAP["helm_depends_on"]]
)
Expand Down
14 changes: 8 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 @@ -343,19 +343,21 @@ def get_chart_mapping_schema(

logger.debug("Get chart mapping schema for %s", helm_package.name)

non_def_values = os.path.join(
self._tmp_folder_name, helm_package.name, "values.mappings.yaml"
)
mappings_path = helm_package.path_to_mappings
values_schema = os.path.join(
self._tmp_folder_name, helm_package.name, "values.schema.json"
)

if not os.path.exists(non_def_values) or not os.path.exists(values_schema):
if not os.path.exists(mappings_path):
raise InvalidTemplateError(
f"ERROR: The helm package '{helm_package.name}' does not have a valid values mappings file. The file at '{helm_package.path_to_mappings}' does not exist.\nPlease fix this and run the command again."
)
if not os.path.exists(values_schema):
raise InvalidTemplateError(
f"ERROR: The helm package '{helm_package.name}' is missing either values.mappings.yaml or values.schema.json. Please fix this and run the command again."
f"ERROR: The helm package '{helm_package.name}' is missing values.schema.json. Please fix this and run the command again."
)

with open(non_def_values, "r", encoding="utf-8") as stream:
with open(mappings_path, "r", encoding="utf-8") as stream:
values_data = yaml.load(stream, Loader=yaml.SafeLoader)

with open(values_schema, "r", encoding="utf-8") as f:
Expand Down

0 comments on commit 371a1ea

Please sign in to comment.