File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 10
10
import copy
11
11
import json
12
12
import re
13
+ import typing
13
14
from dataclasses import asdict , dataclass , field
14
15
from datetime import datetime
15
16
from enum import Enum
@@ -189,8 +190,25 @@ def apply(self, role: "Role") -> "Role":
189
190
role = copy .deepcopy (role )
190
191
role .args = [self .substitute (arg ) for arg in role .args ]
191
192
role .env = {key : self .substitute (arg ) for key , arg in role .env .items ()}
193
+ role .metadata = self ._apply_nested (role .metadata )
194
+
192
195
return role
193
196
197
+ def _apply_nested (self , d : typing .Dict [str , Any ]) -> typing .Dict [str , Any ]:
198
+ stack = [d ]
199
+ while stack :
200
+ current_dict = stack .pop ()
201
+ for k , v in current_dict .items ():
202
+ if isinstance (v , dict ):
203
+ stack .append (v )
204
+ elif isinstance (v , str ):
205
+ current_dict [k ] = self .substitute (v )
206
+ elif isinstance (v , list ):
207
+ for i in range (len (v )):
208
+ if isinstance (v [i ], str ):
209
+ v [i ] = self .substitute (v [i ])
210
+ return d
211
+
194
212
def substitute (self , arg : str ) -> str :
195
213
"""
196
214
substitute applies the values to the template arg.
You can’t perform that action at this time.
0 commit comments