Create credentials dict prior to assignment in auth add

Fixes #17.
This commit is contained in:
rlaphoenix 2023-02-07 21:32:21 +00:00
parent c5d6ba09f2
commit 18e2d8617e
1 changed files with 4 additions and 0 deletions

View File

@ -251,6 +251,10 @@ def add(ctx: click.Context, profile: str, service: str, cookie: Optional[str] =
yaml, data = YAML(), None yaml, data = YAML(), None
yaml.default_flow_style = False yaml.default_flow_style = False
data = yaml.load(config_path) 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() data["credentials"][service][profile] = credential.dumps()
yaml.dump(data, config_path) yaml.dump(data, config_path)
log.info(f"Added Credential: {credential}") log.info(f"Added Credential: {credential}")