knife: backport #531 and #131

This commit is contained in:
midchildan 2021-11-19 00:15:06 +09:00
parent b5de3d53e0
commit da42a24a07
No known key found for this signature in database
GPG Key ID: D9A5748BACC6E3C2
1 changed files with 9 additions and 2 deletions

View File

@ -72,7 +72,7 @@ _knife() {
case $state in case $state in
knifecmd) knifecmd)
compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment index node recipe role search solo ssh status upload vault windows $cloudproviders compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" diff exec environment user index node recipe role search solo ssh status upload vault windows $cloudproviders
;; ;;
knifesubcmd) knifesubcmd)
case $words[2] in case $words[2] in
@ -94,6 +94,9 @@ _knife() {
environment) environment)
compadd -Q "$@" list create delete edit show "from file" compadd -Q "$@" list create delete edit show "from file"
;; ;;
user)
compadd -Q "$@" create delete edit list reregister show
;;
node) node)
compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete" compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
;; ;;
@ -263,6 +266,10 @@ _chef_environments_remote() {
(knife environment list | awk '{print $1}') (knife environment list | awk '{print $1}')
} }
_chef_users_remote() {
(knife user list | awk '{print $1}')
}
# The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server
_chef_cookbooks_local() { _chef_cookbooks_local() {
if [ $KNIFE_RELATIVE_PATH ]; then if [ $KNIFE_RELATIVE_PATH ]; then
@ -272,7 +279,7 @@ _chef_cookbooks_local() {
if [ -f ./.chef/knife.rb ]; then if [ -f ./.chef/knife.rb ]; then
knife_rb="./.chef/knife.rb" knife_rb="./.chef/knife.rb"
fi fi
local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/')} local cookbook_path=${KNIFE_COOKBOOK_PATH:-$(grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' | cut -d '"' -f2)}
fi fi
(for i in $cookbook_path; do ls $i; done) (for i in $cookbook_path; do ls $i; done)
} }