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

Change the way we get environment variables #280

Merged
merged 9 commits into from
Sep 16, 2020

Conversation

rw-access
Copy link
Contributor

Issues

Loosely related/discovered to this comment #17 (comment)

Summary

Got rid of click callback to use a non-interactive default variable. I think we were trying to do too much in a callback, and I believe any I/O in callback is discouraged.

@rw-access rw-access added cli command line tooling python Internal python for the repository labels Sep 10, 2020
detection_rules/eswrap.py Outdated Show resolved Hide resolved
elif prompt:
return click.prompt(key, default=param.default if not param.default else None, hide_input=param.hide_input,
show_default=True if param.default else False)
def getenv(name):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like what this is intended to solve, but this totally eliminates the ability to use config files for anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brokensound77
Copy link
Collaborator

We can remove all IO from the callback and then leave in the option to parse the value from a source based on precedence, which would still check for explicit, then envvar, then config option. Prompts can be moved to within their respective functions (as you did).

Config parsing can be moved to the root group, where users can implicitly opt in to config parsing by storing in the default config file or optionally pass -c to explicitly opt in using a specific config file.

https://github.com/elastic/detection-rules/compare/main...brokensound77:tweak/var-setting?expand=1

Thoughts?

def kibana_upload(toml_files, kibana_url, cloud_id, user, password):
"""Upload a list of rule .toml files to Kibana."""
from uuid import uuid4
from .packaging import manage_versions
from .schemas import downgrade

if not cloud_id or kibana_url:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would need to add a similar blurb for collect-events

Copy link
Collaborator

@brokensound77 brokensound77 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One note, then LGTM

I would also verify that the CLI.md doesn't need any updating as a result of this

detection_rules/eswrap.py Outdated Show resolved Hide resolved
@rw-access rw-access merged commit 453553f into elastic:main Sep 16, 2020
@rw-access rw-access deleted the tweak/environ-getter branch September 16, 2020 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli command line tooling python Internal python for the repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants