Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert comment notice in yaml configs #920

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bbot/core/configurator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ def ensure_config_files():
secrets_strings = ["api_key", "username", "password", "token", "secret", "_id"]
exclude_keys = ["modules", "output_modules", "internal_modules"]

comment_notice = (
"# NOTICE: THESE ENTRIES ARE COMMENTED BY DEFAULT\n"
+ "# Please be sure to uncomment when inserting API keys, etc.\n"
)

# ensure bbot.yml
if not files.config_filename.exists():
log_to_stderr(f"Creating BBOT config at {files.config_filename}")
Expand All @@ -77,7 +82,7 @@ def ensure_config_files():
exclude_keys=exclude_keys,
)
yaml = OmegaConf.to_yaml(no_secrets_config)
yaml = "\n".join(f"# {line}" for line in yaml.splitlines())
yaml = comment_notice + "\n".join(f"# {line}" for line in yaml.splitlines())
with open(str(files.config_filename), "w") as f:
f.write(yaml)

Expand All @@ -92,7 +97,7 @@ def ensure_config_files():
exclude_keys=exclude_keys,
)
yaml = OmegaConf.to_yaml(secrets_only_config)
yaml = "\n".join(f"# {line}" for line in yaml.splitlines())
yaml = comment_notice + "\n".join(f"# {line}" for line in yaml.splitlines())
with open(str(files.secrets_filename), "w") as f:
f.write(yaml)
files.secrets_filename.chmod(0o600)