9
9
10
10
from helm_values_manager .models .config_metadata import ConfigMetadata
11
11
from 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
13
13
14
14
15
15
class PathData :
@@ -20,8 +20,8 @@ def __init__(self, path: str, metadata: Dict[str, Any]):
20
20
Initialize PathData with a path and metadata.
21
21
22
22
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
25
25
"""
26
26
self .path = path
27
27
self ._metadata = ConfigMetadata (
@@ -30,6 +30,7 @@ def __init__(self, path: str, metadata: Dict[str, Any]):
30
30
sensitive = metadata .get ("sensitive" , False ),
31
31
)
32
32
self ._values : Dict [str , Value ] = {}
33
+ HelmLogger .debug ("Created PathData instance for path %s" , path )
33
34
34
35
def validate (self ) -> None :
35
36
"""
@@ -42,20 +43,20 @@ def validate(self) -> None:
42
43
Raises:
43
44
ValueError: If validation fails
44
45
"""
45
- logger .debug ("Validating PathData for path: %s" , self .path )
46
+ HelmLogger .debug ("Validating PathData for path: %s" , self .path )
46
47
47
48
# Validate path consistency and required values
48
49
for env , value in self ._values .items ():
49
50
# Check path consistency
50
51
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 )
52
53
raise ValueError (f"Value for environment { env } has inconsistent path: { value .path } != { self .path } " )
53
54
54
55
# Check required values
55
56
if self ._metadata .required :
56
57
val = value .get ()
57
58
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 )
59
60
raise ValueError (f"Missing required value for path { self .path } in environment { env } " )
60
61
61
62
def set_value (self , environment : str , value : Value ) -> None :
@@ -69,11 +70,11 @@ def set_value(self, environment: str, value: Value) -> None:
69
70
Raises:
70
71
ValueError: If the Value object's path doesn't match this PathData's path
71
72
"""
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 )
73
74
74
75
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 } " )
77
78
78
79
self ._values [environment ] = value
79
80
@@ -87,10 +88,12 @@ def get_value(self, environment: str) -> Optional[Value]:
87
88
Returns:
88
89
Optional[Value]: The Value object if it exists, None otherwise
89
90
"""
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 )
91
92
value = self ._values .get (environment )
92
93
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 )
94
97
return value
95
98
96
99
def get_environments (self ) -> Iterator :
@@ -145,15 +148,15 @@ def from_dict(
145
148
ValueError: If the dictionary structure is invalid
146
149
"""
147
150
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 ))
149
152
raise ValueError ("Data must be a dictionary" )
150
153
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" ))
152
155
153
156
required_keys = {"path" , "values" }
154
157
if not all (key in data for key in required_keys ):
155
158
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 )
157
160
raise ValueError (f"Missing required keys: { missing } " )
158
161
159
162
metadata = {
@@ -165,7 +168,7 @@ def from_dict(
165
168
166
169
# Create Value instances for each environment
167
170
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 )
169
172
value_obj = create_value_fn (data ["path" ], env , {"value" : value })
170
173
path_data .set_value (env , value_obj )
171
174
0 commit comments