@@ -130,8 +130,38 @@ class GlobalConfig:
130130 iam_host : str = ""
131131 iam_schema : str = "https"
132132
133+ @dataclass
134+ class Defaults :
135+ launch_type : Optional [str ] = None
136+ preflight_mode : Optional [str ] = None
137+ cr_public_endpoint_check : Optional [bool ] = None
138+ iam_role_policies : Optional [list ] = None
139+
140+ def to_dict (self ):
141+ data = {}
142+ if self .launch_type :
143+ data ["launch_type" ] = self .launch_type
144+ if self .preflight_mode :
145+ data ["preflight_mode" ] = self .preflight_mode
146+ if self .cr_public_endpoint_check is not None :
147+ data ["cr_public_endpoint_check" ] = self .cr_public_endpoint_check
148+ if self .iam_role_policies is not None :
149+ data ["iam_role_policies" ] = self .iam_role_policies
150+ return data
151+
152+ @classmethod
153+ def from_dict (cls , data : dict ):
154+ return cls (
155+ launch_type = data .get ("launch_type" ),
156+ preflight_mode = data .get ("preflight_mode" ),
157+ cr_public_endpoint_check = data .get ("cr_public_endpoint_check" ),
158+ iam_role_policies = data .get ("iam_role_policies" ),
159+ )
160+
161+ defaults : 'GlobalConfig.Defaults' = field (default_factory = lambda : GlobalConfig .Defaults ())
162+
133163 def to_dict (self ):
134- return {
164+ base = {
135165 "volcengine" : self .volcengine .to_dict (),
136166 "cr" : self .cr .to_dict (),
137167 "tos" : self .tos .to_dict (),
@@ -144,6 +174,10 @@ def to_dict(self):
144174 "schema" : self .iam_schema ,
145175 },
146176 }
177+ defaults_dict = self .defaults .to_dict ()
178+ if defaults_dict :
179+ base ["defaults" ] = defaults_dict
180+ return base
147181
148182 @classmethod
149183 def from_dict (cls , data : dict ):
@@ -155,6 +189,7 @@ def from_dict(cls, data: dict):
155189 agentkit_schema = (data .get ("agentkit" , {}) or {}).get ("schema" , "https" ),
156190 iam_host = (data .get ("iam" , {}) or {}).get ("host" , "" ),
157191 iam_schema = (data .get ("iam" , {}) or {}).get ("schema" , "https" ),
192+ defaults = GlobalConfig .Defaults .from_dict (data .get ("defaults" , {}) or {}),
158193 )
159194
160195
@@ -361,6 +396,16 @@ def apply_global_config_defaults(
361396 'tos_region' : ('tos' , 'region' ),
362397 })
363398
399+ # Region fields (cloud/hybrid) inherit from global volcengine.region when project missing
400+ if isinstance (config_obj , (HybridStrategyConfig , CloudStrategyConfig )):
401+ field_mappings .update ({
402+ 'region' : ('volcengine' , 'region' ),
403+ })
404+ if isinstance (config_obj , CloudStrategyConfig ):
405+ field_mappings .update ({
406+ 'cr_region' : ('volcengine' , 'region' ),
407+ })
408+
364409 # Apply global config values
365410 for field_name , (section , attr ) in field_mappings .items ():
366411 # Skip if the target field does not exist on the config object
0 commit comments