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

Quick fix for https config sources #327

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion broker/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _import_config(self, source, is_url=False):
import requests

click.echo(f"Downloading example file from: {source}")
return requests.get(source, timeout=60).text
return requests.get(source, timeout=60, verify=False).text
else:
return source.read_text()

Expand Down
12 changes: 10 additions & 2 deletions broker/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,15 +267,23 @@ def update_inventory(add=None, remove=None):
yaml.dump(inv_data, settings.inventory_path)


def yaml_format(in_struct):
def yaml_format(in_struct, force_yaml_dict=False):
"""Convert a yaml-compatible structure to a yaml dumped string.

:param in_struct: yaml-compatible structure or string containing structure
:param force_yaml_dict: force the in_struct to be converted to a dictionary before dumping

:return: yaml-formatted string
"""
if isinstance(in_struct, str):
in_struct = yaml.load(in_struct)
# first try to load is as json
try:
in_struct = json.loads(in_struct)
except json.JSONDecodeError:
# then try yaml
in_struct = yaml.load(in_struct)
if force_yaml_dict:
in_struct = dict(in_struct)
output = BytesIO() # ruamel doesn't natively allow for string output
yaml.dump(in_struct, output)
return output.getvalue().decode("utf-8")
Expand Down