chef 12.21.4-universal-mingw32 → 12.21.10-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 459d357a648c30126a7a4dffbb709c327118879b
4
- data.tar.gz: 672f6feac0d731ec7817254138fe803ee3518ec7
3
+ metadata.gz: '095f8502f842f60af6af71dc0b4cc0c0b5dc280a'
4
+ data.tar.gz: 055a5c6e54cc13fcb2a3f453766cf094dd8175e1
5
5
  SHA512:
6
- metadata.gz: 61bd8bb963670a2ef235eb6f612a1964be93774dda090eb4e8e6e9ff9f069cf6a0446c7d886d74a8c4005b631a3a44f1a43f10e9a8c5c9d5233d7b485482a452
7
- data.tar.gz: 21119edf195c229828ba14be8213d8f745043eec53ab5685fb419236fa963ff13332e2d75c472d1093b64676b8f48066539170f24f9901d9929c8575af448008
6
+ metadata.gz: b54dfca6874e5dbbca81194b30848be868cdc64db7816cac47dba96adf6d03f07afe5e01508f7bafd6067718d73549cd0bc8a3d218e44888836cb59260832475
7
+ data.tar.gz: 99c9e8badb15203e86699cd29cf25ebd60df22569ceab926a1530373e2f0d8e464f61838ce03dff9498b57d2cb887163a13e6e56336b59e9f547b12a2c3b4aa6
data/VERSION CHANGED
@@ -1 +1 @@
1
- 12.21.4
1
+ 12.21.10
data/lib/chef/mash.rb CHANGED
@@ -105,6 +105,12 @@ class Mash < Hash
105
105
  regular_writer(convert_key(key), convert_value(value))
106
106
  end
107
107
 
108
+ # internal API for use by Chef's deep merge cache
109
+ # @api private
110
+ def internal_set(key, value)
111
+ regular_writer(key, convert_value(value))
112
+ end
113
+
108
114
  # @param other_hash<Hash>
109
115
  # A hash to update values in the mash with. The keys and the values will be
110
116
  # converted to Mash format.
@@ -403,7 +403,7 @@ class Chef
403
403
  #
404
404
 
405
405
  def merged_attributes(*path)
406
- immutablize(merge_all(path))
406
+ merge_all(path)
407
407
  end
408
408
 
409
409
  def combined_override(*path)
@@ -559,15 +559,10 @@ class Chef
559
559
  apply_path(@automatic, path),
560
560
  ]
561
561
 
562
- components.map! do |component|
563
- safe_dup(component)
564
- end
565
-
566
- return nil if components.compact.empty?
567
-
568
- components.inject(ImmutableMash.new({}, self, __node__, :merged)) do |merged, component|
569
- Chef::Mixin::DeepMerge.hash_only_merge!(merged, component)
562
+ ret = components.inject(NIL) do |merged, component|
563
+ hash_only_merge!(merged, component)
570
564
  end
565
+ ret == NIL ? nil : ret
571
566
  end
572
567
 
573
568
  # Deep merge the default attribute levels with array merging.
@@ -577,10 +572,11 @@ class Chef
577
572
  # @param path [Array] Array of args to method chain to descend into the node object
578
573
  # @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
579
574
  def merge_defaults(path)
580
- DEFAULT_COMPONENTS.inject(nil) do |merged, component_ivar|
575
+ ret = DEFAULT_COMPONENTS.inject(NIL) do |merged, component_ivar|
581
576
  component_value = apply_path(instance_variable_get(component_ivar), path)
582
- Chef::Mixin::DeepMerge.deep_merge(component_value, merged)
577
+ deep_merge!(merged, component_value)
583
578
  end
579
+ ret == NIL ? nil : ret
584
580
  end
585
581
 
586
582
  # Deep merge the override attribute levels with array merging.
@@ -590,10 +586,11 @@ class Chef
590
586
  # @param path [Array] Array of args to method chain to descend into the node object
591
587
  # @return [attr] Deep Merged values (may be VividMash, Hash, Array, etc) from the node object
592
588
  def merge_overrides(path)
593
- OVERRIDE_COMPONENTS.inject(nil) do |merged, component_ivar|
589
+ ret = OVERRIDE_COMPONENTS.inject(NIL) do |merged, component_ivar|
594
590
  component_value = apply_path(instance_variable_get(component_ivar), path)
595
- Chef::Mixin::DeepMerge.deep_merge(component_value, merged)
591
+ deep_merge!(merged, component_value)
596
592
  end
593
+ ret == NIL ? nil : ret
597
594
  end
598
595
 
599
596
  # needed for __path__
@@ -601,7 +598,76 @@ class Chef
601
598
  key.kind_of?(Symbol) ? key.to_s : key
602
599
  end
603
600
 
604
- end
601
+ NIL = Object.new
602
+
603
+ # @api private
604
+ def deep_merge!(merge_onto, merge_with)
605
+ # If there are two Hashes, recursively merge.
606
+ if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)
607
+ merge_with.each do |key, merge_with_value|
608
+ value =
609
+ if merge_onto.has_key?(key)
610
+ deep_merge!(safe_dup(merge_onto[key]), merge_with_value)
611
+ else
612
+ merge_with_value
613
+ end
614
+
615
+ # internal_set bypasses converting keys, does convert values and allows writing to immutable mashes
616
+ merge_onto.internal_set(key, value)
617
+ end
618
+ merge_onto
619
+
620
+ elsif merge_onto.kind_of?(Array) && merge_with.kind_of?(Array)
621
+ merge_onto |= merge_with
622
+
623
+ # If merge_with is nil, don't replace merge_onto
624
+ elsif merge_with.nil?
625
+ merge_onto
626
+
627
+ # In all other cases, replace merge_onto with merge_with
628
+ else
629
+ if merge_with.kind_of?(Hash)
630
+ Chef::Node::VividMash.new(merge_with)
631
+ elsif merge_with.kind_of?(Array)
632
+ Chef::Node::AttrArray.new(merge_with)
633
+ else
634
+ merge_with
635
+ end
636
+ end
637
+ end
638
+
639
+ # @api private
640
+ def hash_only_merge!(merge_onto, merge_with)
641
+ # If there are two Hashes, recursively merge.
642
+ if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)
643
+ merge_with.each do |key, merge_with_value|
644
+ value =
645
+ if merge_onto.has_key?(key)
646
+ hash_only_merge!(safe_dup(merge_onto[key]), merge_with_value)
647
+ else
648
+ merge_with_value
649
+ end
650
+
651
+ # internal_set bypasses converting keys, does convert values and allows writing to immutable mashes
652
+ merge_onto.internal_set(key, value)
653
+ end
654
+ merge_onto
655
+
656
+ # If merge_with is nil, don't replace merge_onto
657
+ elsif merge_with.nil?
658
+ merge_onto
605
659
 
660
+ # In all other cases, replace merge_onto with merge_with
661
+ else
662
+ if merge_with.kind_of?(Hash)
663
+ Chef::Node::ImmutableMash.new(merge_with)
664
+ elsif merge_with.kind_of?(Array)
665
+ Chef::Node::ImmutableArray.new(merge_with)
666
+ else
667
+ merge_with
668
+ end
669
+ end
670
+ end
671
+ end
606
672
  end
607
673
  end
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright:: Copyright 2012-2016, Chef Software, Inc.
2
+ # Copyright:: Copyright 2012-2017, 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");
@@ -24,16 +24,22 @@ class Chef
24
24
  class Node
25
25
 
26
26
  module Immutablize
27
- def immutablize(value)
27
+ def convert_value(value)
28
28
  case value
29
29
  when Hash
30
30
  ImmutableMash.new(value, __root__, __node__, __precedence__)
31
31
  when Array
32
32
  ImmutableArray.new(value, __root__, __node__, __precedence__)
33
+ when ImmutableMash, ImmutableArray
34
+ value
33
35
  else
34
36
  value
35
37
  end
36
38
  end
39
+
40
+ def immutablize(value)
41
+ convert_value(value)
42
+ end
37
43
  end
38
44
 
39
45
  # == ImmutableArray
@@ -110,19 +116,18 @@ class Chef
110
116
  include Immutablize
111
117
  include CommonAPI
112
118
 
113
- alias :internal_set :[]=
114
- private :internal_set
119
+ # this is for deep_merge usage, chef users must never touch this API
120
+ # @api private
121
+ def internal_set(key, value)
122
+ regular_writer(key, convert_value(value))
123
+ end
115
124
 
116
125
  def initialize(mash_data = {})
117
126
  mash_data.each do |key, value|
118
- internal_set(key, immutablize(value))
127
+ internal_set(key, value)
119
128
  end
120
129
  end
121
130
 
122
- def public_method_that_only_deep_merge_should_use(key, value)
123
- internal_set(key, immutablize(value))
124
- end
125
-
126
131
  alias :attribute? :has_key?
127
132
 
128
133
  def method_missing(symbol, *args)
@@ -143,12 +148,6 @@ class Chef
143
148
  end
144
149
  end
145
150
 
146
- # Mash uses #convert_value to mashify values on input.
147
- # Since we're handling this ourselves, override it to be a no-op
148
- def convert_value(value)
149
- value
150
- end
151
-
152
151
  # NOTE: #default and #default= are likely to be pretty confusing. For a
153
152
  # regular ruby Hash, they control what value is returned for, e.g.,
154
153
  # hash[:no_such_key] #=> hash.default
@@ -35,10 +35,12 @@ class Chef
35
35
  use_multipackage_api
36
36
  use_package_name_for_source
37
37
 
38
- provides :package, platform_family: %w{rhel fedora} do
38
+ provides :package, platform_family: %w{fedora} do
39
39
  which("dnf") && shell_out("rpm -q dnf").stdout =~ /^dnf-[1-9]/
40
40
  end
41
41
 
42
+ provides :package, platform_family: %w{rhel}, platform_version: ">= 8"
43
+
42
44
  provides :dnf_package, os: "linux"
43
45
 
44
46
  #
data/lib/chef/version.rb CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  class Chef
23
23
  CHEF_ROOT = File.expand_path("../..", __FILE__)
24
- VERSION = "12.21.4"
24
+ VERSION = "12.21.10"
25
25
  end
26
26
 
27
27
  #
@@ -21,10 +21,10 @@ require "chef/node/immutable_collections"
21
21
 
22
22
  describe Chef::Node::ImmutableMash do
23
23
  before do
24
- @data_in = { :top => { :second_level => "some value" },
24
+ @data_in = { "top" => { "second_level" => "some value" },
25
25
  "top_level_2" => %w{array of values},
26
- :top_level_3 => [{ :hash_array => 1, :hash_array_b => 2 }],
27
- :top_level_4 => { :level2 => { :key => "value" } },
26
+ "top_level_3" => [{ "hash_array" => 1, "hash_array_b" => 2 }],
27
+ "top_level_4" => { "level2" => { "key" => "value" } },
28
28
  }
29
29
  @immutable_mash = Chef::Node::ImmutableMash.new(@data_in)
30
30
  end
@@ -54,6 +54,14 @@ describe Chef::Node::ImmutableMash do
54
54
  expect(@immutable_mash[:top_level_4][:level2]).to be_a(Chef::Node::ImmutableMash)
55
55
  end
56
56
 
57
+ # we only ever absorb VividMashes from other precedence levels, which already have
58
+ # been coerced to only have string keys, so we do not need to do that work twice (performance).
59
+ it "does not call convert_value like Mash/VividMash" do
60
+ @mash = Chef::Node::ImmutableMash.new({ test: "foo", "test2" => "bar" })
61
+ expect(@mash[:test]).to eql("foo")
62
+ expect(@mash["test2"]).to eql("bar")
63
+ end
64
+
57
65
  describe "to_hash" do
58
66
  before do
59
67
  @copy = @immutable_mash.to_hash
@@ -117,7 +125,7 @@ describe Chef::Node::ImmutableArray do
117
125
 
118
126
  before do
119
127
  @immutable_array = Chef::Node::ImmutableArray.new(%w{foo bar baz} + Array(1..3) + [nil, true, false, [ "el", 0, nil ] ])
120
- immutable_mash = Chef::Node::ImmutableMash.new({ :m => "m" })
128
+ immutable_mash = Chef::Node::ImmutableMash.new({ "m" => "m" })
121
129
  @immutable_nested_array = Chef::Node::ImmutableArray.new(["level1", @immutable_array, immutable_mash])
122
130
  end
123
131
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.21.4
4
+ version: 12.21.10
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-14 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 12.21.4
19
+ version: 12.21.10
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 12.21.4
26
+ version: 12.21.10
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -2812,7 +2812,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
2812
2812
  version: '0'
2813
2813
  requirements: []
2814
2814
  rubyforge_project:
2815
- rubygems_version: 2.6.12
2815
+ rubygems_version: 2.6.13
2816
2816
  signing_key:
2817
2817
  specification_version: 4
2818
2818
  summary: A systems integration framework, built to bring the benefits of configuration