1d66bef55030a0de728d8706d352da6dee9a2e44

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #1682 from maplebed/ben.knife

Allow you to customize the path to knife config files

Diff

 1diff --git a/plugins/knife/_knife b/plugins/knife/_knife
 2index dec49125786e5dd40b04d092f540cc07e2ce57b3..9f5b406afd771334308490a6b5871163ae8f0ea4 100644
 3--- a/plugins/knife/_knife
 4+++ b/plugins/knife/_knife
 5@@ -1,5 +1,10 @@
 6 #compdef knife
 7 
 8+# You can override the path to knife.rb and your cookbooks by setting
 9+# KNIFE_CONF_PATH=/path/to/my/.chef/knife.rb
10+# KNIFE_COOKBOOK_PATH=/path/to/my/chef/cookbooks
11+# Read around where these are used for more detail.
12+
13 # These flags should be available everywhere according to man knife
14 knife_general_flags=( --help --server-url --key --config --editor --format --log_level --logfile --no-editor --user --print-after --version --yes )
15 
16@@ -170,11 +175,13 @@ _chef_environments_remote() {
17 
18 # The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server
19 _chef_cookbooks_local() {
20- local knife_rb="$HOME/.chef/knife.rb"
21- if [ -f ./.chef/knife.rb ]; then
22-  knife_rb="./.chef/knife.rb"
23- fi
24- (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)
25+  
26+  local knife_rb=${KNIFE_CONF_PATH:-${HOME}/.chef/knife.rb}
27+  if [ -f ./.chef/knife.rb ]; then
28+    knife_rb="./.chef/knife.rb"
29+  fi
30+  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/' )}
31+  (for i in $cookbook_path; do ls $i; done)
32 }
33 
34 # This function extracts the available cookbook versions on the chef server