chef 14.5.33 → 14.6.47

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -3
  3. data/chef-universal-mingw32.gemspec +3 -2
  4. data/chef.gemspec +3 -4
  5. data/lib/chef/api_client.rb +5 -3
  6. data/lib/chef/api_client_v1.rb +6 -4
  7. data/lib/chef/application.rb +1 -1
  8. data/lib/chef/audit/audit_reporter.rb +1 -1
  9. data/lib/chef/audit/control_group_data.rb +12 -6
  10. data/lib/chef/chef_fs/chef_fs_data_store.rb +2 -2
  11. data/lib/chef/chef_fs/data_handler/data_handler_base.rb +1 -1
  12. data/lib/chef/cookbook/manifest_v0.rb +34 -29
  13. data/lib/chef/cookbook/manifest_v2.rb +15 -11
  14. data/lib/chef/cookbook/metadata.rb +4 -2
  15. data/lib/chef/cookbook_manifest.rb +8 -5
  16. data/lib/chef/cookbook_version.rb +1 -1
  17. data/lib/chef/data_bag.rb +4 -2
  18. data/lib/chef/data_bag_item.rb +5 -3
  19. data/lib/chef/data_collector.rb +2 -2
  20. data/lib/chef/data_collector/resource_report.rb +4 -4
  21. data/lib/chef/encrypted_data_bag_item.rb +4 -2
  22. data/lib/chef/environment.rb +4 -2
  23. data/lib/chef/file_content_management/deploy/mv_unix.rb +5 -4
  24. data/lib/chef/handler.rb +2 -2
  25. data/lib/chef/json_compat.rb +1 -1
  26. data/lib/chef/key.rb +7 -5
  27. data/lib/chef/knife/bootstrap.rb +7 -1
  28. data/lib/chef/knife/client_edit.rb +2 -2
  29. data/lib/chef/knife/data_bag_show.rb +2 -2
  30. data/lib/chef/knife/osc_user_edit.rb +2 -2
  31. data/lib/chef/knife/user_edit.rb +2 -2
  32. data/lib/chef/mixin/params_validate.rb +4 -2
  33. data/lib/chef/node/attribute.rb +4 -4
  34. data/lib/chef/org.rb +6 -4
  35. data/lib/chef/policy_builder/policyfile.rb +5 -3
  36. data/lib/chef/provider/package.rb +9 -4
  37. data/lib/chef/provider/package/windows.rb +23 -1
  38. data/lib/chef/provider/package/yum/yum_helper.py +3 -2
  39. data/lib/chef/provider/package/zypper.rb +12 -8
  40. data/lib/chef/provider/registry_key.rb +15 -6
  41. data/lib/chef/provider/user/windows.rb +4 -3
  42. data/lib/chef/provider/windows_task.rb +11 -2
  43. data/lib/chef/resource.rb +3 -1
  44. data/lib/chef/resource/locale.rb +1 -1
  45. data/lib/chef/resource/ohai_hint.rb +4 -4
  46. data/lib/chef/resource/rhsm_errata_level.rb +1 -1
  47. data/lib/chef/resource/timezone.rb +91 -0
  48. data/lib/chef/resource/user/windows_user.rb +4 -0
  49. data/lib/chef/resource/windows_task.rb +240 -238
  50. data/lib/chef/resource/zypper_package.rb +5 -0
  51. data/lib/chef/resource_collection/resource_collection_serialization.rb +4 -2
  52. data/lib/chef/resources.rb +1 -0
  53. data/lib/chef/role.rb +4 -2
  54. data/lib/chef/run_list/run_list_expansion.rb +5 -3
  55. data/lib/chef/run_status.rb +4 -2
  56. data/lib/chef/user.rb +7 -5
  57. data/lib/chef/user_v1.rb +8 -6
  58. data/lib/chef/version.rb +1 -1
  59. data/lib/chef/win32/security/sid.rb +39 -0
  60. data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.aarch64.rpm +0 -0
  61. data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.i686.rpm +0 -0
  62. data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.ppc64.rpm +0 -0
  63. data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.ppc64le.rpm +0 -0
  64. data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.s390x.rpm +0 -0
  65. data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.src.rpm +0 -0
  66. data/spec/functional/assets/zypprepo/chef_rpm-1.10-1.x86_64.rpm +0 -0
  67. data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.aarch64.rpm +0 -0
  68. data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.i686.rpm +0 -0
  69. data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.ppc64.rpm +0 -0
  70. data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.ppc64le.rpm +0 -0
  71. data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.s390x.rpm +0 -0
  72. data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.src.rpm +0 -0
  73. data/spec/functional/assets/zypprepo/chef_rpm-1.2-1.x86_64.rpm +0 -0
  74. data/spec/functional/http/simple_spec.rb +2 -2
  75. data/spec/functional/resource/remote_file_spec.rb +2 -2
  76. data/spec/functional/resource/user/windows_spec.rb +1 -1
  77. data/spec/functional/resource/windows_task_spec.rb +1 -1
  78. data/spec/functional/resource/zypper_package_spec.rb +233 -0
  79. data/spec/spec_helper.rb +1 -0
  80. data/spec/unit/audit/audit_reporter_spec.rb +4 -4
  81. data/spec/unit/audit/control_group_data_spec.rb +17 -17
  82. data/spec/unit/environment_spec.rb +1 -1
  83. data/spec/unit/file_content_management/deploy/mv_unix_spec.rb +13 -1
  84. data/spec/unit/node_spec.rb +33 -0
  85. data/spec/unit/provider/package/rpm_spec.rb +5 -5
  86. data/spec/unit/provider/package/zypper_spec.rb +51 -0
  87. data/spec/unit/provider/package_spec.rb +32 -2
  88. data/spec/unit/provider/registry_key_spec.rb +74 -0
  89. data/spec/unit/provider/user/windows_spec.rb +12 -3
  90. data/spec/unit/provider/windows_task_spec.rb +1 -0
  91. data/spec/unit/resource/timezone.rb +39 -0
  92. data/spec/unit/resource/windows_task_spec.rb +1 -1
  93. data/spec/unit/resource_collection_spec.rb +1 -1
  94. data/spec/unit/run_context/child_run_context_spec.rb +3 -3
  95. data/spec/unit/shell/shell_session_spec.rb +3 -2
  96. metadata +21 -43
  97. data/CONTRIBUTING.md +0 -152
  98. data/VERSION +0 -1
  99. data/distro/powershell/chef/chef.psm1 +0 -459
  100. data/distro/ruby_bin_folder/Chef.PowerShell.Wrapper.dll +0 -0
  101. data/distro/ruby_bin_folder/Chef.PowerShell.dll +0 -0
  102. data/distro/ruby_bin_folder/Newtonsoft.Json.dll +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f32c9c7263c21045b7ee27b9d8dfdd8576d7ff4083d8966eedc4689d47e4fdb6
4
- data.tar.gz: 2c3918f9e7e5935e1ac40cfaee6bfd5c0e768c10763f2d091965fbd7eed65361
3
+ metadata.gz: a8d51e830e9cccfff4ec27af2c3e3bd92e5ae45f0c43d2d4142b4663744d73d0
4
+ data.tar.gz: 07d9387a39d2e53d2b81120cebfa00276e74bcb583826605c3a16eede5773da1
5
5
  SHA512:
6
- metadata.gz: 6d8e510d9adb98352f68f235c5b0ba91940a38bcb710eafa1d4959b2ca0c2d7b818047d3db12d801170de62a28fcf17e2c03f07495925f3dbda04bf12201ce68
7
- data.tar.gz: d0be6f90066117daecd40a45390bca44654bbf6ceadad084db86654fe35a9c5bc5ae75553897fe3d7aa6db542b2e9992d4c58a35bbf50b63b081f56b6ff94cc5
6
+ metadata.gz: 85186af3f82ce9835901e31b66b3f134a8a131a28bab7ea8fcd663f073c8a866e04062e891c2765c0f07197e02b7b412a89aafb4ea4607c705f35940603ec93e
7
+ data.tar.gz: 49d21188f23f5492bfce0dc2058d1abeb9daf87b12edb70de46dcc9809e25c6db345a5e1e5c5d5a67674922ca4323ece9573572c5c6d95311ab1926d32512fc5
data/Gemfile CHANGED
@@ -13,7 +13,7 @@ gem "cheffish", "~> 14"
13
13
  group(:omnibus_package) do
14
14
  gem "appbundler"
15
15
  gem "rb-readline"
16
- gem "inspec-core", "~> 2"
16
+ gem "inspec-core", "~> 3"
17
17
  gem "chef-vault"
18
18
  end
19
19
 
@@ -47,12 +47,14 @@ group(:ruby_shadow) do
47
47
  end
48
48
 
49
49
  group(:development, :test) do
50
- gem "rake"
50
+ # we pin rake as a copy of rake is installed from the ruby source
51
+ # if you bump the ruby version you should confirm we don't end up with
52
+ # two rake gems installed again
53
+ gem "rake", "<= 12.3.0"
51
54
  gem "simplecov"
52
55
  gem "webmock"
53
56
 
54
57
  # for testing new chefstyle rules
55
- # gem 'chefstyle', github: 'chef/chefstyle'
56
58
  gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "master"
57
59
  end
58
60
 
@@ -14,9 +14,10 @@ gemspec.add_dependency "win32-process", "~> 0.8.2"
14
14
  gemspec.add_dependency "win32-service", "~> 1.0"
15
15
  gemspec.add_dependency "windows-api", "~> 0.4.4"
16
16
  gemspec.add_dependency "wmi-lite", "~> 1.0"
17
- gemspec.add_dependency "win32-taskscheduler", "~> 1.0.0"
17
+ gemspec.add_dependency "win32-taskscheduler", "~> 2.0"
18
+ gemspec.add_dependency "iso8601", "~> 0.12.1"
18
19
  gemspec.extensions << "ext/win32-eventlog/Rakefile"
19
- gemspec.files += %w{ext/win32-eventlog/Rakefile ext/win32-eventlog/chef-log.man}
20
+ gemspec.files += Dir.glob("{distro,ext}/**/*")
20
21
 
21
22
  gemspec.executables += %w{ chef-service-manager chef-windows-service }
22
23
 
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.name = "chef"
6
6
  s.version = Chef::VERSION
7
7
  s.platform = Gem::Platform::RUBY
8
- s.extra_rdoc_files = ["README.md", "CONTRIBUTING.md", "LICENSE" ]
8
+ s.extra_rdoc_files = ["README.md", "LICENSE" ]
9
9
  s.summary = "A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure."
10
10
  s.description = s.summary
11
11
  s.license = "Apache-2.0"
@@ -38,10 +38,9 @@ Gem::Specification.new do |s|
38
38
  s.add_dependency "plist", "~> 3.2"
39
39
  s.add_dependency "iniparse", "~> 1.4"
40
40
  s.add_dependency "addressable"
41
- s.add_dependency "iso8601", "~> 0.11.0"
42
41
 
43
42
  # Audit mode requires these, so they are non-developmental dependencies now
44
- %w{rspec-core rspec-expectations rspec-mocks}.each { |gem| s.add_dependency gem, "~> 3.5", "< 3.8" }
43
+ %w{rspec-core rspec-expectations rspec-mocks}.each { |gem| s.add_dependency gem, "~> 3.5" }
45
44
  s.add_dependency "rspec_junit_formatter", "~> 0.2.0"
46
45
  s.add_dependency "serverspec", "~> 2.7"
47
46
  s.add_dependency "specinfra", "~> 2.10"
@@ -59,5 +58,5 @@ Gem::Specification.new do |s|
59
58
  s.executables = %w{ chef-client chef-solo knife chef-shell chef-apply chef-resource-inspector }
60
59
 
61
60
  s.require_paths = %w{ lib }
62
- s.files = %w{Gemfile Rakefile LICENSE README.md CONTRIBUTING.md VERSION} + Dir.glob("{distro,lib,lib-backcompat,tasks,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } + Dir.glob("*.gemspec")
61
+ s.files = %w{Gemfile Rakefile LICENSE README.md} + Dir.glob("{lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) } + Dir.glob("*.gemspec")
63
62
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Nuo Yan (<nuo@chef.io>)
4
- # Copyright:: Copyright 2008-2016, Chef Software Inc.
4
+ # Copyright:: Copyright 2008-2018, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -110,7 +110,7 @@ class Chef
110
110
  # Private key is included if available.
111
111
  #
112
112
  # @return [Hash]
113
- def to_hash
113
+ def to_h
114
114
  result = {
115
115
  "name" => @name,
116
116
  "public_key" => @public_key,
@@ -123,11 +123,13 @@ class Chef
123
123
  result
124
124
  end
125
125
 
126
+ alias_method :to_hash, :to_h
127
+
126
128
  # The JSON representation of the object.
127
129
  #
128
130
  # @return [String] the JSON string.
129
131
  def to_json(*a)
130
- Chef::JSONCompat.to_json(to_hash, *a)
132
+ Chef::JSONCompat.to_json(to_h, *a)
131
133
  end
132
134
 
133
135
  def self.from_hash(o)
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
3
  # Author:: Nuo Yan (<nuo@chef.io>)
4
- # Copyright:: Copyright 2008-2016, Chef Software, Inc.
4
+ # Copyright:: Copyright 2008-2018, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -146,7 +146,7 @@ class Chef
146
146
  # Private key is included if available.
147
147
  #
148
148
  # @return [Hash]
149
- def to_hash
149
+ def to_h
150
150
  result = {
151
151
  "name" => @name,
152
152
  "validator" => @validator,
@@ -159,11 +159,13 @@ class Chef
159
159
  result
160
160
  end
161
161
 
162
+ alias_method :to_hash, :to_h
163
+
162
164
  # The JSON representation of the object.
163
165
  #
164
166
  # @return [String] the JSON string.
165
167
  def to_json(*a)
166
- Chef::JSONCompat.to_json(to_hash, *a)
168
+ Chef::JSONCompat.to_json(to_h, *a)
167
169
  end
168
170
 
169
171
  def self.from_hash(o)
@@ -312,7 +314,7 @@ class Chef
312
314
 
313
315
  new_client = chef_rest_v0.post("clients", payload)
314
316
  end
315
- Chef::ApiClientV1.from_hash(to_hash.merge(new_client))
317
+ Chef::ApiClientV1.from_hash(to_h.merge(new_client))
316
318
  end
317
319
 
318
320
  # As a string
@@ -205,7 +205,7 @@ class Chef
205
205
  # Based on config and whether or not STDOUT is a tty, should we setup a
206
206
  # secondary logger for stdout?
207
207
  def want_additional_logger?
208
- Chef::Config.is_default?(:log_location) && Chef::Config[:log_location].tty? && !Chef::Config[:daemonize]
208
+ ( Chef::Config[:log_location].class != IO ) && STDOUT.tty? && !Chef::Config[:daemonize]
209
209
  end
210
210
 
211
211
  def configure_stdout_logger
@@ -118,7 +118,7 @@ class Chef
118
118
 
119
119
  audit_history_url = "controls"
120
120
  Chef::Log.trace("Sending audit report (run-id: #{audit_data.run_id})")
121
- run_data = audit_data.to_hash
121
+ run_data = audit_data.to_h
122
122
 
123
123
  if @audit_phase_error
124
124
  error_info = "#{@audit_phase_error.class}: #{@audit_phase_error.message}"
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Tyler Ball (<tball@chef.io>)
3
3
  #
4
- # Copyright:: Copyright 2014-2016, Chef Software, Inc.
4
+ # Copyright:: Copyright 2014-2018, Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -35,15 +35,17 @@ class Chef
35
35
  control_groups << control_group
36
36
  end
37
37
 
38
- def to_hash
38
+ def to_h
39
39
  {
40
40
  node_name: node_name,
41
41
  run_id: run_id,
42
42
  start_time: start_time,
43
43
  end_time: end_time,
44
- control_groups: control_groups.collect { |c| c.to_hash },
44
+ control_groups: control_groups.collect { |c| c.to_h },
45
45
  }
46
46
  end
47
+
48
+ alias_method :to_hash, :to_h
47
49
  end
48
50
 
49
51
  class ControlGroupData
@@ -76,7 +78,7 @@ class Chef
76
78
  control
77
79
  end
78
80
 
79
- def to_hash
81
+ def to_h
80
82
  # We sort it so the examples appear in the output in the same order
81
83
  # they appeared in the recipe
82
84
  controls.sort! { |x, y| x.line_number <=> y.line_number }
@@ -85,12 +87,14 @@ class Chef
85
87
  status: status,
86
88
  number_succeeded: number_succeeded,
87
89
  number_failed: number_failed,
88
- controls: controls.collect { |c| c.to_hash },
90
+ controls: controls.collect { |c| c.to_h },
89
91
  }
90
92
  # If there is a duplicate key, metadata will overwrite it
91
93
  add_display_only_data(h).merge(metadata)
92
94
  end
93
95
 
96
+ alias_method :to_hash, :to_h
97
+
94
98
  private
95
99
 
96
100
  def create_control(control_data)
@@ -122,7 +126,7 @@ class Chef
122
126
  end
123
127
  end
124
128
 
125
- def to_hash
129
+ def to_h
126
130
  h = {
127
131
  name: name,
128
132
  status: status,
@@ -133,6 +137,8 @@ class Chef
133
137
  h[:context] = context || []
134
138
  h
135
139
  end
140
+
141
+ alias_method :to_hash, :to_h
136
142
  end
137
143
 
138
144
  end
@@ -311,7 +311,7 @@ class Chef
311
311
  cookbook_type = path[0]
312
312
  result = nil
313
313
  begin
314
- result = Chef::CookbookManifest.new(entry.chef_object, policy_mode: cookbook_type == "cookbook_artifacts").to_hash
314
+ result = Chef::CookbookManifest.new(entry.chef_object, policy_mode: cookbook_type == "cookbook_artifacts").to_h
315
315
  rescue Chef::ChefFS::FileSystem::NotFoundError => e
316
316
  raise ChefZero::DataStore::DataNotFoundError.new(to_zero_path(e.entry), e)
317
317
  end
@@ -334,7 +334,7 @@ class Chef
334
334
  end
335
335
 
336
336
  if cookbook_type == "cookbook_artifacts"
337
- result["metadata"] = result["metadata"].to_hash
337
+ result["metadata"] = result["metadata"].to_h
338
338
  result["metadata"].delete_if do |key, value|
339
339
  value == [] ||
340
340
  (value == {} && !%w{dependencies attributes recipes}.include?(key)) ||
@@ -114,7 +114,7 @@ class Chef
114
114
  def from_ruby(path)
115
115
  r = chef_class.new
116
116
  r.from_file(path)
117
- r.to_hash
117
+ r.to_h
118
118
  end
119
119
 
120
120
  #
@@ -1,5 +1,5 @@
1
1
  # Author:: Daniel DeLeo (<dan@chef.io>)
2
- # Copyright:: Copyright 2015-2016, Chef Software Inc.
2
+ # Copyright:: Copyright 2015-2018, Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,42 +26,47 @@ class Chef
26
26
 
27
27
  COOKBOOK_SEGMENTS = %w{ resources providers recipes definitions libraries attributes files templates root_files }.freeze
28
28
 
29
- def self.from_hash(hash)
30
- response = Mash.new(hash)
31
- response[:all_files] = COOKBOOK_SEGMENTS.inject([]) do |memo, segment|
32
- next memo if hash[segment].nil? || hash[segment].empty?
33
- hash[segment].each do |file|
34
- file["name"] = "#{segment}/#{file["name"]}"
35
- memo << file
29
+ class << self
30
+
31
+ def from_hash(hash)
32
+ response = Mash.new(hash)
33
+ response[:all_files] = COOKBOOK_SEGMENTS.inject([]) do |memo, segment|
34
+ next memo if hash[segment].nil? || hash[segment].empty?
35
+ hash[segment].each do |file|
36
+ file["name"] = "#{segment}/#{file["name"]}"
37
+ memo << file
38
+ end
39
+ response.delete(segment)
40
+ memo
36
41
  end
37
- response.delete(segment)
38
- memo
42
+ response
39
43
  end
40
- response
41
- end
42
44
 
43
- def self.to_hash(manifest)
44
- result = manifest.manifest.dup
45
- result.delete("all_files")
45
+ def to_h(manifest)
46
+ result = manifest.manifest.dup
47
+ result.delete("all_files")
46
48
 
47
- files = manifest.by_parent_directory
48
- files.keys.each_with_object(result) do |parent, memo|
49
- if COOKBOOK_SEGMENTS.include?(parent)
50
- memo[parent] ||= []
51
- files[parent].each do |file|
52
- file["name"] = file["name"].split("/")[1]
53
- file.delete("full_path")
54
- memo[parent] << file
49
+ files = manifest.by_parent_directory
50
+ files.keys.each_with_object(result) do |parent, memo|
51
+ if COOKBOOK_SEGMENTS.include?(parent)
52
+ memo[parent] ||= []
53
+ files[parent].each do |file|
54
+ file["name"] = file["name"].split("/")[1]
55
+ file.delete("full_path")
56
+ memo[parent] << file
57
+ end
55
58
  end
56
59
  end
57
- end
58
- # Ensure all segments are set to [] if they don't exist.
59
- # See https://github.com/chef/chef/issues/6044
60
- COOKBOOK_SEGMENTS.each do |segment|
61
- result[segment] ||= []
60
+ # Ensure all segments are set to [] if they don't exist.
61
+ # See https://github.com/chef/chef/issues/6044
62
+ COOKBOOK_SEGMENTS.each do |segment|
63
+ result[segment] ||= []
64
+ end
65
+
66
+ result.merge({ "frozen?" => manifest.frozen_version?, "chef_type" => "cookbook_version" })
62
67
  end
63
68
 
64
- result.merge({ "frozen?" => manifest.frozen_version?, "chef_type" => "cookbook_version" })
69
+ alias_method :to_hash, :to_h
65
70
  end
66
71
  end
67
72
  end
@@ -1,4 +1,4 @@
1
- # Copyright:: Copyright 2015-2016, Chef Software Inc.
1
+ # Copyright:: Copyright 2015-2018, Chef Software Inc.
2
2
  # License:: Apache License, Version 2.0
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,17 +23,21 @@ class Chef
23
23
 
24
24
  minimum_api_version 2
25
25
 
26
- def self.from_hash(hash)
27
- Chef::Log.trace "processing manifest: #{hash}"
28
- Mash.new hash
29
- end
26
+ class << self
27
+ def from_hash(hash)
28
+ Chef::Log.trace "processing manifest: #{hash}"
29
+ Mash.new hash
30
+ end
31
+
32
+ def to_h(manifest)
33
+ result = manifest.manifest.dup
34
+ result["all_files"].map! { |file| file.delete("full_path"); file }
35
+ result["frozen?"] = manifest.frozen_version?
36
+ result["chef_type"] = "cookbook_version"
37
+ result.to_hash
38
+ end
30
39
 
31
- def self.to_hash(manifest)
32
- result = manifest.manifest.dup
33
- result["all_files"].map! { |file| file.delete("full_path"); file }
34
- result["frozen?"] = manifest.frozen_version?
35
- result["chef_type"] = "cookbook_version"
36
- result.to_hash
40
+ alias_method :to_hash, :to_h
37
41
  end
38
42
 
39
43
  end
@@ -465,7 +465,7 @@ class Chef
465
465
  end
466
466
  end
467
467
 
468
- def to_hash
468
+ def to_h
469
469
  {
470
470
  NAME => name,
471
471
  DESCRIPTION => description,
@@ -488,8 +488,10 @@ class Chef
488
488
  }
489
489
  end
490
490
 
491
+ alias_method :to_hash, :to_h
492
+
491
493
  def to_json(*a)
492
- Chef::JSONCompat.to_json(to_hash, *a)
494
+ Chef::JSONCompat.to_json(to_h, *a)
493
495
  end
494
496
 
495
497
  def self.from_hash(o)
@@ -1,5 +1,5 @@
1
1
  # Author:: Daniel DeLeo (<dan@chef.io>)
2
- # Copyright:: Copyright 2015-2016, Chef Software Inc.
2
+ # Copyright:: Copyright 2015-2018, Chef Software Inc.
3
3
  # License:: Apache License, Version 2.0
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -40,7 +40,7 @@ class Chef
40
40
  def_delegator :@cookbook_version, :frozen_version?
41
41
 
42
42
  # Create a new CookbookManifest object for the given `cookbook_version`.
43
- # You can subsequently call #to_hash to get a Hash representation of the
43
+ # You can subsequently call #to_h to get a Hash representation of the
44
44
  # cookbook_version in the "manifest" format, or #to_json to get a JSON
45
45
  # representation of the cookbook_version.
46
46
  #
@@ -119,12 +119,14 @@ class Chef
119
119
  @policy_mode
120
120
  end
121
121
 
122
- def to_hash
123
- CookbookManifestVersions.to_hash(self)
122
+ def to_h
123
+ CookbookManifestVersions.to_h(self)
124
124
  end
125
125
 
126
+ alias_method :to_hash, :to_h
127
+
126
128
  def to_json(*a)
127
- result = to_hash
129
+ result = to_h
128
130
  result["json_class"] = "Chef::CookbookVersion"
129
131
  Chef::JSONCompat.to_json(result, *a)
130
132
  end
@@ -321,5 +323,6 @@ class Chef
321
323
 
322
324
  def_versioned_delegator :from_hash
323
325
  def_versioned_delegator :to_hash
326
+ def_versioned_delegator :to_h
324
327
  end
325
328
  end