@@ -59,12 +59,26 @@ def _validate(self, data):
5959 if self .key in self .config .overrides :
6060 return data
6161
62- # next, env-var
63- if self ._env_var_name and not self .config .locked :
62+ if not self .config .locked :
63+
64+ # next, env-var
6465 value = os .getenv (self ._env_var_name )
6566 if value is not None :
6667 return self ._parse_env_var (value )
6768
69+ # next, JSON-encoded env-var
70+ varname = self ._env_var_name + "_JSON"
71+ value = os .getenv (varname )
72+ if value is not None :
73+ from rez .utils import json
74+
75+ try :
76+ return json .loads (value )
77+ except ValueError :
78+ raise ConfigurationError (
79+ "Expected $%s to be JSON-encoded string." % varname
80+ )
81+
6882 # next, data unchanged
6983 if data is not None :
7084 return data
@@ -121,9 +135,10 @@ def _parse_env_var(self, value):
121135 try :
122136 return int (value )
123137 except ValueError :
124- raise ConfigurationError ("expected %s to be an integer"
138+ raise ConfigurationError ("Expected %s to be an integer"
125139 % self ._env_var_name )
126140
141+
127142class Bool (Setting ):
128143 schema = Schema (bool )
129144 true_words = frozenset (["1" , "true" , "yes" , "y" , "on" ])
@@ -138,7 +153,7 @@ def _parse_env_var(self, value):
138153 return False
139154 else :
140155 raise ConfigurationError (
141- "expected $%s to be one of: %s"
156+ "Expected $%s to be one of: %s"
142157 % (self ._env_var_name , ", " .join (self .all_words )))
143158
144159
@@ -160,12 +175,28 @@ class Dict(Setting):
160175
161176 def _parse_env_var (self , value ):
162177 items = value .split ("," )
163- try :
164- return dict ([item .split (":" ) for item in items ])
165- except ValueError :
166- raise ConfigurationError (
167- "expected dict string in form 'k1:v1,k2:v2,...kN:vN': %s"
168- % value )
178+ result = {}
179+
180+ for item in items :
181+ if ':' not in item :
182+ raise ConfigurationError (
183+ "Expected dict string in form 'k1:v1,k2:v2,...kN:vN': %s"
184+ % value
185+ )
186+
187+ k , v = item .split (':' , 1 )
188+
189+ try :
190+ v = int (v )
191+ except ValueError :
192+ try :
193+ v = float (v )
194+ except ValueError :
195+ pass
196+
197+ result [k ] = v
198+
199+ return result
169200
170201
171202class OptionalDict (Dict ):
@@ -177,7 +208,6 @@ class OptionalDictOrDictList(Setting):
177208 schema = Or (And (None , Use (lambda x : [])),
178209 And (dict , Use (lambda x : [x ])),
179210 [dict ])
180- _env_var_name = None
181211
182212
183213class SuiteVisibility_ (Str ):
@@ -236,6 +266,7 @@ def _parse_env_var(self, value):
236266 "parent_variables" : StrList ,
237267 "resetting_variables" : StrList ,
238268 "release_hooks" : StrList ,
269+ "context_tracking_context_fields" : StrList ,
239270 "prompt_release_message" : Bool ,
240271 "critical_styles" : OptionalStrList ,
241272 "error_styles" : OptionalStrList ,
@@ -283,6 +314,7 @@ def _parse_env_var(self, value):
283314 "alias_fore" : OptionalStr ,
284315 "alias_back" : OptionalStr ,
285316 "package_preprocess_function" : OptionalStr ,
317+ "context_tracking_host" : OptionalStr ,
286318 "build_thread_count" : BuildThreadCount_ ,
287319 "resource_caching_maxsize" : Int ,
288320 "max_package_changelog_chars" : Int ,
@@ -333,6 +365,8 @@ def _parse_env_var(self, value):
333365 "variant_select_mode" : VariantSelectMode_ ,
334366 "package_filter" : OptionalDictOrDictList ,
335367 "new_session_popen_args" : OptionalDict ,
368+ "context_tracking_amqp" : OptionalDict ,
369+ "context_tracking_extra_fields" : OptionalDict ,
336370
337371 # GUI settings
338372 "use_pyside" : Bool ,
0 commit comments