chef 12.11.18-universal-mingw32 → 12.12.13-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Rakefile +3 -2
  4. data/VERSION +1 -1
  5. data/acceptance/Gemfile.lock +22 -23
  6. data/acceptance/data-collector/test/integration/default/serverspec/default_spec.rb +2 -41
  7. data/lib/chef/application/solo.rb +7 -0
  8. data/lib/chef/chef_fs/file_system/multiplexed_dir.rb +1 -1
  9. data/lib/chef/data_collector.rb +79 -43
  10. data/lib/chef/data_collector/messages.rb +4 -33
  11. data/lib/chef/data_collector/messages/helpers.rb +2 -2
  12. data/lib/chef/data_collector/resource_report.rb +21 -11
  13. data/lib/chef/decorator/unchain.rb +43 -0
  14. data/lib/chef/exceptions.rb +5 -0
  15. data/lib/chef/http.rb +5 -5
  16. data/lib/chef/knife/cookbook_create.rb +4 -0
  17. data/lib/chef/knife/cookbook_site_download.rb +8 -1
  18. data/lib/chef/knife/cookbook_site_install.rb +8 -0
  19. data/lib/chef/knife/cookbook_site_list.rb +8 -1
  20. data/lib/chef/knife/cookbook_site_search.rb +8 -1
  21. data/lib/chef/knife/cookbook_site_share.rb +8 -1
  22. data/lib/chef/knife/cookbook_site_show.rb +14 -3
  23. data/lib/chef/knife/cookbook_site_unshare.rb +8 -1
  24. data/lib/chef/knife/core/bootstrap_context.rb +1 -1
  25. data/lib/chef/knife/supermarket_download.rb +33 -0
  26. data/lib/chef/knife/supermarket_install.rb +33 -0
  27. data/lib/chef/knife/supermarket_list.rb +33 -0
  28. data/lib/chef/knife/supermarket_search.rb +33 -0
  29. data/lib/chef/knife/supermarket_share.rb +33 -0
  30. data/lib/chef/knife/supermarket_show.rb +33 -0
  31. data/lib/chef/knife/supermarket_unshare.rb +33 -0
  32. data/lib/chef/node.rb +13 -32
  33. data/lib/chef/node/attribute.rb +123 -70
  34. data/lib/chef/node/attribute_collections.rb +9 -130
  35. data/lib/chef/node/common_api.rb +124 -0
  36. data/lib/chef/node/immutable_collections.rb +27 -2
  37. data/lib/chef/property.rb +6 -2
  38. data/lib/chef/provider.rb +4 -5
  39. data/lib/chef/provider/batch.rb +1 -1
  40. data/lib/chef/provider/directory.rb +3 -1
  41. data/lib/chef/provider/package/openbsd.rb +1 -1
  42. data/lib/chef/provider/package/rubygems.rb +9 -3
  43. data/lib/chef/provider/package/windows/exe.rb +2 -5
  44. data/lib/chef/provider/powershell_script.rb +1 -1
  45. data/lib/chef/provider/remote_directory.rb +2 -0
  46. data/lib/chef/resource.rb +22 -17
  47. data/lib/chef/resource_builder.rb +9 -4
  48. data/lib/chef/shell.rb +1 -1
  49. data/lib/chef/version.rb +1 -1
  50. data/spec/data/run_context/cookbooks/circular-dep1/attributes/default.rb +2 -4
  51. data/spec/data/run_context/cookbooks/circular-dep2/attributes/default.rb +2 -3
  52. data/spec/data/run_context/cookbooks/dependency1/attributes/aa_first.rb +2 -2
  53. data/spec/data/run_context/cookbooks/dependency1/attributes/default.rb +2 -2
  54. data/spec/data/run_context/cookbooks/dependency1/attributes/zz_last.rb +2 -3
  55. data/spec/data/run_context/cookbooks/dependency2/attributes/default.rb +2 -3
  56. data/spec/data/run_context/cookbooks/no-default-attr/attributes/server.rb +2 -3
  57. data/spec/data/run_context/cookbooks/test-with-circular-deps/attributes/default.rb +2 -3
  58. data/spec/data/run_context/cookbooks/test-with-deps/attributes/default.rb +2 -3
  59. data/spec/functional/assets/chocolatey_feed/test-A.1.0.nupkg +0 -0
  60. data/spec/functional/assets/chocolatey_feed/test-A.1.5.nupkg +0 -0
  61. data/spec/functional/assets/chocolatey_feed/test-A.2.0.nupkg +0 -0
  62. data/spec/functional/assets/chocolatey_feed/test-B.1.0.nupkg +0 -0
  63. data/spec/functional/resource/dsc_script_spec.rb +1 -0
  64. data/spec/functional/resource/package_spec.rb +1 -1
  65. data/spec/functional/resource/template_spec.rb +3 -3
  66. data/spec/functional/shell_spec.rb +1 -1
  67. data/spec/integration/knife/client_bulk_delete_spec.rb +130 -0
  68. data/spec/integration/knife/client_create_spec.rb +69 -0
  69. data/spec/integration/knife/client_delete_spec.rb +63 -0
  70. data/spec/integration/knife/client_key_create_spec.rb +65 -0
  71. data/spec/integration/knife/client_key_delete_spec.rb +42 -0
  72. data/spec/integration/knife/client_key_list_spec.rb +60 -0
  73. data/spec/integration/knife/client_key_show_spec.rb +44 -0
  74. data/spec/integration/knife/client_list_spec.rb +48 -0
  75. data/spec/integration/knife/client_show_spec.rb +36 -0
  76. data/spec/integration/knife/cookbook_bulk_delete_spec.rb +64 -0
  77. data/spec/integration/knife/cookbook_download_spec.rb +95 -0
  78. data/spec/integration/knife/cookbook_list_spec.rb +54 -0
  79. data/spec/integration/knife/cookbook_show_spec.rb +159 -0
  80. data/spec/integration/knife/cookbook_upload_spec.rb +90 -0
  81. data/spec/integration/knife/data_bag_create_spec.rb +58 -0
  82. data/spec/integration/knife/data_bag_delete_spec.rb +58 -0
  83. data/spec/integration/knife/data_bag_from_file_spec.rb +115 -0
  84. data/spec/integration/knife/data_bag_list_spec.rb +43 -0
  85. data/spec/integration/knife/data_bag_show_spec.rb +53 -0
  86. data/spec/integration/knife/environment_compare_spec.rb +74 -0
  87. data/spec/integration/knife/environment_create_spec.rb +40 -0
  88. data/spec/integration/knife/environment_delete_spec.rb +36 -0
  89. data/spec/integration/knife/environment_from_file_spec.rb +115 -0
  90. data/spec/integration/knife/environment_list_spec.rb +41 -0
  91. data/spec/integration/knife/environment_show_spec.rb +56 -0
  92. data/spec/integration/knife/node_bulk_delete_spec.rb +51 -0
  93. data/spec/integration/knife/node_create_spec.rb +46 -0
  94. data/spec/integration/knife/node_delete_spec.rb +47 -0
  95. data/spec/integration/knife/node_environment_set_spec.rb +42 -0
  96. data/spec/integration/knife/node_from_file_spec.rb +58 -0
  97. data/spec/integration/knife/node_list_spec.rb +44 -0
  98. data/spec/integration/knife/node_run_list_add_spec.rb +53 -0
  99. data/spec/integration/knife/node_run_list_remove_spec.rb +35 -0
  100. data/spec/integration/knife/node_run_list_set_spec.rb +40 -0
  101. data/spec/integration/knife/node_show_spec.rb +35 -0
  102. data/spec/integration/knife/role_bulk_delete_spec.rb +51 -0
  103. data/spec/integration/knife/role_create_spec.rb +40 -0
  104. data/spec/integration/knife/role_delete_spec.rb +47 -0
  105. data/spec/integration/knife/role_from_file_spec.rb +95 -0
  106. data/spec/integration/knife/role_list_spec.rb +44 -0
  107. data/spec/integration/knife/role_show_spec.rb +50 -0
  108. data/spec/support/shared/integration/knife_support.rb +10 -3
  109. data/spec/unit/application/solo_spec.rb +7 -0
  110. data/spec/unit/cookbook_version_spec.rb +4 -4
  111. data/spec/unit/data_collector/messages/helpers_spec.rb +3 -7
  112. data/spec/unit/data_collector/messages_spec.rb +28 -45
  113. data/spec/unit/data_collector_spec.rb +40 -47
  114. data/spec/unit/knife/cookbook_create_spec.rb +1 -0
  115. data/spec/unit/knife/cookbook_site_download_spec.rb +1 -0
  116. data/spec/unit/knife/node_environment_set_spec.rb +0 -24
  117. data/spec/unit/knife/node_run_list_set_spec.rb +0 -25
  118. data/spec/unit/node/attribute_spec.rb +7 -9
  119. data/spec/unit/node/immutable_collections_spec.rb +4 -0
  120. data/spec/unit/node/vivid_mash_spec.rb +344 -0
  121. data/spec/unit/node_spec.rb +115 -26
  122. data/spec/unit/provider/directory_spec.rb +11 -1
  123. data/spec/unit/provider/package/windows/exe_spec.rb +14 -9
  124. data/spec/unit/provider/powershell_script_spec.rb +4 -4
  125. data/spec/unit/provider/remote_directory_spec.rb +15 -0
  126. data/spec/unit/recipe_spec.rb +31 -6
  127. data/spec/unit/run_context_spec.rb +2 -2
  128. data/spec/unit/shell/shell_session_spec.rb +1 -1
  129. data/tasks/dependencies.rb +0 -2
  130. metadata +55 -786
  131. data/acceptance/.bundle/config +0 -2
  132. data/acceptance/basics/.kitchen/logs/chef-current-install-ubuntu-1404.log +0 -2
  133. data/acceptance/basics/.kitchen/logs/kitchen.log +0 -3
  134. data/acceptance/fips/.kitchen/logs/fips-integration-centos-6.log +0 -3
  135. data/acceptance/fips/.kitchen/logs/fips-integration-windows-2012r2.log +0 -3
  136. data/acceptance/fips/.kitchen/logs/fips-unit-functional-centos-6.log +0 -3
  137. data/acceptance/fips/.kitchen/logs/fips-unit-functional-windows-2012r2.log +0 -3
  138. data/acceptance/fips/.kitchen/logs/kitchen.log +0 -6
  139. data/acceptance/trivial/.kitchen/logs/chef-current-install-windows-2012r2.log +0 -2
  140. data/acceptance/trivial/.kitchen/logs/kitchen.log +0 -3
  141. data/acceptance/windows-service/.kitchen/logs/chef-windows-service-windows-2012r2.log +0 -2
  142. data/acceptance/windows-service/.kitchen/logs/kitchen.log +0 -3
@@ -68,17 +68,18 @@ class Chef
68
68
  "id" => run_status.run_id,
69
69
  "message_version" => "1.0.0",
70
70
  "message_type" => "run_converge",
71
+ "node" => run_status.node,
71
72
  "node_name" => run_status.node.name,
72
73
  "organization_name" => organization,
73
- "resources" => reporter_data[:updated_resources].map(&:for_json),
74
+ "resources" => reporter_data[:resources].map(&:report_data),
74
75
  "run_id" => run_status.run_id,
75
76
  "run_list" => run_status.node.run_list.for_json,
76
77
  "start_time" => run_status.start_time.utc.iso8601,
77
78
  "end_time" => run_status.end_time.utc.iso8601,
78
79
  "source" => collector_source,
79
80
  "status" => reporter_data[:status],
80
- "total_resource_count" => reporter_data[:total_resource_count],
81
- "updated_resource_count" => reporter_data[:updated_resources].count,
81
+ "total_resource_count" => reporter_data[:resources].count,
82
+ "updated_resource_count" => reporter_data[:resources].select { |r| r.report_data["status"] == "updated" }.count,
82
83
  }
83
84
 
84
85
  message["error"] = {
@@ -90,36 +91,6 @@ class Chef
90
91
 
91
92
  message
92
93
  end
93
-
94
- #
95
- # Message payload that is sent to the DataCollector server at the
96
- # end of a Chef run.
97
- #
98
- # @param run_status [Chef::RunStatus] The RunStatus instance for this node/run.
99
- #
100
- # @return [Hash] A hash containing the node object and related metadata.
101
- #
102
- def self.node_update_message(run_status)
103
- {
104
- "entity_name" => run_status.node.name,
105
- "entity_type" => "node",
106
- "entity_uuid" => node_uuid,
107
- "id" => SecureRandom.uuid,
108
- "message_version" => "1.1.0",
109
- "message_type" => "action",
110
- "organization_name" => organization,
111
- "recorded_at" => Time.now.utc.iso8601,
112
- "remote_hostname" => run_status.node["fqdn"],
113
- "requestor_name" => run_status.node.name,
114
- "requestor_type" => "client",
115
- "run_id" => run_status.run_id,
116
- "service_hostname" => chef_server_fqdn(run_status),
117
- "source" => collector_source,
118
- "task" => "update",
119
- "user_agent" => Chef::HTTP::HTTPRequest::DEFAULT_UA,
120
- "data" => run_status.node,
121
- }
122
- end
123
94
  end
124
95
  end
125
96
  end
@@ -148,8 +148,8 @@ class Chef
148
148
  end
149
149
 
150
150
  def update_metadata(key, value)
151
- metadata[key] = value
152
- Chef::FileCache.store(metadata_filename, metadata.to_json, 0644)
151
+ updated_metadata = metadata.tap { |x| x[key] = value }
152
+ Chef::FileCache.store(metadata_filename, updated_metadata.to_json, 0644)
153
153
  end
154
154
 
155
155
  def metadata_filename
@@ -22,13 +22,14 @@ class Chef
22
22
  class DataCollector
23
23
  class ResourceReport
24
24
 
25
- attr_reader :action, :current_resource, :elapsed_time, :new_resource, :status
26
- attr_accessor :conditional, :exception
25
+ attr_reader :action, :elapsed_time, :new_resource, :status
26
+ attr_accessor :conditional, :current_resource, :exception
27
27
 
28
28
  def initialize(new_resource, action, current_resource = nil)
29
29
  @new_resource = new_resource
30
30
  @action = action
31
31
  @current_resource = current_resource
32
+ @status = "unprocessed"
32
33
  end
33
34
 
34
35
  def skipped(conditional)
@@ -54,17 +55,26 @@ class Chef
54
55
  @elapsed_time = new_resource.elapsed_time
55
56
  end
56
57
 
58
+ def elapsed_time_in_milliseconds
59
+ elapsed_time.nil? ? nil : (elapsed_time * 1000).to_i
60
+ end
61
+
62
+ def potentially_changed?
63
+ %w{updated failed}.include?(status)
64
+ end
65
+
57
66
  def to_hash
58
67
  hash = {
59
- "type" => new_resource.resource_name.to_sym,
60
- "name" => new_resource.name.to_s,
61
- "id" => new_resource.identity.to_s,
62
- "after" => new_resource.state_for_resource_reporter,
63
- "before" => current_resource ? current_resource.state_for_resource_reporter : {},
64
- "duration" => (elapsed_time * 1000).to_i.to_s,
65
- "delta" => new_resource.respond_to?(:diff) ? new_resource.diff : "",
66
- "result" => action.to_s,
67
- "status" => status,
68
+ "type" => new_resource.resource_name.to_sym,
69
+ "name" => new_resource.name.to_s,
70
+ "id" => new_resource.identity.to_s,
71
+ "after" => new_resource.state_for_resource_reporter,
72
+ "before" => current_resource ? current_resource.state_for_resource_reporter : {},
73
+ "duration" => elapsed_time_in_milliseconds.to_s,
74
+ "delta" => new_resource.respond_to?(:diff) && potentially_changed? ? new_resource.diff : "",
75
+ "ignore_failure" => new_resource.ignore_failure,
76
+ "result" => action.to_s,
77
+ "status" => status,
68
78
  }
69
79
 
70
80
  if new_resource.cookbook_name
@@ -0,0 +1,43 @@
1
+ class Chef
2
+ class Decorator < SimpleDelegator
3
+ #
4
+ # This decorator unchains method call chains and turns them into method calls
5
+ # with variable args. So this:
6
+ #
7
+ # node.set_unless["foo"]["bar"] = "baz"
8
+ #
9
+ # Can become:
10
+ #
11
+ # node.set_unless("foo", "bar", "baz")
12
+ #
13
+ # While this is a decorator it is not a Decorator and does not inherit because
14
+ # it deliberately does not need or want the method_missing magic. It is not legal
15
+ # to call anything on the intermediate values and only supports method chaining with
16
+ # #[] until the chain comes to an end with #[]=, so does not behave like a hash or
17
+ # array... e.g.
18
+ #
19
+ # node.default['foo'].keys is legal
20
+ # node.set_unless['foo'].keys is not legal now or ever
21
+ #
22
+ class Unchain
23
+ attr_accessor :__path__
24
+ attr_accessor :__method__
25
+
26
+ def initialize(obj, method)
27
+ @__path__ = []
28
+ @__method__ = method
29
+ @delegate_sd_obj = obj
30
+ end
31
+
32
+ def [](key)
33
+ __path__.push(key)
34
+ self
35
+ end
36
+
37
+ def []=(key, value)
38
+ __path__.push(key)
39
+ @delegate_sd_obj.public_send(__method__, *__path__, value)
40
+ end
41
+ end
42
+ end
43
+ end
@@ -106,7 +106,12 @@ class Chef
106
106
  # for back compat, need to raise an error that inherits from ArgumentError
107
107
  class CookbookNotFoundInRepo < ArgumentError; end
108
108
  class RecipeNotFound < ArgumentError; end
109
+ # AttributeNotFound really means the attribute file could not be found
109
110
  class AttributeNotFound < RuntimeError; end
111
+ # NoSuchAttribute is raised on access by node.read!("foo", "bar") when node["foo"]["bar"] does not exist.
112
+ class NoSuchAttribute < RuntimeError; end
113
+ # AttributeTypeMismatch is raised by node.write!("foo", "bar", "baz") when e.g. node["foo"] = "bar" (overwriting String with Hash)
114
+ class AttributeTypeMismatch < RuntimeError; end
110
115
  class MissingCookbookDependency < StandardError; end # CHEF-5120
111
116
  class InvalidCommandOption < RuntimeError; end
112
117
  class CommandTimeout < RuntimeError; end
@@ -232,11 +232,11 @@ class Chef
232
232
  # PERFORMANCE CRITICAL: *MUST* lazy require here otherwise we load up webrick
233
233
  # via chef-zero and that hits DNS (at *require* time) which may timeout,
234
234
  # when for most knife/chef-client work we never need/want this loaded.
235
- Thread.exclusive {
236
- unless defined?(SocketlessChefZeroClient)
237
- require "chef/http/socketless_chef_zero_client"
238
- end
239
- }
235
+
236
+ unless defined?(SocketlessChefZeroClient)
237
+ require "chef/http/socketless_chef_zero_client"
238
+ end
239
+
240
240
  SocketlessChefZeroClient.new(base_url)
241
241
  else
242
242
  BasicClient.new(base_url, :ssl_policy => Chef::HTTP::APISSLPolicy)
@@ -56,6 +56,10 @@ class Chef
56
56
  :description => "Email address of cookbook maintainer"
57
57
 
58
58
  def run
59
+ Chef::Log.deprecation <<EOF
60
+ This command is being deprecated in favor of `chef generate cookbook` and will soon return an error.
61
+ Please use `chef generate cookbook` instead of this command.
62
+ EOF
59
63
  self.config = Chef::Config.merge!(config)
60
64
  if @name_args.length < 1
61
65
  show_usage
@@ -37,6 +37,13 @@ class Chef
37
37
  :long => "--force",
38
38
  :description => "Force download deprecated version"
39
39
 
40
+ option :supermarket_site,
41
+ :short => "-m SUPERMARKET_SITE",
42
+ :long => "--supermarket-site SUPERMARKET_SITE",
43
+ :description => "Supermarket Site",
44
+ :default => "https://supermarket.chef.io",
45
+ :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
46
+
40
47
  def run
41
48
  if current_cookbook_deprecated?
42
49
  message = "DEPRECATION: This cookbook has been deprecated. "
@@ -59,7 +66,7 @@ class Chef
59
66
  private
60
67
 
61
68
  def cookbooks_api_url
62
- "https://supermarket.chef.io/api/v1/cookbooks"
69
+ "#{config[:supermarket_site]}/api/v1/cookbooks"
63
70
  end
64
71
 
65
72
  def current_cookbook_data
@@ -59,6 +59,13 @@ class Chef
59
59
  :boolean => true,
60
60
  :default => false
61
61
 
62
+ option :supermarket_site,
63
+ :short => "-m SUPERMARKET_SITE",
64
+ :long => "--supermarket-site SUPERMARKET_SITE",
65
+ :description => "Supermarket Site",
66
+ :default => "https://supermarket.chef.io",
67
+ :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
68
+
62
69
  attr_reader :cookbook_name
63
70
  attr_reader :vendor_path
64
71
 
@@ -134,6 +141,7 @@ class Chef
134
141
  def download_cookbook_to(download_path)
135
142
  downloader = Chef::Knife::CookbookSiteDownload.new
136
143
  downloader.config[:file] = download_path
144
+ downloader.config[:supermarket_site] = config[:supermarket_site]
137
145
  downloader.name_args = name_args
138
146
  downloader.run
139
147
  downloader
@@ -30,6 +30,13 @@ class Chef
30
30
  :long => "--with-uri",
31
31
  :description => "Show corresponding URIs"
32
32
 
33
+ option :supermarket_site,
34
+ :short => "-m SUPERMARKET_SITE",
35
+ :long => "--supermarket-site SUPERMARKET_SITE",
36
+ :description => "Supermarket Site",
37
+ :default => "https://supermarket.chef.io",
38
+ :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
39
+
33
40
  def run
34
41
  if config[:with_uri]
35
42
  cookbooks = Hash.new
@@ -41,7 +48,7 @@ class Chef
41
48
  end
42
49
 
43
50
  def get_cookbook_list(items = 10, start = 0, cookbook_collection = {})
44
- cookbooks_url = "https://supermarket.chef.io/api/v1/cookbooks?items=#{items}&start=#{start}"
51
+ cookbooks_url = "#{config[:supermarket_site]}/api/v1/cookbooks?items=#{items}&start=#{start}"
45
52
  cr = noauth_rest.get(cookbooks_url)
46
53
  cr["items"].each do |cookbook|
47
54
  cookbook_collection[cookbook["cookbook_name"]] = cookbook
@@ -24,12 +24,19 @@ class Chef
24
24
  banner "knife cookbook site search QUERY (options)"
25
25
  category "cookbook site"
26
26
 
27
+ option :supermarket_site,
28
+ :short => "-m SUPERMARKET_SITE",
29
+ :long => "--supermarket-site SUPERMARKET_SITE",
30
+ :description => "Supermarket Site",
31
+ :default => "https://supermarket.chef.io",
32
+ :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
33
+
27
34
  def run
28
35
  output(search_cookbook(name_args[0]))
29
36
  end
30
37
 
31
38
  def search_cookbook(query, items = 10, start = 0, cookbook_collection = {})
32
- cookbooks_url = "https://supermarket.chef.io/api/v1/search?q=#{query}&items=#{items}&start=#{start}"
39
+ cookbooks_url = "#{config[:supermarket_site]}/api/v1/search?q=#{query}&items=#{items}&start=#{start}"
33
40
  cr = noauth_rest.get(cookbooks_url)
34
41
  cr["items"].each do |cookbook|
35
42
  cookbook_collection[cookbook["cookbook_name"]] = cookbook
@@ -50,6 +50,13 @@ class Chef
50
50
  :default => false,
51
51
  :description => "Don't take action, only print what files will be uploaded to Supermarket."
52
52
 
53
+ option :supermarket_site,
54
+ :short => "-m SUPERMARKET_SITE",
55
+ :long => "--supermarket-site SUPERMARKET_SITE",
56
+ :description => "Supermarket Site",
57
+ :default => "https://supermarket.chef.io",
58
+ :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
59
+
53
60
  def run
54
61
  config[:cookbook_path] ||= Chef::Config[:cookbook_path]
55
62
 
@@ -122,7 +129,7 @@ class Chef
122
129
  end
123
130
 
124
131
  def do_upload(cookbook_filename, cookbook_category, user_id, user_secret_filename)
125
- uri = "https://supermarket.chef.io/api/v1/cookbooks"
132
+ uri = "#{config[:supermarket_site]}/api/v1/cookbooks"
126
133
 
127
134
  category_string = Chef::JSONCompat.to_json({ "category" => cookbook_category })
128
135
 
@@ -24,21 +24,32 @@ class Chef
24
24
  banner "knife cookbook site show COOKBOOK [VERSION] (options)"
25
25
  category "cookbook site"
26
26
 
27
+ option :supermarket_site,
28
+ :short => "-m SUPERMARKET_SITE",
29
+ :long => "--supermarket-site SUPERMARKET_SITE",
30
+ :description => "Supermarket Site",
31
+ :default => "https://supermarket.chef.io",
32
+ :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
33
+
27
34
  def run
28
35
  output(format_for_display(get_cookbook_data))
29
36
  end
30
37
 
38
+ def supermarket_uri
39
+ "#{config[:supermarket_site]}/api/v1"
40
+ end
41
+
31
42
  def get_cookbook_data
32
43
  case @name_args.length
33
44
  when 1
34
- noauth_rest.get("https://supermarket.chef.io/api/v1/cookbooks/#{@name_args[0]}")
45
+ noauth_rest.get("#{supermarket_uri}/cookbooks/#{@name_args[0]}")
35
46
  when 2
36
- noauth_rest.get("https://supermarket.chef.io/api/v1/cookbooks/#{@name_args[0]}/versions/#{name_args[1].tr('.', '_')}")
47
+ noauth_rest.get("#{supermarket_uri}/cookbooks/#{@name_args[0]}/versions/#{name_args[1].tr('.', '_')}")
37
48
  end
38
49
  end
39
50
 
40
51
  def get_cookbook_list(items = 10, start = 0, cookbook_collection = {})
41
- cookbooks_url = "https://supermarket.chef.io/api/v1/cookbooks?items=#{items}&start=#{start}"
52
+ cookbooks_url = "#{supermarket_uri}/cookbooks?items=#{items}&start=#{start}"
42
53
  cr = noauth_rest.get(cookbooks_url)
43
54
  cr["items"].each do |cookbook|
44
55
  cookbook_collection[cookbook["cookbook_name"]] = cookbook
@@ -30,6 +30,13 @@ class Chef
30
30
  banner "knife cookbook site unshare COOKBOOK"
31
31
  category "cookbook site"
32
32
 
33
+ option :supermarket_site,
34
+ :short => "-m SUPERMARKET_SITE",
35
+ :long => "--supermarket-site SUPERMARKET_SITE",
36
+ :description => "Supermarket Site",
37
+ :default => "https://supermarket.chef.io",
38
+ :proc => Proc.new { |supermarket| Chef::Config[:knife][:supermarket_site] = supermarket }
39
+
33
40
  def run
34
41
  @cookbook_name = @name_args[0]
35
42
  if @cookbook_name.nil?
@@ -41,7 +48,7 @@ class Chef
41
48
  confirm "Do you really want to unshare all versions of the cookbook #{@cookbook_name}"
42
49
 
43
50
  begin
44
- rest.delete "https://supermarket.chef.io/api/v1/cookbooks/#{@name_args[0]}"
51
+ rest.delete "#{config[:supermarket_site]}/api/v1/cookbooks/#{@name_args[0]}"
45
52
  rescue Net::HTTPServerException => e
46
53
  raise e unless e.message =~ /Forbidden/
47
54
  ui.error "Forbidden: You must be the maintainer of #{@cookbook_name} to unshare it."
@@ -54,7 +54,7 @@ class Chef
54
54
  end
55
55
 
56
56
  def client_d
57
- @cliend_d ||= client_d_content
57
+ @client_d ||= client_d_content
58
58
  end
59
59
 
60
60
  def encrypted_data_bag_secret
@@ -0,0 +1,33 @@
1
+ #
2
+ # Author:: Christopher Webber (<cwebber@chef.io>)
3
+ # Copyright:: Copyright (c) 2014 Chef Software, 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 "chef/knife/cookbook_site_download"
21
+
22
+ class Chef
23
+ class Knife
24
+ class SupermarketDownload < Knife::CookbookSiteDownload
25
+ # Handle the subclassing (knife doesn't do this :()
26
+ dependency_loaders.concat(superclass.dependency_loaders)
27
+ options.merge!(superclass.options)
28
+
29
+ banner "knife supermarket download COOKBOOK [VERSION] (options)"
30
+ category "supermarket"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ #
2
+ # Author:: Christopher Webber (<cwebber@chef.io>)
3
+ # Copyright:: Copyright (c) 2014 Chef Software, 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 "chef/knife/cookbook_site_install"
21
+
22
+ class Chef
23
+ class Knife
24
+ class SupermarketInstall < Knife::CookbookSiteInstall
25
+ # Handle the subclassing (knife doesn't do this :()
26
+ dependency_loaders.concat(superclass.dependency_loaders)
27
+ options.merge!(superclass.options)
28
+
29
+ banner "knife supermarket install COOKBOOK [VERSION] (options)"
30
+ category "supermarket"
31
+ end
32
+ end
33
+ end