Skip to content
Open
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
50 changes: 49 additions & 1 deletion scripts/build_env/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import argparse
import os
import pathlib

import ansible_runner
from envgenehelper import *
Expand Down Expand Up @@ -378,7 +380,53 @@ def validate_appregdefs(render_dir, env_name):
print(f"[INFO] No RegDef YAMLs found in {regdef_dir}")
for file in regdef_files:
print(f"[VALIDATING] RegDef file: {file}")
validate_yaml_by_scheme_or_fail(file, "schemas/regdef.schema.json")

# Detect version and use appropriate schema
regdef_content = openYaml(file)
version = str(regdef_content.get('version', '1.0'))

if version != '1.0':
schema_path = "schemas/regdef-v2.schema.json"
print(
f" Using RegDef V2 schema for {os.path.basename(file)} "
f"(version: {version})"
)
# Validate authConfig references for V2
validate_regdef_v2_authconfig(regdef_content, file)
else:
schema_path = "schemas/regdef.schema.json"
print(f" Using RegDef V1 schema for {os.path.basename(file)}")

validate_yaml_by_scheme_or_fail(file, schema_path)


def validate_regdef_v2_authconfig(regdef_content, file_path):
"""Validate authConfig references in V2 RegDefs"""
auth_configs = regdef_content.get('authConfig', {})

# Config sections that may reference authConfig
config_sections = [
'mavenConfig',
'dockerConfig',
'goConfig',
'rawConfig',
'npmConfig',
'helmConfig',
'helmAppConfig',
]

for config_type in config_sections:
if config_type in regdef_content:
config = regdef_content[config_type]
if isinstance(config, dict) and 'authConfig' in config:
auth_ref = config['authConfig']
if auth_ref not in auth_configs:
raise ValueError(
f"RegDef {os.path.basename(file_path)}: "
f"authConfig reference '{auth_ref}' in {config_type} "
f"not found in authConfig section. "
f"Available authConfigs: {list(auth_configs.keys())}"
)


def render_environment(env_name, cluster_name, templates_dir, all_instances_dir, output_dir, g_template_version,
Expand Down
Loading