Skip to content

Commit 8c65959

Browse files
committed
feat: Support Registry V2
- Add RegDef V2 fields and structures - Wire Registry V2 support into envgene - Fix V2 import/formatting issues - Keep existing Registry V1 behavior backward compatible
1 parent 08c7489 commit 8c65959

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

scripts/build_env/main.py

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import argparse
2+
import os
3+
import pathlib
24

35
from envgenehelper import *
46
from envgenehelper.deployer import *
@@ -280,8 +282,54 @@ def validate_appregdefs(render_dir, env_name):
280282
if not regdef_files:
281283
logger.info(f"No RegDef YAMLs found in {regdef_dir}")
282284
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+
)
285333

286334

287335
def render_environment(env_name, cluster_name, templates_dir, all_instances_dir, output_dir, g_template_version,

0 commit comments

Comments
 (0)