-
Notifications
You must be signed in to change notification settings - Fork 48
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
Add --env to comment trigger phrase #2583
Add --env to comment trigger phrase #2583
Conversation
894950f
to
2a7b77b
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 2m 13s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really nice work, thanks for looking into it so quickly!!
Just few comments, and could you please fix the commits history (there is one in the PR that's already in main)?
env_variables = { | ||
k: v | ||
for k, v in self.comment_arguments.envs.items() | ||
if v is not None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about a use-case of "unsetting" env var via comment arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think about this one. You mean something like --env MY_ENV_VAR=""
will unset it or do you have something else how should look like? It shouldn't be a problem to implement it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you mean if value is None then unset it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, practically both, like if someone passes --env ENV_VAR_TO_UNSET= --env OTHER_ENV_VAR=value
, which would lead to the value being None
# Set up argparse | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("packit_command") | ||
parser.add_argument("--identifier", "--id", "-i") | ||
parser.add_argument("--labels") | ||
parser.add_argument("--env", action="append") # Allows multiple --env arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we could create property out of this, or at least separate the creation of the parser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not python expert so maybe my changes are not python compliant, but I think it is better now
if args.env: | ||
# Parse envs into dictionary | ||
self.envs = dict(env.split("=") for env in args.env) | ||
logger.debug(f"Parsed envs: {self.envs}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here we should add some error handling for bad input (not key=value
format)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some changes, please take a look :)
identifier: str = None | ||
labels: List[str] = None | ||
pr_argument: str = None | ||
|
||
def __init__(self, command_prefix: str, comment: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the __init__
method grew quite a lot with the new code, do you think it could be split up a bit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I will try to split it
2a7b77b
to
27edb85
Compare
Build succeeded. ✔️ pre-commit SUCCESS in 2m 13s |
Build succeeded. ✔️ pre-commit SUCCESS in 2m 29s |
Build succeeded. ✔️ pre-commit SUCCESS in 2m 32s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the improvements! As for me, I would just agree on what to do with the unsetting the env var, and then after squashing the commits this could be merged! 🚀
env_variables = { | ||
k: v | ||
for k, v in self.comment_arguments.envs.items() | ||
if v is not None | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, practically both, like if someone passes --env ENV_VAR_TO_UNSET= --env OTHER_ENV_VAR=value
, which would lead to the value being None
Build succeeded. ✔️ pre-commit SUCCESS in 2m 27s |
3a74c46
to
7a5657d
Compare
Signed-off-by: Jakub Stejskal <[email protected]>
7a5657d
to
7cc43b1
Compare
@lbarcziova I updated the code, please take a look if the unset functionality is fine. |
Build succeeded. ✔️ pre-commit SUCCESS in 12m 10s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks a lot!
let's test in staging and adjust in followup PRs if needed
Build succeeded (gate pipeline). ✔️ pre-commit SUCCESS in 2m 29s |
5622b78
into
packit:main
Checklist:
packit/packit.dev
.This PR adds possibility to specify
--env
parameters in manual trigger command.User can specify multiple env variables in format like
--env MY_ENV_VAR=value --env MY_ENV_VAR2=value2
. Every env var has to have it's own--env
keyword.Env variables specified with this option has the highest priority when building TF payload.
Fixes #2200
RELEASE NOTES BEGIN
Packit now supports
--env
parameters in manual trigger command.RELEASE NOTES END