|
1 | 1 | import argparse |
| 2 | +import os |
| 3 | +import pathlib |
2 | 4 |
|
3 | 5 | from envgenehelper import * |
4 | 6 | from envgenehelper.deployer import * |
@@ -280,8 +282,54 @@ def validate_appregdefs(render_dir, env_name): |
280 | 282 | if not regdef_files: |
281 | 283 | logger.info(f"No RegDef YAMLs found in {regdef_dir}") |
282 | 284 | for file in regdef_files: |
283 | | - logger.info(f"RegDef file: {file}") |
284 | | - validate_yaml_by_scheme_or_fail(file, "schemas/regdef.schema.json") |
| 285 | + print(f"[VALIDATING] RegDef file: {file}") |
| 286 | + |
| 287 | + # Detect version and use appropriate schema |
| 288 | + regdef_content = openYaml(file) |
| 289 | + version = str(regdef_content.get('version', '1.0')) |
| 290 | + |
| 291 | + if version != '1.0': |
| 292 | + schema_path = "schemas/regdef-v2.schema.json" |
| 293 | + print( |
| 294 | + f" Using RegDef V2 schema for {os.path.basename(file)} " |
| 295 | + f"(version: {version})" |
| 296 | + ) |
| 297 | + # Validate authConfig references for V2 |
| 298 | + validate_regdef_v2_authconfig(regdef_content, file) |
| 299 | + else: |
| 300 | + schema_path = "schemas/regdef.schema.json" |
| 301 | + print(f" Using RegDef V1 schema for {os.path.basename(file)}") |
| 302 | + |
| 303 | + validate_yaml_by_scheme_or_fail(file, schema_path) |
| 304 | + |
| 305 | + |
| 306 | +def validate_regdef_v2_authconfig(regdef_content, file_path): |
| 307 | + """Validate authConfig references in V2 RegDefs""" |
| 308 | + auth_configs = regdef_content.get('authConfig', {}) |
| 309 | + |
| 310 | + # Config sections that may reference authConfig |
| 311 | + config_sections = [ |
| 312 | + 'mavenConfig', |
| 313 | + 'dockerConfig', |
| 314 | + 'goConfig', |
| 315 | + 'rawConfig', |
| 316 | + 'npmConfig', |
| 317 | + 'helmConfig', |
| 318 | + 'helmAppConfig', |
| 319 | + ] |
| 320 | + |
| 321 | + for config_type in config_sections: |
| 322 | + if config_type in regdef_content: |
| 323 | + config = regdef_content[config_type] |
| 324 | + if isinstance(config, dict) and 'authConfig' in config: |
| 325 | + auth_ref = config['authConfig'] |
| 326 | + if auth_ref not in auth_configs: |
| 327 | + raise ValueError( |
| 328 | + f"RegDef {os.path.basename(file_path)}: " |
| 329 | + f"authConfig reference '{auth_ref}' in {config_type} " |
| 330 | + f"not found in authConfig section. " |
| 331 | + f"Available authConfigs: {list(auth_configs.keys())}" |
| 332 | + ) |
285 | 333 |
|
286 | 334 |
|
287 | 335 | def render_environment(env_name, cluster_name, templates_dir, all_instances_dir, output_dir, g_template_version, |
|
0 commit comments