chef 14.8.12-universal-mingw32 → 14.9.13-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/chef.gemspec +1 -1
  4. data/distro/ruby_bin_folder/msvcp140.dll +0 -0
  5. data/distro/ruby_bin_folder/vcruntime140.dll +0 -0
  6. data/lib/chef/api_client.rb +1 -1
  7. data/lib/chef/api_client/registration.rb +1 -1
  8. data/lib/chef/api_client_v1.rb +4 -4
  9. data/lib/chef/chef_fs/file_system/chef_server/acl_entry.rb +1 -1
  10. data/lib/chef/chef_fs/file_system/chef_server/cookbook_dir.rb +2 -2
  11. data/lib/chef/chef_fs/file_system/chef_server/cookbook_file.rb +1 -1
  12. data/lib/chef/chef_fs/file_system/chef_server/cookbooks_dir.rb +1 -1
  13. data/lib/chef/chef_fs/file_system/chef_server/data_bag_dir.rb +1 -1
  14. data/lib/chef/chef_fs/file_system/chef_server/data_bags_dir.rb +2 -2
  15. data/lib/chef/chef_fs/file_system/chef_server/nodes_dir.rb +1 -1
  16. data/lib/chef/chef_fs/file_system/chef_server/organization_invites_entry.rb +1 -1
  17. data/lib/chef/chef_fs/file_system/chef_server/organization_members_entry.rb +1 -1
  18. data/lib/chef/chef_fs/file_system/chef_server/policies_dir.rb +3 -3
  19. data/lib/chef/chef_fs/file_system/chef_server/policy_group_entry.rb +2 -2
  20. data/lib/chef/chef_fs/file_system/chef_server/rest_list_dir.rb +3 -3
  21. data/lib/chef/chef_fs/file_system/chef_server/rest_list_entry.rb +4 -4
  22. data/lib/chef/client.rb +2 -2
  23. data/lib/chef/config_fetcher.rb +1 -1
  24. data/lib/chef/cookbook_uploader.rb +3 -3
  25. data/lib/chef/cookbook_version.rb +1 -1
  26. data/lib/chef/data_bag.rb +1 -1
  27. data/lib/chef/data_bag_item.rb +1 -1
  28. data/lib/chef/environment.rb +1 -1
  29. data/lib/chef/formatters/error_inspectors/cookbook_resolve_error_inspector.rb +1 -1
  30. data/lib/chef/formatters/error_inspectors/cookbook_sync_error_inspector.rb +1 -1
  31. data/lib/chef/formatters/error_inspectors/node_load_error_inspector.rb +1 -1
  32. data/lib/chef/formatters/error_inspectors/registration_error_inspector.rb +1 -1
  33. data/lib/chef/formatters/error_inspectors/run_list_expansion_error_inspector.rb +1 -1
  34. data/lib/chef/http.rb +3 -3
  35. data/lib/chef/key.rb +1 -1
  36. data/lib/chef/knife.rb +1 -1
  37. data/lib/chef/knife/bootstrap/client_builder.rb +1 -1
  38. data/lib/chef/knife/cookbook_delete.rb +1 -1
  39. data/lib/chef/knife/cookbook_upload.rb +1 -1
  40. data/lib/chef/knife/data_bag_create.rb +1 -1
  41. data/lib/chef/knife/raw.rb +1 -1
  42. data/lib/chef/knife/search.rb +1 -1
  43. data/lib/chef/knife/supermarket_share.rb +1 -1
  44. data/lib/chef/knife/supermarket_unshare.rb +1 -1
  45. data/lib/chef/mixin/api_version_request_handling.rb +1 -1
  46. data/lib/chef/monkey_patches/net_http.rb +5 -1
  47. data/lib/chef/node.rb +4 -4
  48. data/lib/chef/node/mixin/immutablize_array.rb +5 -0
  49. data/lib/chef/node/mixin/immutablize_hash.rb +3 -0
  50. data/lib/chef/org.rb +1 -1
  51. data/lib/chef/policy_builder/policyfile.rb +1 -1
  52. data/lib/chef/provider/apt_repository.rb +1 -1
  53. data/lib/chef/provider/group/windows.rb +1 -0
  54. data/lib/chef/provider/remote_file/content.rb +1 -1
  55. data/lib/chef/provider/windows_task.rb +2 -2
  56. data/lib/chef/resource/group.rb +4 -0
  57. data/lib/chef/resource/homebrew_cask.rb +8 -8
  58. data/lib/chef/resource/homebrew_tap.rb +6 -6
  59. data/lib/chef/resource/openssl_ec_private_key.rb +1 -1
  60. data/lib/chef/resource/openssl_x509_request.rb +1 -1
  61. data/lib/chef/resource/powershell_package_source.rb +11 -7
  62. data/lib/chef/resource/ssh_known_hosts_entry.rb +1 -1
  63. data/lib/chef/resource/sysctl.rb +6 -6
  64. data/lib/chef/resource/timezone.rb +17 -1
  65. data/lib/chef/resource/windows_ad_join.rb +11 -1
  66. data/lib/chef/resource/windows_certificate.rb +7 -4
  67. data/lib/chef/resource/windows_printer.rb +3 -3
  68. data/lib/chef/resource/windows_task.rb +17 -8
  69. data/lib/chef/role.rb +1 -1
  70. data/lib/chef/run_list/run_list_expansion.rb +1 -1
  71. data/lib/chef/user.rb +1 -1
  72. data/lib/chef/user_v1.rb +4 -4
  73. data/lib/chef/util/windows/net_group.rb +6 -0
  74. data/lib/chef/version.rb +1 -1
  75. data/lib/chef/win32/api/net.rb +16 -0
  76. data/lib/chef/win32/net.rb +15 -0
  77. data/lib/chef/win32/version.rb +15 -15
  78. data/spec/functional/http/simple_spec.rb +10 -10
  79. data/spec/functional/resource/timezone_spec.rb +39 -0
  80. data/spec/functional/resource/windows_task_spec.rb +51 -7
  81. data/spec/integration/knife/client_create_spec.rb +1 -1
  82. data/spec/integration/knife/client_key_create_spec.rb +1 -1
  83. data/spec/integration/knife/cookbook_download_spec.rb +1 -1
  84. data/spec/integration/knife/cookbook_show_spec.rb +2 -2
  85. data/spec/integration/knife/data_bag_create_spec.rb +1 -1
  86. data/spec/integration/knife/environment_create_spec.rb +1 -1
  87. data/spec/integration/knife/node_create_spec.rb +1 -1
  88. data/spec/integration/knife/role_create_spec.rb +1 -1
  89. data/spec/support/shared/context/client.rb +1 -1
  90. data/spec/support/shared/unit/api_error_inspector.rb +5 -5
  91. data/spec/support/shared/unit/api_versioning.rb +2 -2
  92. data/spec/unit/api_client/registration_spec.rb +1 -1
  93. data/spec/unit/api_client_spec.rb +2 -2
  94. data/spec/unit/api_client_v1_spec.rb +3 -3
  95. data/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +1 -1
  96. data/spec/unit/client_spec.rb +2 -2
  97. data/spec/unit/data_bag_item_spec.rb +1 -1
  98. data/spec/unit/data_bag_spec.rb +1 -1
  99. data/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +4 -4
  100. data/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +2 -2
  101. data/spec/unit/knife/bootstrap/client_builder_spec.rb +1 -1
  102. data/spec/unit/knife/cookbook_delete_spec.rb +3 -3
  103. data/spec/unit/knife/data_bag_create_spec.rb +2 -2
  104. data/spec/unit/knife/supermarket_share_spec.rb +1 -1
  105. data/spec/unit/knife/supermarket_unshare_spec.rb +3 -3
  106. data/spec/unit/knife_spec.rb +7 -7
  107. data/spec/unit/mixin/api_version_request_handling_spec.rb +2 -2
  108. data/spec/unit/node_spec.rb +2 -2
  109. data/spec/unit/policy_builder/policyfile_spec.rb +2 -2
  110. data/spec/unit/provider/group/windows_spec.rb +15 -0
  111. data/spec/unit/provider/remote_file/content_spec.rb +2 -2
  112. data/spec/unit/resource/group_spec.rb +17 -0
  113. data/spec/unit/resource/powershell_package_source_spec.rb +2 -2
  114. data/spec/unit/resource/windows_certificate.rb +7 -0
  115. data/spec/unit/resource/windows_task_spec.rb +61 -20
  116. data/spec/unit/resource_reporter_spec.rb +7 -7
  117. data/spec/unit/user_v1_spec.rb +2 -2
  118. metadata +15 -6
@@ -152,7 +152,7 @@ class Chef
152
152
  response.error! unless success_response?(response)
153
153
  return_value
154
154
 
155
- rescue Net::HTTPServerException => e
155
+ rescue Net::HTTPClientException => e
156
156
  http_attempts += 1
157
157
  response = e.response
158
158
  if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
@@ -190,7 +190,7 @@ class Chef
190
190
  response.error!
191
191
  end
192
192
  tempfile
193
- rescue Net::HTTPServerException => e
193
+ rescue Net::HTTPClientException => e
194
194
  http_attempts += 1
195
195
  response = e.response
196
196
  if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
@@ -245,7 +245,7 @@ class Chef
245
245
  end
246
246
  end
247
247
  tempfile
248
- rescue Net::HTTPServerException => e
248
+ rescue Net::HTTPClientException => e
249
249
  http_attempts += 1
250
250
  response = e.response
251
251
  if response.kind_of?(Net::HTTPNotAcceptable) && version_retries - http_attempts > 0
@@ -187,7 +187,7 @@ class Chef
187
187
 
188
188
  def save
189
189
  create
190
- rescue Net::HTTPServerException => e
190
+ rescue Net::HTTPClientException => e
191
191
  if e.response.code == "409"
192
192
  update
193
193
  else
@@ -455,7 +455,7 @@ class Chef
455
455
  case e
456
456
  when SystemExit
457
457
  raise # make sure exit passes through.
458
- when Net::HTTPServerException, Net::HTTPFatalError
458
+ when Net::HTTPClientException, Net::HTTPFatalError
459
459
  humanize_http_exception(e)
460
460
  when OpenSSL::SSL::SSLError
461
461
  ui.error "Could not establish a secure connection to the server."
@@ -187,7 +187,7 @@ class Chef
187
187
  def resource_exists?(relative_path)
188
188
  rest.get(relative_path)
189
189
  true
190
- rescue Net::HTTPServerException => e
190
+ rescue Net::HTTPClientException => e
191
191
  raise unless e.response.code == "404"
192
192
  false
193
193
  end
@@ -88,7 +88,7 @@ class Chef
88
88
  @available_versions ||= rest.get("cookbooks/#{@cookbook_name}").map do |name, url_and_version|
89
89
  url_and_version["versions"].map { |url_by_version| url_by_version["version"] }
90
90
  end.flatten
91
- rescue Net::HTTPServerException => e
91
+ rescue Net::HTTPClientException => e
92
92
  if e.to_s =~ /^404/
93
93
  ui.error("Cannot find a cookbook named #{@cookbook_name} to delete.")
94
94
  nil
@@ -226,7 +226,7 @@ WARNING
226
226
 
227
227
  def assert_environment_valid!
228
228
  environment
229
- rescue Net::HTTPServerException => e
229
+ rescue Net::HTTPClientException => e
230
230
  if e.response.code.to_s == "404"
231
231
  ui.error "The environment #{config[:environment]} does not exist on the server, aborting."
232
232
  Log.debug(e)
@@ -53,7 +53,7 @@ class Chef
53
53
  begin
54
54
  rest.get("data/#{@data_bag_name}")
55
55
  ui.info("Data bag #{@data_bag_name} already exists")
56
- rescue Net::HTTPServerException => e
56
+ rescue Net::HTTPClientException => e
57
57
  raise unless e.to_s =~ /^404/
58
58
  # if it doesn't exists, try to create it
59
59
  rest.post("data", { "name" => @data_bag_name })
@@ -112,7 +112,7 @@ class Chef
112
112
  rescue Timeout::Error => e
113
113
  ui.error "Server timeout"
114
114
  exit 1
115
- rescue Net::HTTPServerException => e
115
+ rescue Net::HTTPClientException => e
116
116
  ui.error "Server responded with error #{e.response.code} \"#{e.response.message}\""
117
117
  ui.error "Error Body: #{e.response.body}" if e.response.body && e.response.body != ""
118
118
  exit 1
@@ -109,7 +109,7 @@ class Chef
109
109
  result_items << formatted_item
110
110
  result_count += 1
111
111
  end
112
- rescue Net::HTTPServerException => e
112
+ rescue Net::HTTPClientException => e
113
113
  msg = Chef::JSONCompat.from_json(e.response.body)["error"].first
114
114
  ui.error("knife search failed: #{msg}")
115
115
  exit 99
@@ -116,7 +116,7 @@ class Chef
116
116
  data = noauth_rest.get("#{config[:supermarket_site]}/api/v1/cookbooks/#{@name_args[0]}")
117
117
  data["category"]
118
118
  rescue => e
119
- return "Other" if e.kind_of?(Net::HTTPServerException) && e.response.code == "404"
119
+ return "Other" if e.kind_of?(Net::HTTPClientException) && e.response.code == "404"
120
120
  ui.fatal("Unable to reach Supermarket: #{e.message}. Increase log verbosity (-VV) for more information.")
121
121
  Chef::Log.trace("\n#{e.backtrace.join("\n")}")
122
122
  exit(1)
@@ -48,7 +48,7 @@ class Chef
48
48
 
49
49
  begin
50
50
  rest.delete "#{config[:supermarket_site]}/api/v1/cookbooks/#{@name_args[0]}"
51
- rescue Net::HTTPServerException => e
51
+ rescue Net::HTTPClientException => e
52
52
  raise e unless e.message =~ /Forbidden/
53
53
  ui.error "Forbidden: You must be the maintainer of #{@cookbook_name} to unshare it."
54
54
  exit 1
@@ -19,7 +19,7 @@
19
19
  class Chef
20
20
  module Mixin
21
21
  module ApiVersionRequestHandling
22
- # @param exeception [Net::HTTPServerException] may or may not contain the x-ops-server-api-version header
22
+ # @param exeception [Net::HTTPClientException] may or may not contain the x-ops-server-api-version header
23
23
  # supported_client_versions:
24
24
  # @param supported_client_versions [Array<Integer>] The API versions the client supports.
25
25
  #
@@ -5,6 +5,10 @@ module ChefNetHTTPExceptionExtensions
5
5
  attr_accessor :chef_rest_request
6
6
  end
7
7
 
8
+ unless defined?(Net::HTTPClientException)
9
+ Net::HTTPClientException = Net::HTTPServerException
10
+ end
11
+
8
12
  require "net/http"
9
13
  module Net
10
14
  class HTTPError
@@ -13,7 +17,7 @@ module Net
13
17
  class HTTPRetriableError
14
18
  include ChefNetHTTPExceptionExtensions
15
19
  end
16
- class HTTPServerException
20
+ class HTTPClientException
17
21
  include ChefNetHTTPExceptionExtensions
18
22
  end
19
23
  class HTTPFatalError
@@ -575,7 +575,7 @@ class Chef
575
575
 
576
576
  def self.find_or_create(node_name)
577
577
  load(node_name)
578
- rescue Net::HTTPServerException => e
578
+ rescue Net::HTTPClientException => e
579
579
  raise unless e.response.code == "404"
580
580
  node = build(node_name)
581
581
  node.create
@@ -608,7 +608,7 @@ class Chef
608
608
  else
609
609
  chef_server_rest.put("nodes/#{name}", data_for_save)
610
610
  end
611
- rescue Net::HTTPServerException => e
611
+ rescue Net::HTTPClientException => e
612
612
  if e.response.code == "404"
613
613
  chef_server_rest.post("nodes", data_for_save)
614
614
  else
@@ -622,7 +622,7 @@ class Chef
622
622
  def create
623
623
  chef_server_rest.post("nodes", data_for_save)
624
624
  self
625
- rescue Net::HTTPServerException => e
625
+ rescue Net::HTTPClientException => e
626
626
  # Chef Server before 12.3 rejects node JSON with 'policy_name' or
627
627
  # 'policy_group' keys, but 'policy_name' will be detected first.
628
628
  # Backcompat can be removed in 13.0
@@ -655,7 +655,7 @@ class Chef
655
655
  trimmed_data = data_for_save_without_policyfile_attrs
656
656
 
657
657
  chef_server_rest.put("nodes/#{name}", trimmed_data)
658
- rescue Net::HTTPServerException => e
658
+ rescue Net::HTTPClientException => e
659
659
  raise e unless e.response.code == "404"
660
660
  chef_server_rest.post("nodes", trimmed_data)
661
661
  end
@@ -34,6 +34,7 @@ class Chef
34
34
  :at,
35
35
  :bsearch,
36
36
  :bsearch_index,
37
+ :chain,
37
38
  :chunk,
38
39
  :chunk_while,
39
40
  :collect,
@@ -43,6 +44,7 @@ class Chef
43
44
  :count,
44
45
  :cycle,
45
46
  :detect,
47
+ :difference,
46
48
  :dig,
47
49
  :drop,
48
50
  :drop_while,
@@ -56,6 +58,7 @@ class Chef
56
58
  :empty?,
57
59
  :entries,
58
60
  :fetch,
61
+ :filter,
59
62
  :find,
60
63
  :find_all,
61
64
  :find_index,
@@ -117,6 +120,7 @@ class Chef
117
120
  :to_plist,
118
121
  :to_set,
119
122
  :transpose,
123
+ :union,
120
124
  :uniq,
121
125
  :values_at,
122
126
  :zip,
@@ -139,6 +143,7 @@ class Chef
139
143
  :delete_at,
140
144
  :delete_if,
141
145
  :fill,
146
+ :filter!,
142
147
  :flatten!,
143
148
  :insert,
144
149
  :keep_if,
@@ -30,6 +30,7 @@ class Chef
30
30
  :all?,
31
31
  :any?,
32
32
  :assoc,
33
+ :chain,
33
34
  :chunk,
34
35
  :chunk_while,
35
36
  :collect,
@@ -58,6 +59,7 @@ class Chef
58
59
  :entries,
59
60
  :fetch,
60
61
  :fetch_values,
62
+ :filter,
61
63
  :find,
62
64
  :find_all,
63
65
  :find_index,
@@ -131,6 +133,7 @@ class Chef
131
133
  :default_proc=,
132
134
  :delete,
133
135
  :delete_if,
136
+ :filter!,
134
137
  :keep_if,
135
138
  :map!,
136
139
  :merge!,
@@ -92,7 +92,7 @@ class Chef
92
92
 
93
93
  def save
94
94
  create
95
- rescue Net::HTTPServerException => e
95
+ rescue Net::HTTPClientException => e
96
96
  if e.response.code == "409"
97
97
  update
98
98
  else
@@ -311,7 +311,7 @@ class Chef
311
311
  # @api private
312
312
  def policy
313
313
  @policy ||= api_service.get(policyfile_location)
314
- rescue Net::HTTPServerException => e
314
+ rescue Net::HTTPClientException => e
315
315
  raise ConfigurationError, "Error loading policyfile from `#{policyfile_location}': #{e.class} - #{e.message}"
316
316
  end
317
317
 
@@ -271,7 +271,7 @@ class Chef
271
271
  url = "https://launchpad.net/api/1.0/~#{owner}/+archive/#{repo}"
272
272
  key_id = Chef::HTTP::Simple.new(url).get("signing_key_fingerprint").delete('"')
273
273
  install_key_from_keyserver(key_id, "keyserver.ubuntu.com")
274
- rescue Net::HTTPServerException => e
274
+ rescue Net::HTTPClientException => e
275
275
  raise "Could not access Launchpad ppa API: #{e.message}"
276
276
  end
277
277
 
@@ -77,6 +77,7 @@ class Chef
77
77
  else
78
78
  @net_group.local_set_members(new_resource.members)
79
79
  end
80
+ @net_group.local_group_set_info(new_resource.comment) if new_resource.comment
80
81
  end
81
82
 
82
83
  def has_current_group_member?(member)
@@ -54,7 +54,7 @@ class Chef
54
54
  as_uri(source)
55
55
  end
56
56
  raw_file = grab_file_from_uri(uri)
57
- rescue SocketError, Errno::ECONNREFUSED, Errno::ENOENT, Errno::EACCES, Timeout::Error, Net::HTTPServerException, Net::HTTPFatalError, Net::FTPError, Errno::ETIMEDOUT => e
57
+ rescue SocketError, Errno::ECONNREFUSED, Errno::ENOENT, Errno::EACCES, Timeout::Error, Net::HTTPClientException, Net::HTTPFatalError, Net::FTPError, Errno::ETIMEDOUT => e
58
58
  logger.warn("#{@new_resource} cannot be downloaded from #{source}: #{e}")
59
59
  if source = sources.shift
60
60
  logger.info("#{@new_resource} trying to download from another mirror")
@@ -145,7 +145,7 @@ class Chef
145
145
  task.working_directory = new_resource.cwd if new_resource.cwd
146
146
  task.configure_settings(config_settings)
147
147
  task.configure_principals(principal_settings)
148
- task.set_account_information(new_resource.user, new_resource.password)
148
+ task.set_account_information(new_resource.user, new_resource.password, new_resource.interactive_enabled)
149
149
  task.creator = new_resource.user
150
150
  task.description = new_resource.description unless new_resource.description.nil?
151
151
  task.activate(new_resource.task_name)
@@ -246,7 +246,7 @@ class Chef
246
246
 
247
247
  def update_task(task)
248
248
  converge_by("#{new_resource} task updated") do
249
- task.set_account_information(new_resource.user, new_resource.password)
249
+ task.set_account_information(new_resource.user, new_resource.password, new_resource.interactive_enabled)
250
250
  task.application_name = new_resource.command if new_resource.command
251
251
  task.parameters = new_resource.command_arguments if new_resource.command_arguments
252
252
  task.working_directory = new_resource.cwd if new_resource.cwd
@@ -51,6 +51,10 @@ class Chef
51
51
  property :non_unique, [ TrueClass, FalseClass ], default: false,
52
52
  description: "Allow gid duplication. May only be used with the Groupadd provider."
53
53
 
54
+ property :comment, String,
55
+ introduced: "14.9",
56
+ description: "Specifies a comment to associate with the local group."
57
+
54
58
  alias_method :users, :members
55
59
  end
56
60
  end
@@ -55,11 +55,11 @@ class Chef
55
55
  action :install do
56
56
  description "Install an application packaged as a Homebrew cask."
57
57
 
58
- homebrew_tap "caskroom/cask" if new_resource.install_cask
58
+ homebrew_tap "homebrew/cask" if new_resource.install_cask
59
59
 
60
60
  unless casked?
61
- converge_by("install cask #{new_resource.name} #{new_resource.options}") do
62
- shell_out!("#{new_resource.homebrew_path} cask install #{new_resource.name} #{new_resource.options}",
61
+ converge_by("install cask #{new_resource.cask_name} #{new_resource.options}") do
62
+ shell_out!("#{new_resource.homebrew_path} cask install #{new_resource.cask_name} #{new_resource.options}",
63
63
  user: new_resource.owner,
64
64
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
65
65
  cwd: ::Dir.home(new_resource.owner))
@@ -70,11 +70,11 @@ class Chef
70
70
  action :remove do
71
71
  description "Remove an application packaged as a Homebrew cask."
72
72
 
73
- homebrew_tap "caskroom/cask" if new_resource.install_cask
73
+ homebrew_tap "homebrew/cask" if new_resource.install_cask
74
74
 
75
75
  if casked?
76
- converge_by("uninstall cask #{new_resource.name}") do
77
- shell_out!("#{new_resource.homebrew_path} cask uninstall #{new_resource.name}",
76
+ converge_by("uninstall cask #{new_resource.cask_name}") do
77
+ shell_out!("#{new_resource.homebrew_path} cask uninstall #{new_resource.cask_name}",
78
78
  user: new_resource.owner,
79
79
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
80
80
  cwd: ::Dir.home(new_resource.owner))
@@ -88,8 +88,8 @@ class Chef
88
88
  alias_method :action_uninstall, :action_remove
89
89
 
90
90
  def casked?
91
- unscoped_name = new_resource.name.split("/").last
92
- shell_out!('#{new_resource.homebrew_path} cask list 2>/dev/null',
91
+ unscoped_name = new_resource.cask_name.split("/").last
92
+ shell_out!("#{new_resource.homebrew_path} cask list 2>/dev/null",
93
93
  user: new_resource.owner,
94
94
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
95
95
  cwd: ::Dir.home(new_resource.owner)).stdout.split.include?(unscoped_name)
@@ -55,9 +55,9 @@ class Chef
55
55
  action :tap do
56
56
  description "Add a Homebrew tap."
57
57
 
58
- unless tapped?(new_resource.name)
59
- converge_by("tap #{new_resource.name}") do
60
- shell_out!("#{new_resource.homebrew_path} tap #{new_resource.full ? '--full' : ''} #{new_resource.name} #{new_resource.url || ''}",
58
+ unless tapped?(new_resource.tap_name)
59
+ converge_by("tap #{new_resource.tap_name}") do
60
+ shell_out!("#{new_resource.homebrew_path} tap #{new_resource.full ? '--full' : ''} #{new_resource.tap_name} #{new_resource.url || ''}",
61
61
  user: new_resource.owner,
62
62
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
63
63
  cwd: ::Dir.home(new_resource.owner))
@@ -68,9 +68,9 @@ class Chef
68
68
  action :untap do
69
69
  description "Remove a Homebrew tap."
70
70
 
71
- if tapped?(new_resource.name)
72
- converge_by("untap #{new_resource.name}") do
73
- shell_out!("#{new_resource.homebrew_path} untap #{new_resource.name}",
71
+ if tapped?(new_resource.tap_name)
72
+ converge_by("untap #{new_resource.tap_name}") do
73
+ shell_out!("#{new_resource.homebrew_path} untap #{new_resource.tap_name}",
74
74
  user: new_resource.owner,
75
75
  env: { "HOME" => ::Dir.home(new_resource.owner), "USER" => new_resource.owner },
76
76
  cwd: ::Dir.home(new_resource.owner))
@@ -68,7 +68,7 @@ class Chef
68
68
  unless new_resource.force || priv_key_file_valid?(new_resource.path, new_resource.key_pass)
69
69
  converge_by("Create an EC private key #{new_resource.path}") do
70
70
  log "Generating an #{new_resource.key_curve} "\
71
- "EC key file at #{new_resource.name}, this may take some time"
71
+ "EC key file at #{new_resource.path}, this may take some time"
72
72
 
73
73
  if new_resource.key_pass
74
74
  unencrypted_ec_key = gen_ec_priv_key(new_resource.key_curve)
@@ -89,7 +89,7 @@ class Chef
89
89
 
90
90
  unless ::File.exist? new_resource.path
91
91
  converge_by("Create CSR #{@new_resource}") do
92
- file new_resource.name do
92
+ file new_resource.path do
93
93
  owner new_resource.owner unless new_resource.owner.nil?
94
94
  group new_resource.group unless new_resource.group.nil?
95
95
  mode new_resource.mode unless new_resource.mode.nil?
@@ -55,10 +55,14 @@ class Chef
55
55
  description: "The location where scripts will be published to for this source. Only valid if the provider is 'PowerShellGet'."
56
56
 
57
57
  load_current_value do
58
- cmd = load_resource_state_script(name)
58
+ cmd = load_resource_state_script(source_name)
59
59
  repo = powershell_out!(cmd)
60
- status = Chef::JSONCompat.from_json(repo.stdout)
61
- url status["url"].nil? ? "not_set" : status["url"]
60
+ if repo.stdout.empty?
61
+ current_value_does_not_exist!
62
+ else
63
+ status = Chef::JSONCompat.from_json(repo.stdout)
64
+ end
65
+ url status["url"]
62
66
  trusted status["trusted"]
63
67
  provider_name status["provider_name"]
64
68
  publish_location status["publish_location"]
@@ -113,7 +117,7 @@ class Chef
113
117
 
114
118
  action_class do
115
119
  def package_source_exists?
116
- cmd = powershell_out!("(Get-PackageSource -Name '#{new_resource.source_name}').Name")
120
+ cmd = powershell_out!("(Get-PackageSource -Name '#{new_resource.source_name}' -WarningAction SilentlyContinue).Name")
117
121
  cmd.stdout.downcase.strip == new_resource.source_name.downcase
118
122
  end
119
123
 
@@ -145,6 +149,9 @@ class Chef
145
149
 
146
150
  def load_resource_state_script(name)
147
151
  <<-EOH
152
+ $PSDefaultParameterValues = @{
153
+ "*:WarningAction" = "SilentlyContinue"
154
+ }
148
155
  if(Get-PackageSource -Name '#{name}' -ErrorAction SilentlyContinue) {
149
156
  if ((Get-PackageSource -Name '#{name}').ProviderName -eq 'PowerShellGet') {
150
157
  (Get-PSRepository -Name '#{name}') | Select @{n='source_name';e={$_.Name}}, @{n='url';e={$_.SourceLocation}},
@@ -156,9 +163,6 @@ class Chef
156
163
  @{n='provider_name';e={$_.ProviderName}}, @{n='trusted';e={$_.IsTrusted}} | ConvertTo-Json
157
164
  }
158
165
  }
159
- else {
160
- "" | Select source_name, url, provider_name, trusted | ConvertTo-Json
161
- }
162
166
  EOH
163
167
  end
164
168
  end