From 18e2d8617eea52030eb3b2a206ebae16f1730498 Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Tue, 7 Feb 2023 21:32:21 +0000 Subject: [PATCH] Create credentials dict prior to assignment in auth add Fixes #17. --- devine/commands/auth.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devine/commands/auth.py b/devine/commands/auth.py index 3dbe419..cf7ab21 100644 --- a/devine/commands/auth.py +++ b/devine/commands/auth.py @@ -251,6 +251,10 @@ def add(ctx: click.Context, profile: str, service: str, cookie: Optional[str] = yaml, data = YAML(), None yaml.default_flow_style = False data = yaml.load(config_path) + if "credentials" not in data: + data["credentials"] = {} + if service not in data["credentials"]: + data["credentials"][service] = {} data["credentials"][service][profile] = credential.dumps() yaml.dump(data, config_path) log.info(f"Added Credential: {credential}")