1
1
from dataclasses import dataclass , field
2
- from typing import Any , Dict , Optional
2
+ from typing import Any , Dict , Optional , Union
3
+
4
+ from nodestream .file_io import LazyLoadedArgument
3
5
4
6
from ..pipeline .object_storage import ObjectStore , Signer
5
7
@@ -9,14 +11,15 @@ class StoreConfiguration:
9
11
name : str
10
12
storage_type : str
11
13
arguments : Dict [str , Any ]
12
- hmac_key : Optional [any ] = None
14
+ hmac_key : Optional [Union [ LazyLoadedArgument , str ] ] = None
13
15
14
16
def initialize (self ) -> ObjectStore :
15
- store = ObjectStore .from_file_arguments (self .storage_type , ** self .arguments )
17
+ resolved_args = LazyLoadedArgument .resolve_if_needed (self .arguments )
18
+ store = ObjectStore .from_file_arguments (self .storage_type , ** resolved_args )
16
19
if self .hmac_key :
17
- return store . signed ( Signer . hmac ( self .hmac_key ) )
18
- else :
19
- return store
20
+ resolved_key = LazyLoadedArgument . resolve_if_needed ( self .hmac_key )
21
+ return store . signed ( Signer . hmac ( resolved_key ))
22
+ return store
20
23
21
24
def to_file_data (self ):
22
25
return dict (
@@ -37,10 +40,15 @@ def from_file_data(data):
37
40
38
41
@staticmethod
39
42
def describe_yaml_schema ():
40
- from schema import Optional , Schema
43
+ from schema import Optional , Or , Schema
41
44
42
45
return Schema (
43
- {"name" : str , "type" : str , Optional ("hmac_key" ): str , Optional (str ): object }
46
+ {
47
+ "name" : str ,
48
+ "type" : str ,
49
+ Optional ("hmac_key" ): Or (LazyLoadedArgument , str , only_one = True ),
50
+ Optional (str ): object ,
51
+ }
44
52
)
45
53
46
54
0 commit comments