fix role._rc init

This commit is contained in:
better629 2023-11-30 21:42:09 +08:00
parent c70c8358d3
commit 6208400f71
3 changed files with 26 additions and 8 deletions

View file

@ -31,6 +31,7 @@ class Environment(BaseModel):
arbitrary_types_allowed = True
def __init__(self, **kwargs):
roles = []
for role_key, role in kwargs.get("roles", {}).items():
current_role = kwargs["roles"][role_key]
if isinstance(current_role, dict):
@ -41,8 +42,11 @@ class Environment(BaseModel):
current_role = subclass(**current_role)
break
kwargs["roles"][role_key] = current_role
roles.append(current_role)
super().__init__(**kwargs)
self.add_roles(roles) # add_roles again to init the Role.set_env
def serialize(self, stg_path: Path):
roles_path = stg_path.joinpath("roles.json")
roles_info = []