File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33scw_allow_ip () {
44 meta_check " var" " http"
55
6- if [[ ${# } -ne 2 ]]; then
7- var_red " Usage: scw_allow_ip SECURITY_GROUP_NAME RULE_PORT ZONE?"
8- return 1
9- fi
10-
11- local SECURITY_GROUP_NAME=" ${1} "
12- shift 1
13-
14- local RULE_PORT=" ${1} "
15- shift 1
16-
176 local ZONE=" ${1:- fr-par-2} "
7+ shift 1 || true
188
199 http_init_client --header " X-Auth-Token: $( pass_get " dev/scaleway" " secret_key" ) " -4
2010
@@ -36,7 +26,8 @@ scw_allow_ip() {
3626 fi
3727
3828 local SECURITY_GROUP_ID
39- SECURITY_GROUP_ID=" $( jq --raw-output --arg secGroupName " ${SECURITY_GROUP_NAME} " ' .security_groups[] | select(.name == $secGroupName) | .id' " ${HTTP_OUTPUT} " ) "
29+ SECURITY_GROUP_ID=" $( jq --raw-output ' .security_groups[] | .name + " - " + .id' " ${HTTP_OUTPUT} " | fzf --prompt=" Security Group: " --query " ${1:- } " --select-1 | awk ' {print $3}' ) "
30+
4031 rm " ${HTTP_OUTPUT} "
4132
4233 printf " Security group ID %s\n" " ${SECURITY_GROUP_ID} "
@@ -48,7 +39,7 @@ scw_allow_ip() {
4839 fi
4940
5041 local SECURITY_GROUP_RULE_ID
51- SECURITY_GROUP_RULE_ID=" $( jq --raw-output --argjson port " ${RULE_PORT} " ' .rules[] | select (.dest_port_from == $port) | .id' " ${HTTP_OUTPUT} " ) "
42+ SECURITY_GROUP_RULE_ID=" $( jq --raw-output ' .rules[] | (.dest_port_from | tostring) + " - " + .id' " ${HTTP_OUTPUT} " | fzf --prompt= " Port: " --query " ${1 :- } " --select-1 | awk ' {print $3} ' ) "
5243 rm " ${HTTP_OUTPUT} "
5344
5445 printf " Security rule ID %s\n" " ${SECURITY_GROUP_RULE_ID} "
You can’t perform that action at this time.
0 commit comments