chef 0.9.6 → 0.9.8.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/lib/chef/application.rb +19 -3
  2. data/lib/chef/application/client.rb +7 -8
  3. data/lib/chef/application/knife.rb +9 -3
  4. data/lib/chef/application/solo.rb +5 -5
  5. data/lib/chef/cache/checksum.rb +2 -2
  6. data/lib/chef/client.rb +30 -64
  7. data/lib/chef/config.rb +52 -30
  8. data/lib/chef/cookbook/metadata.rb +12 -1
  9. data/lib/chef/cookbook_site_streaming_uploader.rb +211 -0
  10. data/lib/chef/cookbook_uploader.rb +102 -0
  11. data/lib/chef/cookbook_version.rb +47 -30
  12. data/lib/chef/couchdb.rb +1 -11
  13. data/lib/chef/exceptions.rb +1 -0
  14. data/lib/chef/file_access_control.rb +1 -1
  15. data/lib/chef/index_queue/amqp_client.rb +10 -3
  16. data/lib/chef/knife.rb +154 -58
  17. data/lib/chef/knife/bootstrap.rb +84 -48
  18. data/lib/chef/knife/bootstrap/centos5-gems.erb +41 -0
  19. data/lib/chef/knife/bootstrap/fedora13-gems.erb +38 -0
  20. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +44 -0
  21. data/lib/chef/knife/client_bulk_delete.rb +1 -1
  22. data/lib/chef/knife/client_create.rb +1 -1
  23. data/lib/chef/knife/client_delete.rb +1 -1
  24. data/lib/chef/knife/client_edit.rb +1 -1
  25. data/lib/chef/knife/client_list.rb +1 -1
  26. data/lib/chef/knife/client_reregister.rb +1 -1
  27. data/lib/chef/knife/client_show.rb +1 -1
  28. data/lib/chef/knife/configure.rb +1 -1
  29. data/lib/chef/knife/configure_client.rb +1 -1
  30. data/lib/chef/knife/cookbook_bulk_delete.rb +1 -1
  31. data/lib/chef/knife/cookbook_create.rb +159 -0
  32. data/lib/chef/knife/cookbook_delete.rb +6 -6
  33. data/lib/chef/knife/cookbook_download.rb +1 -1
  34. data/lib/chef/knife/cookbook_list.rb +1 -1
  35. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  36. data/lib/chef/knife/cookbook_metadata_from_file.rb +1 -1
  37. data/lib/chef/knife/cookbook_show.rb +1 -1
  38. data/lib/chef/knife/cookbook_site_download.rb +2 -1
  39. data/lib/chef/knife/cookbook_site_list.rb +2 -1
  40. data/lib/chef/knife/cookbook_site_search.rb +2 -1
  41. data/lib/chef/knife/cookbook_site_share.rb +108 -0
  42. data/lib/chef/knife/cookbook_site_show.rb +2 -1
  43. data/lib/chef/knife/cookbook_site_unshare.rb +52 -0
  44. data/lib/chef/knife/cookbook_site_vendor.rb +3 -2
  45. data/lib/chef/knife/cookbook_test.rb +1 -1
  46. data/lib/chef/knife/cookbook_upload.rb +22 -155
  47. data/lib/chef/knife/data_bag_create.rb +2 -1
  48. data/lib/chef/knife/data_bag_delete.rb +2 -1
  49. data/lib/chef/knife/data_bag_edit.rb +2 -1
  50. data/lib/chef/knife/data_bag_from_file.rb +2 -1
  51. data/lib/chef/knife/data_bag_list.rb +2 -1
  52. data/lib/chef/knife/data_bag_show.rb +2 -1
  53. data/lib/chef/knife/ec2_instance_data.rb +1 -1
  54. data/lib/chef/knife/ec2_server_create.rb +16 -4
  55. data/lib/chef/knife/ec2_server_delete.rb +8 -2
  56. data/lib/chef/knife/ec2_server_list.rb +8 -2
  57. data/lib/chef/knife/index_rebuild.rb +1 -1
  58. data/lib/chef/knife/node_bulk_delete.rb +1 -1
  59. data/lib/chef/knife/node_create.rb +1 -1
  60. data/lib/chef/knife/node_delete.rb +1 -1
  61. data/lib/chef/knife/node_edit.rb +1 -1
  62. data/lib/chef/knife/node_from_file.rb +1 -1
  63. data/lib/chef/knife/node_list.rb +1 -1
  64. data/lib/chef/knife/node_run_list_add.rb +1 -1
  65. data/lib/chef/knife/node_run_list_remove.rb +1 -1
  66. data/lib/chef/knife/node_show.rb +1 -1
  67. data/lib/chef/knife/rackspace_server_create.rb +1 -1
  68. data/lib/chef/knife/rackspace_server_delete.rb +1 -1
  69. data/lib/chef/knife/rackspace_server_list.rb +1 -1
  70. data/lib/chef/knife/recipe_list.rb +1 -1
  71. data/lib/chef/knife/role_bulk_delete.rb +1 -1
  72. data/lib/chef/knife/role_create.rb +1 -1
  73. data/lib/chef/knife/role_delete.rb +1 -1
  74. data/lib/chef/knife/role_edit.rb +1 -1
  75. data/lib/chef/knife/role_from_file.rb +1 -1
  76. data/lib/chef/knife/role_list.rb +1 -1
  77. data/lib/chef/knife/role_show.rb +1 -1
  78. data/lib/chef/knife/search.rb +1 -1
  79. data/lib/chef/knife/slicehost_images_list.rb +1 -1
  80. data/lib/chef/knife/slicehost_server_create.rb +1 -1
  81. data/lib/chef/knife/slicehost_server_delete.rb +1 -1
  82. data/lib/chef/knife/slicehost_server_list.rb +1 -1
  83. data/lib/chef/knife/ssh.rb +49 -9
  84. data/lib/chef/knife/status.rb +2 -2
  85. data/lib/chef/knife/terremark_server_create.rb +1 -1
  86. data/lib/chef/knife/terremark_server_delete.rb +1 -1
  87. data/lib/chef/knife/terremark_server_list.rb +1 -1
  88. data/lib/chef/mixin/command.rb +17 -204
  89. data/lib/chef/mixin/command/unix.rb +215 -0
  90. data/lib/chef/mixin/command/windows.rb +72 -0
  91. data/lib/chef/mixin/find_preferred_file.rb +3 -3
  92. data/lib/chef/mixin/language.rb +64 -23
  93. data/lib/chef/node.rb +27 -3
  94. data/lib/chef/node/attribute.rb +20 -10
  95. data/lib/chef/platform.rb +3 -9
  96. data/lib/chef/provider/cron.rb +1 -1
  97. data/lib/chef/provider/deploy.rb +4 -1
  98. data/lib/chef/provider/group.rb +1 -1
  99. data/lib/chef/provider/group/dscl.rb +2 -2
  100. data/lib/chef/provider/mount/mount.rb +6 -6
  101. data/lib/chef/provider/package/easy_install.rb +8 -7
  102. data/lib/chef/provider/package/pacman.rb +1 -1
  103. data/lib/chef/provider/package/rpm.rb +4 -4
  104. data/lib/chef/provider/package/solaris.rb +127 -0
  105. data/lib/chef/provider/package/yum.rb +51 -28
  106. data/lib/chef/provider/remote_directory.rb +5 -2
  107. data/lib/chef/provider/remote_file.rb +1 -1
  108. data/lib/chef/provider/ruby_block.rb +1 -0
  109. data/lib/chef/provider/script.rb +2 -2
  110. data/lib/chef/provider/service/debian.rb +40 -4
  111. data/lib/chef/provider/service/freebsd.rb +1 -1
  112. data/lib/chef/provider/service/upstart.rb +3 -10
  113. data/lib/chef/provider/user/dscl.rb +2 -2
  114. data/lib/chef/providers.rb +1 -0
  115. data/lib/chef/resource.rb +7 -8
  116. data/lib/chef/resource/service.rb +17 -0
  117. data/lib/chef/resource/solaris_package.rb +36 -0
  118. data/lib/chef/resource/yum_package.rb +11 -4
  119. data/lib/chef/rest/rest_request.rb +18 -1
  120. data/lib/chef/run_list/run_list_expansion.rb +4 -0
  121. data/lib/chef/run_list/run_list_item.rb +8 -1
  122. data/lib/chef/shef/ext.rb +1 -1
  123. data/lib/chef/shef/shef_session.rb +7 -3
  124. data/lib/chef/tasks/chef_repo.rake +1 -0
  125. data/lib/chef/version.rb +2 -1
  126. metadata +23 -8
  127. data/lib/chef/cache/file_cache_by_checksum.rb +0 -52
@@ -0,0 +1,41 @@
1
+ bash -c '
2
+ rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
3
+ rpm -Uvh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
4
+
5
+ yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf rubygems make
6
+
7
+ gem update --system
8
+ gem update
9
+ gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
10
+
11
+ mkdir -p /etc/chef
12
+
13
+ (
14
+ cat <<'EOP'
15
+ <%= IO.read(Chef::Config[:validation_key]) %>
16
+ EOP
17
+ ) > /tmp/validation.pem
18
+ awk NF /tmp/validation.pem > /etc/chef/validation.pem
19
+ rm /tmp/validation.pem
20
+
21
+ (
22
+ cat <<'EOP'
23
+ log_level :info
24
+ log_location STDOUT
25
+ chef_server_url "<%= Chef::Config[:chef_server_url] %>"
26
+ validation_client_name "<%= Chef::Config[:validation_client_name] %>"
27
+ <% if @config[:chef_node_name] == nil %>
28
+ # Using default node name"
29
+ <% else %>
30
+ node_name "<%= @config[:chef_node_name] %>"
31
+ <% end %>
32
+ EOP
33
+ ) > /etc/chef/client.rb
34
+
35
+ (
36
+ cat <<'EOP'
37
+ <%= { "run_list" => @run_list }.to_json %>
38
+ EOP
39
+ ) > /etc/chef/first-boot.json
40
+
41
+ /usr/bin/chef-client -j /etc/chef/first-boot.json'
@@ -0,0 +1,38 @@
1
+ bash -c '
2
+ yum install -q -y ruby ruby-devel gcc gcc-c++ automake autoconf rubygems make
3
+
4
+ gem update --system
5
+ gem update
6
+ gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
7
+
8
+ mkdir -p /etc/chef
9
+
10
+ (
11
+ cat <<'EOP'
12
+ <%= IO.read(Chef::Config[:validation_key]) %>
13
+ EOP
14
+ ) > /tmp/validation.pem
15
+ awk NF /tmp/validation.pem > /etc/chef/validation.pem
16
+ rm /tmp/validation.pem
17
+
18
+ (
19
+ cat <<'EOP'
20
+ log_level :info
21
+ log_location STDOUT
22
+ chef_server_url "<%= Chef::Config[:chef_server_url] %>"
23
+ validation_client_name "<%= Chef::Config[:validation_client_name] %>"
24
+ <% if @config[:chef_node_name] == nil %>
25
+ # Using default node name"
26
+ <% else %>
27
+ node_name "<%= @config[:chef_node_name] %>"
28
+ <% end %>
29
+ EOP
30
+ ) > /etc/chef/client.rb
31
+
32
+ (
33
+ cat <<'EOP'
34
+ <%= { "run_list" => @run_list }.to_json %>
35
+ EOP
36
+ ) > /etc/chef/first-boot.json
37
+
38
+ /usr/bin/chef-client -j /etc/chef/first-boot.json'
@@ -0,0 +1,44 @@
1
+ bash -c '
2
+ if [ ! -f /usr/bin/chef-client ]; then
3
+ apt-get update
4
+ apt-get install -y ruby ruby1.8-dev build-essential wget libruby-extras libruby1.8-extras
5
+ cd /tmp
6
+ wget http://rubyforge.org/frs/download.php/69365/rubygems-1.3.6.tgz
7
+ tar xvf rubygems-1.3.6.tgz
8
+ cd rubygems-1.3.6
9
+ ruby setup.rb
10
+ cp /usr/bin/gem1.8 /usr/bin/gem
11
+ gem install ohai chef --no-rdoc --no-ri --verbose <%= '--prerelease' if @config[:prerelease] %>
12
+ fi
13
+
14
+ mkdir -p /etc/chef
15
+
16
+ (
17
+ cat <<'EOP'
18
+ <%= IO.read(Chef::Config[:validation_key]) %>
19
+ EOP
20
+ ) > /tmp/validation.pem
21
+ awk NF /tmp/validation.pem > /etc/chef/validation.pem
22
+ rm /tmp/validation.pem
23
+
24
+ (
25
+ cat <<'EOP'
26
+ log_level :info
27
+ log_location STDOUT
28
+ chef_server_url "<%= Chef::Config[:chef_server_url] %>"
29
+ validation_client_name "<%= Chef::Config[:validation_client_name] %>"
30
+ <% if @config[:chef_node_name] == nil %>
31
+ # Using default node name"
32
+ <% else %>
33
+ node_name "<%= @config[:chef_node_name] %>"
34
+ <% end %>
35
+ EOP
36
+ ) > /etc/chef/client.rb
37
+
38
+ (
39
+ cat <<'EOP'
40
+ <%= { "run_list" => @run_list }.to_json %>
41
+ EOP
42
+ ) > /etc/chef/first-boot.json
43
+
44
+ /usr/bin/chef-client -j /etc/chef/first-boot.json'
@@ -24,7 +24,7 @@ class Chef
24
24
  class Knife
25
25
  class ClientBulkDelete < Knife
26
26
 
27
- banner "Sub-Command: client bulk delete REGEX (options)"
27
+ banner "knife client bulk delete REGEX (options)"
28
28
 
29
29
  def run
30
30
  if @name_args.length < 1
@@ -35,7 +35,7 @@ class Chef
35
35
  :description => "Create the client as an admin",
36
36
  :boolean => true
37
37
 
38
- banner "Sub-Command: client create CLIENT (options)"
38
+ banner "knife client create CLIENT (options)"
39
39
 
40
40
  def run
41
41
  @client_name = @name_args[0]
@@ -24,7 +24,7 @@ class Chef
24
24
  class Knife
25
25
  class ClientDelete < Knife
26
26
 
27
- banner "Sub-Command: client delete CLIENT (options)"
27
+ banner "knife client delete CLIENT (options)"
28
28
 
29
29
  def run
30
30
  @client_name = @name_args[0]
@@ -24,7 +24,7 @@ class Chef
24
24
  class Knife
25
25
  class ClientEdit < Knife
26
26
 
27
- banner "Sub-Command: client edit CLIENT (options)"
27
+ banner "knife client edit CLIENT (options)"
28
28
 
29
29
  def run
30
30
  @client_name = @name_args[0]
@@ -24,7 +24,7 @@ class Chef
24
24
  class Knife
25
25
  class ClientList < Knife
26
26
 
27
- banner "Sub-Command: client list (options)"
27
+ banner "knife client list (options)"
28
28
 
29
29
  option :with_uri,
30
30
  :short => "-w",
@@ -24,7 +24,7 @@ class Chef
24
24
  class Knife
25
25
  class ClientReregister < Knife
26
26
 
27
- banner "Sub-Command: client reregister CLIENT (options)"
27
+ banner "knife client reregister CLIENT (options)"
28
28
 
29
29
  option :file,
30
30
  :short => "-f FILE",
@@ -24,7 +24,7 @@ class Chef
24
24
  class Knife
25
25
  class ClientShow < Knife
26
26
 
27
- banner "Sub-Command: client show CLIENT (options)"
27
+ banner "knife client show CLIENT (options)"
28
28
 
29
29
  option :attribute,
30
30
  :short => "-a ATTR",
@@ -24,7 +24,7 @@ class Chef
24
24
  attr_reader :chef_server, :new_client_name, :admin_client_name, :admin_client_key
25
25
  attr_reader :chef_repo, :new_client_key, :validation_client_name, :validation_key
26
26
 
27
- banner "Sub-Command: configure (options)"
27
+ banner "knife configure (options)"
28
28
 
29
29
  option :repository,
30
30
  :short => "-r REPO",
@@ -21,7 +21,7 @@ require 'chef/knife'
21
21
  class Chef
22
22
  class Knife
23
23
  class ConfigureClient < Knife
24
- banner "Sub-Command: configure client DIRECTORY"
24
+ banner "knife configure client DIRECTORY"
25
25
 
26
26
  def run
27
27
  unless @config_dir = @name_args[0]
@@ -26,7 +26,7 @@ class Chef
26
26
 
27
27
  option :purge, :short => '-p', :long => '--purge', :boolean => true, :description => 'Permanently remove files from backing data store'
28
28
 
29
- banner "Sub-Command: cookbook bulk delete REGEX (options)"
29
+ banner "knife cookbook bulk delete REGEX (options)"
30
30
 
31
31
  def run
32
32
  unless regex_str = @name_args.first
@@ -0,0 +1,159 @@
1
+ #
2
+ # Author:: Nuo Yan (<nuo@opscode.com>)
3
+ # Copyright:: Copyright (c) 2009 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife'
20
+ require 'json'
21
+ require 'uri'
22
+ require 'chef/mixin/shell_out'
23
+
24
+ class Chef
25
+ class Knife
26
+ class CookbookCreate < Knife
27
+ include Chef::Mixin::ShellOut
28
+
29
+ banner "knife cookbook create COOKBOOK [COMPANY_NAME_FOR_COPYRIGHT] [EMAIL] [APACHE_LICENSE=false] (options)"
30
+
31
+ option :cookbook_path,
32
+ :short => "-o PATH",
33
+ :long => "--cookbook-path PATH",
34
+ :description => "The directory where the cookbook will be created"
35
+
36
+ def run
37
+ if @name_args.length < 1
38
+ show_usage
39
+ Chef::Log.fatal("You must specify a cookbook name")
40
+ exit 1
41
+ end
42
+
43
+ if default_cookbook_path_empty? && given_cookbook_path_empty?
44
+ raise ArgumentError, "Default cookbook_path is not specified in the knife.rb config file, and a value to -o is not provided. Nowhere to write the new cookbook to."
45
+ end
46
+
47
+ cookbook_path = given_cookbook_path_empty? ? Chef::Config[:cookbook_path].first : config[:cookbook_path]
48
+ cookbook_name = @name_args.first
49
+ company_name = @name_args[1].nil? || @name_args[1].empty? ? "YOUR_COMPANY_NAME" : @name_args[1]
50
+ email = @name_args[2].nil? || @name_args[2].empty? ? "YOUR_EMAIL" : @name_args[2]
51
+ license = (@name_args[3].nil? || @name_args[3].to_s.empty? || @name_args[3] == false || @name_args[3] == 'false') ? :none : :apachev2
52
+ create_cookbook(cookbook_path,cookbook_name, company_name, license)
53
+ create_readme(cookbook_path,cookbook_name)
54
+ create_metadata(cookbook_path,cookbook_name, company_name, email, license)
55
+ end
56
+
57
+ def create_cookbook(dir, cookbook_name, company_name, license)
58
+ msg("** Creating cookbook #{cookbook_name}")
59
+ shell_out "mkdir -p #{File.join(dir, cookbook_name, "attributes")}"
60
+ shell_out "mkdir -p #{File.join(dir, cookbook_name, "recipes")}"
61
+ shell_out "mkdir -p #{File.join(dir, cookbook_name, "definitions")}"
62
+ shell_out "mkdir -p #{File.join(dir, cookbook_name, "libraries")}"
63
+ shell_out "mkdir -p #{File.join(dir, cookbook_name, "resources")}"
64
+ shell_out "mkdir -p #{File.join(dir, cookbook_name, "providers")}"
65
+ shell_out "mkdir -p #{File.join(dir, cookbook_name, "files", "default")}"
66
+ shell_out "mkdir -p #{File.join(dir, cookbook_name, "templates", "default")}"
67
+ unless File.exists?(File.join(dir, cookbook_name, "recipes", "default.rb"))
68
+ open(File.join(dir, cookbook_name, "recipes", "default.rb"), "w") do |file|
69
+ file.puts <<-EOH
70
+ #
71
+ # Cookbook Name:: #{cookbook_name}
72
+ # Recipe:: default
73
+ #
74
+ # Copyright #{Time.now.year}, #{company_name}
75
+ #
76
+ EOH
77
+ case license
78
+ when :apachev2
79
+ file.puts <<-EOH
80
+ # Licensed under the Apache License, Version 2.0 (the "License");
81
+ # you may not use this file except in compliance with the License.
82
+ # You may obtain a copy of the License at
83
+ #
84
+ # http://www.apache.org/licenses/LICENSE-2.0
85
+ #
86
+ # Unless required by applicable law or agreed to in writing, software
87
+ # distributed under the License is distributed on an "AS IS" BASIS,
88
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89
+ # See the License for the specific language governing permissions and
90
+ # limitations under the License.
91
+ #
92
+ EOH
93
+ when :none
94
+ file.puts <<-EOH
95
+ # All rights reserved - Do Not Redistribute
96
+ #
97
+ EOH
98
+ end
99
+ end
100
+ end
101
+ end
102
+
103
+ def create_readme(dir, cookbook_name)
104
+ msg("** Creating README for cookbook: #{cookbook_name}")
105
+ unless File.exists?(File.join(dir, cookbook_name, "README.rdoc"))
106
+ open(File.join(dir, cookbook_name, "README.rdoc"), "w") do |file|
107
+ file.puts <<-EOH
108
+ = DESCRIPTION:
109
+
110
+ = REQUIREMENTS:
111
+
112
+ = ATTRIBUTES:
113
+
114
+ = USAGE:
115
+
116
+ EOH
117
+ end
118
+ end
119
+ end
120
+
121
+ def create_metadata(dir, cookbook_name, company_name, email, license)
122
+ msg("** Creating metadata for cookbook: #{cookbook_name}")
123
+
124
+ license_name = case license
125
+ when :apachev2
126
+ "Apache 2.0"
127
+ when :none
128
+ "All rights reserved"
129
+ end
130
+
131
+ unless File.exists?(File.join(dir, cookbook_name, "metadata.rb"))
132
+ open(File.join(dir, cookbook_name, "metadata.rb"), "w") do |file|
133
+ if File.exists?(File.join(dir, cookbook_name, 'README.rdoc'))
134
+ long_description = "long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))"
135
+ end
136
+ file.puts <<-EOH
137
+ maintainer "#{company_name}"
138
+ maintainer_email "#{email}"
139
+ license "#{license_name}"
140
+ description "Installs/Configures #{cookbook_name}"
141
+ #{long_description}
142
+ version "0.0.1"
143
+ EOH
144
+ end
145
+ end
146
+ end
147
+
148
+ private
149
+ def default_cookbook_path_empty?
150
+ Chef::Config[:cookbook_path].nil? || Chef::Config[:cookbook_path].empty?
151
+ end
152
+
153
+ def given_cookbook_path_empty?
154
+ config[:cookbook_path].nil? || config[:cookbook_path].empty?
155
+ end
156
+
157
+ end
158
+ end
159
+ end
@@ -26,7 +26,7 @@ class Chef
26
26
 
27
27
  option :purge, :short => '-p', :long => '--purge', :boolean => true, :description => 'Permanently remove files from backing data store'
28
28
 
29
- banner "Sub-Command: cookbook delete COOKBOOK VERSION (options)"
29
+ banner "knife cookbook delete COOKBOOK VERSION (options)"
30
30
 
31
31
  def run
32
32
  confirm("Files that are common to multiple cookbooks are shared, so purging the files may disable other cookbooks. Are you sure you want to purge files instead of just deleting the cookbook") if config[:purge]
@@ -46,7 +46,7 @@ class Chef
46
46
 
47
47
  def delete_explicit_version
48
48
  delete_object(Chef::CookbookVersion, "#{@cookbook_name} version #{@version}", "cookbook") do
49
- delete_request("cookbooks/#{@cookbook_name}/#{@version}", config[:purge])
49
+ delete_request("cookbooks/#{@cookbook_name}/#{@version}")
50
50
  end
51
51
  end
52
52
 
@@ -115,7 +115,7 @@ class Chef
115
115
  end
116
116
 
117
117
  def delete_version_without_confirmation(version)
118
- object = delete_request("cookbooks/#{@cookbook_name}/#{version}", config[:purge])
118
+ object = delete_request("cookbooks/#{@cookbook_name}/#{version}")
119
119
  output(format_for_display(object)) if config[:print_after]
120
120
  Chef::Log.info("Deleted cookbook[#{@cookbook_name}][#{version}]")
121
121
  end
@@ -133,9 +133,9 @@ class Chef
133
133
 
134
134
  private
135
135
 
136
- def delete_request(path, purge)
137
- url = "cookbooks/#{@cookbook_name}/#{@version}#{purge ? "?purge=true" : ""}"
138
- rest.delete_rest(url)
136
+ def delete_request(path)
137
+ path += "?purge=true" if config[:purge]
138
+ rest.delete_rest(path)
139
139
  end
140
140
 
141
141
  end
@@ -23,7 +23,7 @@ class Chef
23
23
  class Knife
24
24
  class CookbookDownload < Knife
25
25
 
26
- banner "Sub-Command: cookbook download COOKBOOK [VERSION] (options)"
26
+ banner "knife cookbook download COOKBOOK [VERSION] (options)"
27
27
 
28
28
  option :latest,
29
29
  :short => "-N",
@@ -23,7 +23,7 @@ class Chef
23
23
  class Knife
24
24
  class CookbookList < Knife
25
25
 
26
- banner "Sub-Command: cookbook list (options)"
26
+ banner "knife cookbook list (options)"
27
27
 
28
28
  option :with_uri,
29
29
  :short => "-w",
@@ -23,7 +23,7 @@ class Chef
23
23
  class Knife
24
24
  class CookbookMetadata < Knife
25
25
 
26
- banner "Sub-Command: cookbook metadata COOKBOOK (options)"
26
+ banner "knife cookbook metadata COOKBOOK (options)"
27
27
 
28
28
  option :cookbook_path,
29
29
  :short => "-o PATH:PATH",