44This module provides a simple in-memory backend for storing non-sensitive values.
55"""
66
7- from typing import Dict
7+ from typing import Dict , Union
88
99from helm_values_manager .backends .base import ValueBackend
1010
@@ -19,24 +19,23 @@ class SimpleValueBackend(ValueBackend):
1919 def __init__ (self ) -> None :
2020 """Initialize an empty in-memory storage."""
2121 super ().__init__ ({"type" : "direct" }) # Simple backend doesn't need auth
22- self ._storage : Dict [str , str ] = {}
22+ self ._storage : Dict [str , Union [ str , int , float , bool , None ] ] = {}
2323
2424 def _get_storage_key (self , path : str , environment : str ) -> str :
2525 """Generate a unique storage key."""
2626 return f"{ path } :{ environment } "
2727
28- def get_value (self , path : str , environment : str , resolve : bool = False ) -> str :
28+ def get_value (self , path : str , environment : str , resolve : bool = False ) -> Union [ str , int , float , bool , None ] :
2929 """
3030 Get a value from the in-memory storage.
3131
3232 Args:
3333 path: The configuration path (e.g., "app.replicas")
3434 environment: The environment name (e.g., "dev", "prod")
35- resolve: If True, resolve any secret references to their actual values.
36- If False, return the raw value which may be a secret reference.
35+ resolve: Whether to resolve any secret references
3736
3837 Returns:
39- str: The value (resolved or raw depending on resolve parameter)
38+ The value from the backend, can be a string, number, boolean, or None
4039
4140 Raises:
4241 ValueError: If the value doesn't exist
@@ -46,20 +45,21 @@ def get_value(self, path: str, environment: str, resolve: bool = False) -> str:
4645 raise ValueError (f"No value found for { path } in { environment } " )
4746 return self ._storage [key ]
4847
49- def set_value (self , path : str , environment : str , value : str ) -> None :
48+ def set_value (self , path : str , environment : str , value : Union [ str , int , float , bool , None ] ) -> None :
5049 """
5150 Set a value in the in-memory storage.
5251
5352 Args:
5453 path: The configuration path (e.g., "app.replicas")
5554 environment: The environment name (e.g., "dev", "prod")
56- value: The value to store
55+ value: The value to store, can be a string, number, boolean, or None
5756
5857 Raises:
59- ValueError: If the value is not a string
58+ ValueError: If the value is not a string, number, boolean, or None
6059 """
61- if not isinstance (value , str ):
62- raise ValueError ("Value must be a string" )
60+ if not isinstance (value , (str , int , float , bool , type (None ))):
61+ raise ValueError ("Value must be a string, number, boolean, or None" )
62+
6363 key = self ._get_storage_key (path , environment )
6464 self ._storage [key ] = value
6565
0 commit comments