summaryrefslogtreecommitdiff
path: root/plugins/knife
diff options
context:
space:
mode:
authorRobby Russell <robby@planetargon.com>2013-04-07 18:57:00 -0700
committerRobby Russell <robby@planetargon.com>2013-04-07 18:57:00 -0700
commit1d66bef55030a0de728d8706d352da6dee9a2e44 (patch)
tree512242b7a867bf98be65882b91a12506ba839c91 /plugins/knife
parentb9064542383994432e927a06b773b81f4c82499f (diff)
parent520b0132e943252409457b550b39d8821663da7a (diff)
downloadzsh-1d66bef55030a0de728d8706d352da6dee9a2e44.tar.gz
zsh-1d66bef55030a0de728d8706d352da6dee9a2e44.tar.bz2
zsh-1d66bef55030a0de728d8706d352da6dee9a2e44.zip
Merge pull request #1682 from maplebed/ben.knife
Allow you to customize the path to knife config files
Diffstat (limited to 'plugins/knife')
-rw-r--r--plugins/knife/_knife17
1 files changed, 12 insertions, 5 deletions
diff --git a/plugins/knife/_knife b/plugins/knife/_knife
index dec491257..9f5b406af 100644
--- a/plugins/knife/_knife
+++ b/plugins/knife/_knife
@@ -1,5 +1,10 @@
#compdef knife
+# You can override the path to knife.rb and your cookbooks by setting
+# KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb
+# KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks
+# Read around where these are used for more detail.
+
# These flags should be available everywhere according to man knife
knife_general_flags=( --help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes )
@@ -170,11 +175,13 @@ _chef_environments_remote() {
# 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() {
- local knife_rb="$HOME/.chef/knife.rb"
- if [ -f ./.chef/knife.rb ]; then
- knife_rb="./.chef/knife.rb"
- fi
- (for i in $( grep cookbook_path $knife_rb | awk 'BEGIN {FS = "[" }; {print $2}' | sed 's/\,//g' | sed "s/'//g" | sed 's/\(.*\)]/\1/' ); do ls $i; done)
+
+ local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb}
+ if [ -f ./.chef/knife.rb ]; then
+ knife_rb="./.chef/knife.rb"
+ 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/' )}
+ (for i in $cookbook_path; do ls $i; done)
}
# This function extracts the available cookbook versions on the chef server