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

Move Value Mappings to Outside Helm Package #18

Merged
merged 2 commits into from
Jun 2, 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
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