chef 12.21.4 → 12.21.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/chef/mash.rb +6 -0
- data/lib/chef/node/attribute.rb +80 -14
- data/lib/chef/node/immutable_collections.rb +14 -15
- data/lib/chef/provider/package/dnf.rb +3 -1
- data/lib/chef/version.rb +1 -1
- data/spec/unit/node/immutable_collections_spec.rb +12 -4
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f27c9cd29f06bf504863e8b341a142d56b71e038
|
4
|
+
data.tar.gz: e68494374efc70bffc65e5cf31b90aae3352aec3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1dba830c81174f7f26e49758851c620d6d25eaa3d3a916ce9dccd13f62c28eb3c9a71701ef069cb56ad2094829379b10ea98734bcd1e7541c25bb6252d7da95
|
7
|
+
data.tar.gz: 9304bc1b56ff135048a3161461139f1d369e4e66149ff8af0ea47c7e471b7d563ed04db51e795878d3b04f91230f66f65991e2cea783fa8e4c47963183a65d08
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
12.21.
|
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.
|
data/lib/chef/node/attribute.rb
CHANGED
@@ -403,7 +403,7 @@ class Chef
|
|
403
403
|
#
|
404
404
|
|
405
405
|
def merged_attributes(*path)
|
406
|
-
|
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.
|
563
|
-
|
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(
|
575
|
+
ret = DEFAULT_COMPONENTS.inject(NIL) do |merged, component_ivar|
|
581
576
|
component_value = apply_path(instance_variable_get(component_ivar), path)
|
582
|
-
|
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(
|
589
|
+
ret = OVERRIDE_COMPONENTS.inject(NIL) do |merged, component_ivar|
|
594
590
|
component_value = apply_path(instance_variable_get(component_ivar), path)
|
595
|
-
|
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
|
-
|
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-
|
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
|
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
|
-
|
114
|
-
private
|
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,
|
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{
|
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,10 +21,10 @@ require "chef/node/immutable_collections"
|
|
21
21
|
|
22
22
|
describe Chef::Node::ImmutableMash do
|
23
23
|
before do
|
24
|
-
@data_in = {
|
24
|
+
@data_in = { "top" => { "second_level" => "some value" },
|
25
25
|
"top_level_2" => %w{array of values},
|
26
|
-
|
27
|
-
|
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({
|
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
|
+
version: 12.21.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
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.
|
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.
|
26
|
+
version: 12.21.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mixlib-cli
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -2651,7 +2651,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
2651
2651
|
version: '0'
|
2652
2652
|
requirements: []
|
2653
2653
|
rubyforge_project:
|
2654
|
-
rubygems_version: 2.6.
|
2654
|
+
rubygems_version: 2.6.13
|
2655
2655
|
signing_key:
|
2656
2656
|
specification_version: 4
|
2657
2657
|
summary: A systems integration framework, built to bring the benefits of configuration
|