99
1010from helm_values_manager .models .config_metadata import ConfigMetadata
1111from helm_values_manager .models .value import Value
12- from helm_values_manager .utils .logger import logger
12+ from helm_values_manager .utils .logger import HelmLogger
1313
1414
1515class PathData :
@@ -20,8 +20,8 @@ def __init__(self, path: str, metadata: Dict[str, Any]):
2020 Initialize PathData with a path and metadata.
2121
2222 Args:
23- path: The configuration path
24- metadata: Dictionary containing metadata fields
23+ path: The configuration path (e.g., "app.replicas")
24+ metadata: Dictionary containing metadata for the path
2525 """
2626 self .path = path
2727 self ._metadata = ConfigMetadata (
@@ -30,6 +30,7 @@ def __init__(self, path: str, metadata: Dict[str, Any]):
3030 sensitive = metadata .get ("sensitive" , False ),
3131 )
3232 self ._values : Dict [str , Value ] = {}
33+ HelmLogger .debug ("Created PathData instance for path %s" , path )
3334
3435 def validate (self ) -> None :
3536 """
@@ -42,20 +43,20 @@ def validate(self) -> None:
4243 Raises:
4344 ValueError: If validation fails
4445 """
45- logger .debug ("Validating PathData for path: %s" , self .path )
46+ HelmLogger .debug ("Validating PathData for path: %s" , self .path )
4647
4748 # Validate path consistency and required values
4849 for env , value in self ._values .items ():
4950 # Check path consistency
5051 if value .path != self .path :
51- logger .error ("Path mismatch for environment %s: %s != %s" , env , value .path , self .path )
52+ HelmLogger .error ("Path mismatch for environment %s: %s != %s" , env , value .path , self .path )
5253 raise ValueError (f"Value for environment { env } has inconsistent path: { value .path } != { self .path } " )
5354
5455 # Check required values
5556 if self ._metadata .required :
5657 val = value .get ()
5758 if val is None or val == "" :
58- logger .error ("Missing required value for path %s in environment %s" , self .path , env )
59+ HelmLogger .error ("Missing required value for path %s in environment %s" , self .path , env )
5960 raise ValueError (f"Missing required value for path { self .path } in environment { env } " )
6061
6162 def set_value (self , environment : str , value : Value ) -> None :
@@ -69,11 +70,11 @@ def set_value(self, environment: str, value: Value) -> None:
6970 Raises:
7071 ValueError: If the Value object's path doesn't match this PathData's path
7172 """
72- logger .debug ("Setting value for path %s in environment %s" , self .path , environment )
73+ HelmLogger .debug ("Setting value for path %s in environment %s" , self .path , environment )
7374
7475 if value .path != self .path :
75- logger .error ("Value path %s doesn't match PathData path %s" , value .path , self .path )
76- raise ValueError (f"Value path { value .path } doesn't match PathData path { self .path } " )
76+ HelmLogger .error ("Value path %s does not match PathData path %s" , value .path , self .path )
77+ raise ValueError (f"Value path { value .path } does not match PathData path { self .path } " )
7778
7879 self ._values [environment ] = value
7980
@@ -87,10 +88,12 @@ def get_value(self, environment: str) -> Optional[Value]:
8788 Returns:
8889 Optional[Value]: The Value object if it exists, None otherwise
8990 """
90- logger .debug ("Getting value for path %s in environment %s" , self .path , environment )
91+ HelmLogger .debug ("Getting value for path %s in environment %s" , self .path , environment )
9192 value = self ._values .get (environment )
9293 if value is None :
93- logger .debug ("No value found for path %s in environment %s" , self .path , environment )
94+ HelmLogger .debug ("No value found for path %s in environment %s" , self .path , environment )
95+ else :
96+ HelmLogger .debug ("Found value for path %s in environment %s" , self .path , environment )
9497 return value
9598
9699 def get_environments (self ) -> Iterator :
@@ -145,15 +148,15 @@ def from_dict(
145148 ValueError: If the dictionary structure is invalid
146149 """
147150 if not isinstance (data , dict ):
148- logger .error ("Invalid data type provided: %s" , type (data ))
151+ HelmLogger .error ("Invalid data type provided: %s" , type (data ))
149152 raise ValueError ("Data must be a dictionary" )
150153
151- logger .debug ("Creating PathData from dict with path: %s" , data .get ("path" ))
154+ HelmLogger .debug ("Creating PathData from dict with path: %s" , data .get ("path" ))
152155
153156 required_keys = {"path" , "values" }
154157 if not all (key in data for key in required_keys ):
155158 missing = required_keys - set (data .keys ())
156- logger .error ("Missing required keys in data: %s" , missing )
159+ HelmLogger .error ("Missing required keys in data: %s" , missing )
157160 raise ValueError (f"Missing required keys: { missing } " )
158161
159162 metadata = {
@@ -165,7 +168,7 @@ def from_dict(
165168
166169 # Create Value instances for each environment
167170 for env , value in data .get ("values" , {}).items ():
168- logger .debug ("Creating value for environment %s" , env )
171+ HelmLogger .debug ("Creating value for environment %s" , env )
169172 value_obj = create_value_fn (data ["path" ], env , {"value" : value })
170173 path_data .set_value (env , value_obj )
171174
0 commit comments