chef 12.21.10 → 12.21.12

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: f27c9cd29f06bf504863e8b341a142d56b71e038
4
- data.tar.gz: e68494374efc70bffc65e5cf31b90aae3352aec3
3
+ metadata.gz: 6a9cfce3a9c74e84ffa685e513386db548002580
4
+ data.tar.gz: 11180225a5ac33925b6746cd85c3cd8a253091ae
5
5
  SHA512:
6
- metadata.gz: a1dba830c81174f7f26e49758851c620d6d25eaa3d3a916ce9dccd13f62c28eb3c9a71701ef069cb56ad2094829379b10ea98734bcd1e7541c25bb6252d7da95
7
- data.tar.gz: 9304bc1b56ff135048a3161461139f1d369e4e66149ff8af0ea47c7e471b7d563ed04db51e795878d3b04f91230f66f65991e2cea783fa8e4c47963183a65d08
6
+ metadata.gz: 5d89f801502474f4360bfc0df5a8da84f7ef4c1ad1cd22b3bbcec2b972f6e18f0c108efa7c3f0ce01846ad1bf9e862123ac942bcdc7cb17aa31d9f7aa999ba78
7
+ data.tar.gz: 2bf71ae0ce47fc9b3b6288e3ad0e5a8f6006e0a697dd66f4023c7571daa53e0e116fa874b6cac628336a3cc736f93727a9266dc87600c5f4be3a241090e3d85d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 12.21.10
1
+ 12.21.12
@@ -47,15 +47,13 @@ class Chef::Util::DSC
47
47
 
48
48
  def run_configuration_cmdlet(configuration_document, apply_configuration, shellout_flags)
49
49
  Chef::Log.debug("DSC: Calling DSC Local Config Manager to #{apply_configuration ? "set" : "test"} configuration document.")
50
- test_only_parameters = ! apply_configuration ? "-whatif; if (! $?) { exit 1 }" : ""
51
50
 
52
51
  start_operation_timing
53
- command_code = lcm_command_code(@configuration_path, test_only_parameters)
54
52
  status = nil
55
53
 
56
54
  begin
57
55
  save_configuration_document(configuration_document)
58
- cmdlet = ::Chef::Util::Powershell::Cmdlet.new(@node, "#{command_code}")
56
+ cmdlet = ::Chef::Util::Powershell::Cmdlet.new(@node, lcm_command(apply_configuration))
59
57
  if apply_configuration
60
58
  status = cmdlet.run!({}, shellout_flags)
61
59
  else
@@ -72,10 +70,22 @@ class Chef::Util::DSC
72
70
  status
73
71
  end
74
72
 
75
- def lcm_command_code(configuration_path, test_only_parameters)
76
- <<-EOH
77
- $ProgressPreference = 'SilentlyContinue';start-dscconfiguration -path #{@configuration_path} -wait -erroraction 'stop' -force #{test_only_parameters}
78
- EOH
73
+ def lcm_command(apply_configuration)
74
+ common_command_prefix = "$ProgressPreference = 'SilentlyContinue';"
75
+ ps4_base_command = "#{common_command_prefix} Start-DscConfiguration -path #{@configuration_path} -wait -erroraction 'stop' -force"
76
+ if apply_configuration
77
+ ps4_base_command
78
+ else
79
+ if ps_version_gte_5?
80
+ "#{common_command_prefix} Test-DscConfiguration -path #{@configuration_path}"
81
+ else
82
+ ps4_base_command + " -whatif; if (! $?) { exit 1 }"
83
+ end
84
+ end
85
+ end
86
+
87
+ def ps_version_gte_5?
88
+ Chef::Platform.supported_powershell_version?(@node, 5)
79
89
  end
80
90
 
81
91
  def log_what_if_exception(what_if_exception_output)
@@ -21,7 +21,7 @@
21
21
 
22
22
  class Chef
23
23
  CHEF_ROOT = File.expand_path("../..", __FILE__)
24
- VERSION = "12.21.10"
24
+ VERSION = "12.21.12"
25
25
  end
26
26
 
27
27
  #
@@ -63,7 +63,7 @@ EOH
63
63
  let(:lcm_standard_error) { nil }
64
64
  let(:lcm_cmdlet_success) { true }
65
65
 
66
- it "should successfully return resource information for normally formatted output when cmdlet the cmdlet succeeds" do
66
+ it "successfully returns resource information for normally formatted output when cmdlet the cmdlet succeeds" do
67
67
  test_configuration_result = lcm.test_configuration("config", {})
68
68
  expect(test_configuration_result.class).to be(Array)
69
69
  expect(test_configuration_result.length).to be > 0
@@ -71,6 +71,58 @@ EOH
71
71
  end
72
72
  end
73
73
 
74
+ context "when running on PowerShell version 5" do
75
+ let(:lcm_standard_output) { normal_lcm_output }
76
+ let(:lcm_standard_error) { nil }
77
+ let(:lcm_cmdlet_success) { true }
78
+
79
+ it "successfully returns resource information for normally formatted output when cmdlet the cmdlet succeeds" do
80
+ allow(lcm).to receive(:ps_version_gte_5?).and_return(true)
81
+ test_configuration_result = lcm.test_configuration("config", {})
82
+ expect(test_configuration_result.class).to be(Array)
83
+ expect(test_configuration_result.length).to be > 0
84
+ expect(Chef::Log).not_to receive(:warn)
85
+ end
86
+ end
87
+
88
+ context "when running on PowerShell version less than 5" do
89
+ let(:lcm_standard_output) { normal_lcm_output }
90
+ let(:lcm_standard_error) { nil }
91
+ let(:lcm_cmdlet_success) { true }
92
+
93
+ it "successfully returns resource information for normally formatted output when cmdlet the cmdlet succeeds" do
94
+ allow(lcm).to receive(:ps_version_gte_5?).and_return(false)
95
+ test_configuration_result = lcm.test_configuration("config", {})
96
+ expect(test_configuration_result.class).to be(Array)
97
+ expect(test_configuration_result.length).to be > 0
98
+ expect(Chef::Log).not_to receive(:warn)
99
+ end
100
+ end
101
+
102
+ context "#lcm_command" do
103
+ let(:common_command_prefix) { "$ProgressPreference = 'SilentlyContinue';" }
104
+ let(:ps4_base_command) { "#{common_command_prefix} Start-DscConfiguration -path tmp -wait -erroraction 'stop' -force" }
105
+ let(:lcm_command_ps4) { ps4_base_command + " -whatif; if (! $?) { exit 1 }" }
106
+ let(:lcm_command_ps5) { "#{common_command_prefix} Test-DscConfiguration -path tmp" }
107
+ let(:lcm_standard_output) { normal_lcm_output }
108
+ let(:lcm_standard_error) { nil }
109
+ let(:lcm_cmdlet_success) { true }
110
+
111
+ it "successfully returns command when apply_configuration true" do
112
+ expect(lcm.send(:lcm_command, true)).to eq(ps4_base_command)
113
+ end
114
+
115
+ it "successfully returns command when PowerShell version 4" do
116
+ allow(lcm).to receive(:ps_version_gte_5?).and_return(false)
117
+ expect(lcm.send(:lcm_command, false)).to eq(lcm_command_ps4)
118
+ end
119
+
120
+ it "successfully returns command when PowerShell version 5" do
121
+ allow(lcm).to receive(:ps_version_gte_5?).and_return(true)
122
+ expect(lcm.send(:lcm_command, false)).to eq(lcm_command_ps5)
123
+ end
124
+ end
125
+
74
126
  context "that fails due to missing what-if switch in DSC resource cmdlet implementation" do
75
127
  let(:lcm_standard_output) { "" }
76
128
  let(:lcm_standard_error) { no_whatif_lcm_output }
@@ -80,7 +132,7 @@ EOH
80
132
  expect(lcm.send(:whatif_not_supported?, no_whatif_lcm_output)).to be_truthy
81
133
  end
82
134
 
83
- it "should should return a (possibly empty) array of ResourceInfo instances" do
135
+ it "returns a (possibly empty) array of ResourceInfo instances" do
84
136
  expect(Chef::Log).to receive(:warn).at_least(:once)
85
137
  expect(lcm).to receive(:whatif_not_supported?).and_call_original
86
138
  test_configuration_result = nil
@@ -94,14 +146,14 @@ EOH
94
146
  let(:lcm_standard_error) { dsc_resource_import_failure_output }
95
147
  let(:lcm_cmdlet_success) { false }
96
148
 
97
- it "should log a warning if the message is formatted as expected when a resource import failure occurs" do
149
+ it "logs a warning if the message is formatted as expected when a resource import failure occurs" do
98
150
  expect(Chef::Log).to receive(:warn).at_least(:once)
99
151
  expect(lcm).to receive(:dsc_module_import_failure?).and_call_original
100
152
  test_configuration_result = nil
101
153
  expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error
102
154
  end
103
155
 
104
- it "should return a (possibly empty) array of ResourceInfo instances" do
156
+ it "returns a (possibly empty) array of ResourceInfo instances" do
105
157
  expect(Chef::Log).to receive(:warn).at_least(:once)
106
158
  test_configuration_result = nil
107
159
  expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error
@@ -114,7 +166,7 @@ EOH
114
166
  let(:lcm_standard_error) { "Abort, Retry, Fail?" }
115
167
  let(:lcm_cmdlet_success) { false }
116
168
 
117
- it "should log a warning" do
169
+ it "logs a warning" do
118
170
  expect(Chef::Log).to receive(:warn).at_least(:once)
119
171
  expect(lcm).to receive(:dsc_module_import_failure?).and_call_original
120
172
  expect { lcm.test_configuration("config", {}) }.not_to raise_error
@@ -122,15 +174,15 @@ EOH
122
174
  end
123
175
  end
124
176
 
125
- it "should identify a correctly formatted error message as a resource import failure" do
177
+ it "identify a correctly formatted error message as a resource import failure" do
126
178
  expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output)).to be(true)
127
179
  end
128
180
 
129
- it "should not identify an incorrectly formatted error message as a resource import failure" do
181
+ it "does not identify an incorrectly formatted error message as a resource import failure" do
130
182
  expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("module", "gibberish"))).to be(false)
131
183
  end
132
184
 
133
- it "should not identify a message without a CimException reference as a resource import failure" do
185
+ it "does not identify a message without a CimException reference as a resource import failure" do
134
186
  expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("CimException", "ArgumentException"))).to be(false)
135
187
  end
136
188
  end
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.10
4
+ version: 12.21.12
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-09-05 00:00:00.000000000 Z
11
+ date: 2017-09-14 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.10
19
+ version: 12.21.12
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.10
26
+ version: 12.21.12
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: mixlib-cli
29
29
  requirement: !ruby/object:Gem::Requirement