-
-
Notifications
You must be signed in to change notification settings - Fork 782
Pass many 'register' components for 'packs.install', 'packs.load', 'st2ctl reload' #1619 #1624
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,12 +47,12 @@ function print_usage() { | |
| echo | ||
| echo "usage: st2ctl {reload, clean}" | ||
| echo "optional arguments:" | ||
| echo " --register-all Register all sensors, rules, and actions." | ||
| echo " --register-sensors Register all sensors only." | ||
| echo " --register-rules Register all rules only." | ||
| echo " --register-actions Register all actions only." | ||
| echo " --register-aliases Register all aliases only." | ||
| echo " --register-policies Register all policies only." | ||
| echo " --register-all Register all." | ||
| echo " --register-sensors Register all sensors." | ||
| echo " --register-rules Register all rules." | ||
| echo " --register-actions Register all actions." | ||
| echo " --register-aliases Register all aliases." | ||
| echo " --register-policies Register all policies." | ||
| echo " --verbose Output additional debug and informational messages." | ||
| } | ||
|
|
||
|
|
@@ -93,19 +93,26 @@ then | |
| fi | ||
|
|
||
| # Note: Scripts already call reload with "--register-<content>" | ||
| # TODO: Update packs. actions to only pass in a resource name excluding # --register prefix | ||
| if [ ${1} == "reload" -o ${1} == "clean" ]; then | ||
| ALLOWED_REGISTER_FLAGS=(--register-all --register-actions --register-aliases --register-policies --register-rules --register-sensors --verbose) | ||
| DEFAULT_REGISTER_FLAGS='--register-actions --register-aliases --register-sensors' | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this is a lot better. Hated this monstrosity :P
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just slightly worried, since I don't remember if we have any end to end tests for st2ctl. If we don't, now it would be a good time to add some to st2tests repo.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. st2tests looks like some kind of acceptance tests, pretty cool thing. I'll do it a bit later. |
||
| if [ ! -z ${2} ]; then | ||
| for arg in ${@:2}; do | ||
| if [[ " ${ALLOWED_REGISTER_FLAGS[*]} " != *" $arg "* ]]; then # argument not allowed | ||
| echo -e "\e[31mError: Invalid argument provided: ${arg} \e[0m\n" | ||
| print_usage | ||
| exit 1 | ||
| fi | ||
| done | ||
| fi | ||
|
|
||
| if [ -z ${2} ]; then | ||
| REGISTER_FLAGS="--register-sensors --register-actions --register-aliases" | ||
| elif [ ! -z ${2} ] && [ ${2} == "--register-all" -o ${2} == "--register-sensors" -o ${2} == "--register-rules" -o ${2} == "--register-actions" -o ${2} == "--register-aliases" -o ${2} == "--register-policies" ]; then | ||
| REGISTER_FLAGS=${2} | ||
| if [ ! -z ${3} ] && [ ${3} == "--verbose" ]; then | ||
| REGISTER_FLAGS="${REGISTER_FLAGS} ${3}" | ||
| fi | ||
| elif [ ${2} == "--verbose" ] && [ -z ${3} ]; then | ||
| REGISTER_FLAGS="--register-sensors --register-actions --register-aliases ${2}" | ||
| elif [ ${2} == "--verbose" ] && [ ${3} == "--register-all" -o ${3} == "--register-sensors" -o ${3} == "--register-rules" -o ${3} == "--register-actions" -o ${3} == "--register-aliases" -o ${3} == "--register-policies" ]; then | ||
| REGISTER_FLAGS="${3} ${2}" | ||
| REGISTER_FLAGS=${DEFAULT_REGISTER_FLAGS} | ||
| elif [ ${2} == '--verbose' ] && [ -z ${3} ]; then | ||
| REGISTER_FLAGS="$DEFAULT_REGISTER_FLAGS ${2}" | ||
| elif [ ! -z ${2} ]; then | ||
| REGISTER_FLAGS=${@:2} | ||
| else | ||
| print_usage | ||
| exit 1 | ||
|
|
||
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.
This is misusing string parameter type (it should really be
array), but I assume you have done it because you can't really specify arrays via chatops now, right?If so, that's fine for now. As a future improvement, we could look into re-using CLI logic for specifying arrays and objects as strings, but this might require more work since aliases are not aware of the parameter types.
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.
Aliases work with array like the Cli. Also there is some type awareness
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.
Oh, they do? Cool, I didn't know that.
(I do see the
CAST_OVERRIDEScode now...)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 tried with array first, but it's converted into string. See: #1231 (comment)
Also, as I understand array type won't be preserved here in install workflow
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.
Most likely due to the specific jinja template being used. Have not tried it out myself so can't say what works and what does not.
It will if load.yaml say it expect input as an array. The output type is not preserved since we lack type information. However, input to an action is cast, as much as possible, into the correct types.
I will agree that all this is very confusing and how the translations happens and types are preserved/not preserved during transitions is quite unclear.
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.
For now if you have figured out a way we should go with that since we know that it works.