chef-cli 3.0.36 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +4 -10
- data/chef-cli.gemspec +1 -1
- data/lib/chef-cli/cli.rb +1 -5
- data/lib/chef-cli/command/generator_commands/cookbook.rb +1 -1
- data/lib/chef-cli/command/generator_commands/generator_generator.rb +2 -2
- data/lib/chef-cli/command/shell_init.rb +1 -1
- data/lib/chef-cli/command/update.rb +1 -1
- data/lib/chef-cli/completions/chef.fish.erb +4 -5
- data/lib/chef-cli/configurable.rb +1 -1
- data/lib/chef-cli/cookbook_profiler/git.rb +4 -8
- data/lib/chef-cli/generator.rb +1 -1
- data/lib/chef-cli/helpers.rb +6 -3
- data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +5 -1
- data/lib/chef-cli/policyfile/differ.rb +1 -1
- data/lib/chef-cli/policyfile_services/install.rb +1 -1
- data/lib/chef-cli/service_exceptions.rb +1 -0
- data/lib/chef-cli/skeletons/code_generator/recipes/cookbook_file.rb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen.yml.erb +1 -1
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb +1 -0
- data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +1 -1
- data/lib/chef-cli/version.rb +1 -1
- data/spec/test_helpers.rb +1 -1
- data/spec/unit/command/generator_commands/cookbook_spec.rb +3 -3
- data/spec/unit/command/generator_commands/generator_generator_spec.rb +2 -2
- data/spec/unit/command/shell_init_spec.rb +10 -10
- data/spec/unit/command/update_spec.rb +0 -8
- data/spec/unit/policyfile/artifactory_cookbook_source_spec.rb +27 -1
- data/spec/unit/policyfile/undo_stack_spec.rb +2 -2
- data/spec/unit/policyfile_install_with_includes_spec.rb +1 -1
- data/spec/unit/policyfile_lock_build_spec.rb +1 -1
- data/spec/unit/policyfile_lock_install_spec.rb +1 -1
- data/spec/unit/policyfile_lock_validation_spec.rb +1 -1
- data/spec/unit/policyfile_services/install_spec.rb +88 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db59602ecc8f8eccfed56173f71092e36e1cc55ad6ece88e311d26896d7a1e0b
|
4
|
+
data.tar.gz: a584cf195ad81b8e3ddae995aa5c275545e795782439990ceb11e7dc2450eba6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1d34379eda31b8391fd142cc60ad71c0ac8bcd9e8a0fc9734da1a25cbfebdae1b2dda323ef6937ba2a05d11a86cc429f8a6d4692067d073b240dd5da3fdc5a2
|
7
|
+
data.tar.gz: 27b7a7342e77162a34a7c6e3dcabfc9ba73d3081fb2b1bc6d144c5d01a8fa673bc2c60f6fc87ee2cc3841a970274f407b6cf9ab2c099d4cd6e7fdd845066c10c
|
data/Gemfile
CHANGED
@@ -2,30 +2,24 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
group :docs do
|
6
|
-
gem "yard"
|
7
|
-
gem "redcarpet"
|
8
|
-
gem "github-markup"
|
9
|
-
end
|
10
|
-
|
11
5
|
group :test do
|
12
6
|
gem "rake"
|
13
7
|
gem "rspec", "~> 3.8"
|
14
8
|
gem "rspec-expectations", "~> 3.8"
|
15
9
|
gem "rspec-mocks", "~> 3.8"
|
16
|
-
gem "cookstyle", "
|
17
|
-
gem "chefstyle", "1.2
|
18
|
-
gem "test-kitchen", "
|
10
|
+
gem "cookstyle", "=7.7.2" # this forces dependabot PRs to open which triggers cookstyle CI on the chef generate command
|
11
|
+
gem "chefstyle", "=1.6.2"
|
12
|
+
gem "test-kitchen", ">= 2.11.1"
|
19
13
|
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6")
|
20
14
|
gem "chef-zero", "~> 14"
|
21
15
|
gem "chef", "~> 15"
|
16
|
+
gem "chef-utils", "=16.6.14"
|
22
17
|
end
|
23
18
|
end
|
24
19
|
|
25
20
|
group :development do
|
26
21
|
gem "pry"
|
27
22
|
gem "pry-byebug"
|
28
|
-
gem "pry-stack_explorer", "~> 0.4.0"
|
29
23
|
gem "rb-readline"
|
30
24
|
end
|
31
25
|
|
data/chef-cli.gemspec
CHANGED
data/lib/chef-cli/cli.rb
CHANGED
@@ -207,7 +207,7 @@ module ChefCLI
|
|
207
207
|
if !@cookbook_name_or_path
|
208
208
|
@params_valid = false
|
209
209
|
elsif File.basename(@cookbook_name_or_path).include?("-")
|
210
|
-
msg("Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/ctl_chef/#chef-generate-cookbook for more information.")
|
210
|
+
msg("Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/workstation/ctl_chef/#chef-generate-cookbook for more information.")
|
211
211
|
end
|
212
212
|
|
213
213
|
if config[:berks] && config[:policy]
|
@@ -86,7 +86,7 @@ module ChefCLI
|
|
86
86
|
# chefcli.generator_cookbook would make this command copy the custom
|
87
87
|
# generator, but that doesn't make sense because the user can easily
|
88
88
|
# do that anyway.
|
89
|
-
File.expand_path("
|
89
|
+
File.expand_path("../../skeletons/code_generator", __dir__)
|
90
90
|
end
|
91
91
|
|
92
92
|
private
|
@@ -109,7 +109,7 @@ module ChefCLI
|
|
109
109
|
# @api private
|
110
110
|
def metadata_rb
|
111
111
|
<<~METADATA
|
112
|
-
name
|
112
|
+
name File.basename(File.dirname(__FILE__))
|
113
113
|
description 'Custom code generator cookbook for use with #{ChefCLI::Dist::PRODUCT}'
|
114
114
|
version '0.1.0'
|
115
115
|
|
@@ -142,7 +142,7 @@ module ChefCLI
|
|
142
142
|
end
|
143
143
|
|
144
144
|
def expand_completion_template_path(basename)
|
145
|
-
File.join(File.expand_path("
|
145
|
+
File.join(File.expand_path("../completions", __dir__), basename)
|
146
146
|
end
|
147
147
|
|
148
148
|
def shell_completion_template_context
|
@@ -91,7 +91,7 @@ module ChefCLI
|
|
91
91
|
def run(params = [])
|
92
92
|
return 1 unless apply_params!(params)
|
93
93
|
|
94
|
-
attributes_updater.run
|
94
|
+
attributes_updater.run if update_attributes_only?
|
95
95
|
installer.run(@cookbooks_to_update, config[:exclude_deps]) unless update_attributes_only?
|
96
96
|
0
|
97
97
|
rescue PolicyfileServiceError => e
|
@@ -1,10 +1,9 @@
|
|
1
|
+
|
1
2
|
# Fish Shell command-line completions for <%=ChefCLI::Dist::PRODUCT %>
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
test (count $cmd) -eq 1
|
6
|
-
end
|
4
|
+
# set a list of all the chef commands in the Ruby chef-cli
|
5
|
+
set -l chef_commands <%= commands.keys.join(' ') %>;
|
7
6
|
|
8
7
|
<% commands.each do |command, desc| -%>
|
9
|
-
complete -c chef -f -n
|
8
|
+
complete -c chef -f -n "not __fish_seen_subcommand_from $chef_commands" -a <%= command %> -d "<%= desc %>";
|
10
9
|
<% end -%>
|
@@ -33,7 +33,7 @@ class Chef::Config
|
|
33
33
|
# instead of `chefcli.generator_cookbook`).
|
34
34
|
config_strict_mode(true)
|
35
35
|
|
36
|
-
default(:generator_cookbook, File.expand_path("
|
36
|
+
default(:generator_cookbook, File.expand_path("skeletons/code_generator", __dir__))
|
37
37
|
|
38
38
|
config_context(:generator) do
|
39
39
|
config_strict_mode(true)
|
@@ -120,14 +120,10 @@ module ChefCLI
|
|
120
120
|
@unborn_branch = false
|
121
121
|
branch
|
122
122
|
rescue Mixlib::ShellOut::ShellCommandFailed => e
|
123
|
-
#
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
# if we got here, but verify_ref_cmd didn't error, we don't know why
|
128
|
-
# the original git command failed, so re-raise.
|
129
|
-
raise e
|
130
|
-
end
|
123
|
+
# "unborn" branch, i.e. one with no commits or
|
124
|
+
# verify_ref_cmd didn't error, we don't know why
|
125
|
+
# the original git command failed, so re-raise.
|
126
|
+
unborn_branch_ref || raise(e)
|
131
127
|
end
|
132
128
|
|
133
129
|
def unborn_branch_ref
|
data/lib/chef-cli/generator.rb
CHANGED
@@ -150,7 +150,7 @@ module ChefCLI
|
|
150
150
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
151
151
|
EOH
|
152
152
|
else
|
153
|
-
raise ArgumentError, "Invalid generator.license setting: #{license}. See available licenses at https://docs.chef.io/ctl_chef/#chef-generate-cookbook"
|
153
|
+
raise ArgumentError, "Invalid generator.license setting: #{license}. See available licenses at https://docs.chef.io/workstation/ctl_chef/#chef-generate-cookbook"
|
154
154
|
end
|
155
155
|
if comment
|
156
156
|
# Ensure there's no trailing whitespace
|
data/lib/chef-cli/helpers.rb
CHANGED
@@ -87,7 +87,7 @@ module ChefCLI
|
|
87
87
|
# On Mac we place all of our symlinks under /usr/local/bin on other
|
88
88
|
# platforms they are under /usr/bin
|
89
89
|
def usr_bin_prefix
|
90
|
-
@usr_bin_prefix ||=
|
90
|
+
@usr_bin_prefix ||= macos? ? "/usr/local/bin" : "/usr/bin"
|
91
91
|
end
|
92
92
|
|
93
93
|
# Returns the full path to the given command under usr_bin_prefix
|
@@ -166,8 +166,11 @@ module ChefCLI
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
-
# Returns true if we are on
|
170
|
-
|
169
|
+
# @return [Boolean] Returns true if we are on macOS. Otherwise false
|
170
|
+
#
|
171
|
+
# @api private
|
172
|
+
#
|
173
|
+
def macos?
|
171
174
|
!!(RUBY_PLATFORM =~ /darwin/)
|
172
175
|
end
|
173
176
|
end
|
@@ -82,10 +82,14 @@ module ChefCLI
|
|
82
82
|
"artifactory(#{uri})"
|
83
83
|
end
|
84
84
|
|
85
|
+
def artifactory_api_key
|
86
|
+
chef_config&.artifactory_api_key || ENV["ARTIFACTORY_API_KEY"]
|
87
|
+
end
|
88
|
+
|
85
89
|
private
|
86
90
|
|
87
91
|
def http_connection_for(base_url)
|
88
|
-
headers = { "X-Jfrog-Art-API" =>
|
92
|
+
headers = { "X-Jfrog-Art-API" => artifactory_api_key }
|
89
93
|
@http_connections[base_url] ||= Chef::HTTP::Simple.new(base_url, headers: headers)
|
90
94
|
end
|
91
95
|
|
@@ -61,7 +61,7 @@ module ChefCLI
|
|
61
61
|
|
62
62
|
if installing_from_lock?
|
63
63
|
install_from_lock
|
64
|
-
elsif cookbooks_to_update.empty? # means update everything
|
64
|
+
elsif cookbooks_to_update.empty? || policyfile_lock.nil? # means update everything
|
65
65
|
generate_lock_and_install
|
66
66
|
else
|
67
67
|
update_lock_and_install(cookbooks_to_update, exclude_deps)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# InSpec test for recipe <%= cookbook_name %>::<%= recipe_name %>
|
2
2
|
|
3
|
-
# The InSpec reference, with examples and extensive documentation, can be
|
3
|
+
# The Chef InSpec reference, with examples and extensive documentation, can be
|
4
4
|
# found at https://docs.chef.io/inspec/resources/
|
5
5
|
|
6
6
|
unless os.windows?
|
@@ -4,7 +4,7 @@ driver:
|
|
4
4
|
|
5
5
|
## The forwarded_port port feature lets you connect to ports on the VM guest via
|
6
6
|
## localhost on the host.
|
7
|
-
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
7
|
+
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
8
8
|
|
9
9
|
# network:
|
10
10
|
# - ["forwarded_port", {guest: 80, host: 8080}]
|
@@ -4,7 +4,7 @@ driver:
|
|
4
4
|
|
5
5
|
## The forwarded_port port feature lets you connect to ports on the VM guest via
|
6
6
|
## localhost on the host.
|
7
|
-
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
7
|
+
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
8
8
|
|
9
9
|
# network:
|
10
10
|
# - ["forwarded_port", {guest: 80, host: 8080}]
|
data/lib/chef-cli/version.rb
CHANGED
data/spec/test_helpers.rb
CHANGED
@@ -129,7 +129,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
129
129
|
|
130
130
|
it "warns if a hyphenated cookbook name is passed" do
|
131
131
|
expect(with_argv(%w{my-cookbook}).run).to eq(0)
|
132
|
-
message = "Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/ctl_chef/#chef-generate-cookbook for more information."
|
132
|
+
message = "Hyphens are discouraged in cookbook names as they may cause problems with custom resources. See https://docs.chef.io/workstation/ctl_chef/#chef-generate-cookbook for more information."
|
133
133
|
expect(stdout_io.string).to include(message)
|
134
134
|
end
|
135
135
|
|
@@ -562,7 +562,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
562
562
|
|
563
563
|
## The forwarded_port port feature lets you connect to ports on the VM guest via
|
564
564
|
## localhost on the host.
|
565
|
-
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
565
|
+
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
566
566
|
|
567
567
|
# network:
|
568
568
|
# - ["forwarded_port", {guest: 80, host: 8080}]
|
@@ -645,7 +645,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
|
|
645
645
|
|
646
646
|
## The forwarded_port port feature lets you connect to ports on the VM guest via
|
647
647
|
## localhost on the host.
|
648
|
-
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
648
|
+
## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
|
649
649
|
|
650
650
|
# network:
|
651
651
|
# - ["forwarded_port", {guest: 80, host: 8080}]
|
@@ -26,7 +26,7 @@ describe ChefCLI::Command::GeneratorCommands::GeneratorGenerator do
|
|
26
26
|
let(:stdout_io) { StringIO.new }
|
27
27
|
let(:stderr_io) { StringIO.new }
|
28
28
|
|
29
|
-
let(:repo_root) { File.expand_path("
|
29
|
+
let(:repo_root) { File.expand_path("../../../..", __dir__) }
|
30
30
|
|
31
31
|
let(:builtin_generator_path) { File.join(repo_root, "lib/chef-cli/skeletons/code_generator") }
|
32
32
|
|
@@ -181,7 +181,7 @@ describe ChefCLI::Command::GeneratorCommands::GeneratorGenerator do
|
|
181
181
|
metadata_path = File.join(target_dir, "metadata.rb")
|
182
182
|
metadata_content = IO.read(metadata_path)
|
183
183
|
expected_metadata = <<~METADATA
|
184
|
-
name
|
184
|
+
name File.basename(File.dirname(__FILE__))
|
185
185
|
description 'Custom code generator cookbook for use with #{ChefCLI::Dist::PRODUCT}'
|
186
186
|
version '0.1.0'
|
187
187
|
|
@@ -264,8 +264,8 @@ describe ChefCLI::Command::ShellInit do
|
|
264
264
|
{
|
265
265
|
"exec" => "Runs the command in context of the embedded ruby",
|
266
266
|
"env" => "Prints environment variables used by #{ChefCLI::Dist::PRODUCT}",
|
267
|
-
"gem" => "Runs the `gem` command in context of the embedded
|
268
|
-
"generate" => "Generate a new
|
267
|
+
"gem" => "Runs the `gem` command in context of the embedded Ruby",
|
268
|
+
"generate" => "Generate a new repository, cookbook, or other component",
|
269
269
|
}
|
270
270
|
end
|
271
271
|
|
@@ -276,17 +276,17 @@ describe ChefCLI::Command::ShellInit do
|
|
276
276
|
|
277
277
|
let(:expected_completion_function) do
|
278
278
|
<<~END_COMPLETION
|
279
|
+
|
279
280
|
# Fish Shell command-line completions for #{ChefCLI::Dist::PRODUCT}
|
280
281
|
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
282
|
+
# set a list of all the chef commands in the Ruby chef-cli
|
283
|
+
set -l chef_commands exec env gem generate;
|
284
|
+
|
285
|
+
complete -c chef -f -n "not __fish_seen_subcommand_from $chef_commands" -a exec -d "Runs the command in context of the embedded ruby";
|
286
|
+
complete -c chef -f -n "not __fish_seen_subcommand_from $chef_commands" -a env -d "Prints environment variables used by #{ChefCLI::Dist::PRODUCT}";
|
287
|
+
complete -c chef -f -n "not __fish_seen_subcommand_from $chef_commands" -a gem -d "Runs the `gem` command in context of the embedded Ruby";
|
288
|
+
complete -c chef -f -n "not __fish_seen_subcommand_from $chef_commands" -a generate -d "Generate a new repository, cookbook, or other component";
|
285
289
|
|
286
|
-
complete -c chef -f -n '__fish_chef_no_command' -a exec -d "Runs the command in context of the embedded ruby"
|
287
|
-
complete -c chef -f -n '__fish_chef_no_command' -a env -d "Prints environment variables used by Chef Workstation"
|
288
|
-
complete -c chef -f -n '__fish_chef_no_command' -a gem -d "Runs the `gem` command in context of the embedded ruby"
|
289
|
-
complete -c chef -f -n '__fish_chef_no_command' -a generate -d "Generate a new app, cookbook, or component"
|
290
290
|
END_COMPLETION
|
291
291
|
end
|
292
292
|
|
@@ -132,10 +132,6 @@ describe ChefCLI::Command::Update do
|
|
132
132
|
context "when the command is successful" do
|
133
133
|
before do
|
134
134
|
expect(install_service).to receive(:run)
|
135
|
-
expect(ChefCLI::PolicyfileServices::UpdateAttributes).to receive(:new)
|
136
|
-
.with(policyfile: nil, ui: command.ui, root_dir: Dir.pwd, chef_config: anything)
|
137
|
-
.and_return(update_attrs_service)
|
138
|
-
expect(update_attrs_service).to receive(:run)
|
139
135
|
end
|
140
136
|
|
141
137
|
it "returns 0" do
|
@@ -159,10 +155,6 @@ describe ChefCLI::Command::Update do
|
|
159
155
|
|
160
156
|
before do
|
161
157
|
expect(install_service).to receive(:run).and_raise(exception)
|
162
|
-
expect(ChefCLI::PolicyfileServices::UpdateAttributes).to receive(:new)
|
163
|
-
.with(policyfile: nil, ui: command.ui, root_dir: Dir.pwd, chef_config: anything)
|
164
|
-
.and_return(update_attrs_service)
|
165
|
-
expect(update_attrs_service).to receive(:run)
|
166
158
|
end
|
167
159
|
|
168
160
|
it "returns 1" do
|
@@ -20,8 +20,9 @@ require "chef-cli/policyfile/source_uri"
|
|
20
20
|
require "chef-cli/policyfile/artifactory_cookbook_source"
|
21
21
|
|
22
22
|
describe ChefCLI::Policyfile::ArtifactoryCookbookSource do
|
23
|
-
subject { described_class.new(cookbook_source) }
|
23
|
+
subject { described_class.new(cookbook_source, chef_config: config) }
|
24
24
|
|
25
|
+
let(:config) { nil }
|
25
26
|
let(:cookbook_source) { "https://supermarket.chef.io/api/v1" }
|
26
27
|
|
27
28
|
let(:http_connection) { double("Chef::HTTP::Simple") }
|
@@ -56,4 +57,29 @@ describe ChefCLI::Policyfile::ArtifactoryCookbookSource do
|
|
56
57
|
expect(subject.source_options_for("apache2", "1.10.4")).to eq(expected_opts)
|
57
58
|
end
|
58
59
|
end
|
60
|
+
|
61
|
+
describe "#artifactory_api_key" do
|
62
|
+
before do
|
63
|
+
ENV["ARTIFACTORY_API_KEY"] = "test"
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when config is not present" do
|
67
|
+
let(:config) { nil }
|
68
|
+
it "should get artifactory key from the env" do
|
69
|
+
expect(subject.artifactory_api_key).to eq("test")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context "when config is present" do
|
74
|
+
let(:config) { double("Chef::Config") }
|
75
|
+
it "should get artifactory key from config when key is present" do
|
76
|
+
expect(config).to receive(:artifactory_api_key).and_return "test1"
|
77
|
+
expect(subject.artifactory_api_key).to eq("test1")
|
78
|
+
end
|
79
|
+
it "should get artifactory key from env when config is present but has a nil key" do
|
80
|
+
expect(config).to receive(:artifactory_api_key).and_return nil
|
81
|
+
expect(subject.artifactory_api_key).to eq("test")
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
59
85
|
end
|
@@ -223,7 +223,7 @@ describe ChefCLI::Policyfile::UndoStack do
|
|
223
223
|
end
|
224
224
|
|
225
225
|
it "removes the oldest record" do
|
226
|
-
oldest_record_file = undo_stack_files.
|
226
|
+
oldest_record_file = undo_stack_files.min
|
227
227
|
|
228
228
|
undo_stack.push(incremented_undo_record(11))
|
229
229
|
|
@@ -251,7 +251,7 @@ describe ChefCLI::Policyfile::UndoStack do
|
|
251
251
|
end
|
252
252
|
|
253
253
|
it "removes the oldest record" do
|
254
|
-
oldest_record_file = undo_stack_files.
|
254
|
+
oldest_record_file = undo_stack_files.min
|
255
255
|
|
256
256
|
undo_stack.push(incremented_undo_record(11))
|
257
257
|
|
@@ -19,7 +19,7 @@ require "spec_helper"
|
|
19
19
|
require "shared/setup_git_cookbooks"
|
20
20
|
require "shared/fixture_cookbook_checksums"
|
21
21
|
require "chef-cli/policyfile/storage_config"
|
22
|
-
require "chef-cli/policyfile_lock
|
22
|
+
require "chef-cli/policyfile_lock"
|
23
23
|
|
24
24
|
describe ChefCLI::PolicyfileLock, "building a lockfile", :skip_on_windows do
|
25
25
|
|
@@ -54,6 +54,10 @@ describe ChefCLI::PolicyfileServices::Install do
|
|
54
54
|
|
55
55
|
let(:overwrite) { false }
|
56
56
|
|
57
|
+
let(:cookbooks_to_update) { [] || [ "my_cookbook" ] }
|
58
|
+
|
59
|
+
let(:cookbooks_to_update_empty) { false }
|
60
|
+
|
57
61
|
let(:ui) { TestHelpers::TestUI.new }
|
58
62
|
|
59
63
|
let(:install_service) { described_class.new(policyfile: policyfile_rb_name, ui: ui, root_dir: working_dir, overwrite: overwrite) }
|
@@ -153,6 +157,90 @@ describe ChefCLI::PolicyfileServices::Install do
|
|
153
157
|
|
154
158
|
end
|
155
159
|
|
160
|
+
context "when cookbook to update is empty and no policy lock exist" do
|
161
|
+
|
162
|
+
let(:cookbooks_to_update_empty) { true }
|
163
|
+
|
164
|
+
it "create the policy lock" do
|
165
|
+
install_service.run(:cookbooks_to_update)
|
166
|
+
generated_lock = result_policyfile_lock
|
167
|
+
expect(generated_lock.name).to eq("install-example")
|
168
|
+
expect(generated_lock.cookbook_locks).to have_key("local-cookbook")
|
169
|
+
end
|
170
|
+
|
171
|
+
it "checks for policy lock" do
|
172
|
+
lock = install_service.policyfile_lock
|
173
|
+
expect(lock).to eq(nil)
|
174
|
+
end
|
175
|
+
|
176
|
+
end
|
177
|
+
|
178
|
+
context "when cookbook to update is empty and policy lock exist" do
|
179
|
+
|
180
|
+
before do
|
181
|
+
install_service.dup.run
|
182
|
+
end
|
183
|
+
|
184
|
+
let(:cookbooks_to_update_empty) { true }
|
185
|
+
|
186
|
+
it "create the policy lock" do
|
187
|
+
install_service.run(:cookbooks_to_update)
|
188
|
+
generated_lock = result_policyfile_lock
|
189
|
+
expect(generated_lock.name).to eq("install-example")
|
190
|
+
expect(generated_lock.cookbook_locks).to have_key("local-cookbook")
|
191
|
+
end
|
192
|
+
|
193
|
+
it "checks for policy lock" do
|
194
|
+
lock = install_service.policyfile_lock
|
195
|
+
expect(lock).to be_an_instance_of(ChefCLI::PolicyfileLock)
|
196
|
+
expect(lock.name).to eq("install-example")
|
197
|
+
expect(lock.cookbook_locks).to have_key("local-cookbook")
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
context "when cookbook to update is not empty and no policy lock exist" do
|
203
|
+
|
204
|
+
let(:cookbooks_to_update) { [ "my_cookbook" ] }
|
205
|
+
|
206
|
+
it "create the policy lock" do
|
207
|
+
install_service.run(:cookbooks_to_update)
|
208
|
+
generated_lock = result_policyfile_lock
|
209
|
+
expect(generated_lock.name).to eq("install-example")
|
210
|
+
expect(generated_lock.cookbook_locks).to have_key("local-cookbook")
|
211
|
+
end
|
212
|
+
|
213
|
+
it "checks for policy lock" do
|
214
|
+
lock = install_service.policyfile_lock
|
215
|
+
expect(lock).to eq(nil)
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
219
|
+
|
220
|
+
context "when cookbook to update is not empty and policy lock exist" do
|
221
|
+
|
222
|
+
before do
|
223
|
+
install_service.dup.run
|
224
|
+
end
|
225
|
+
|
226
|
+
let(:cookbooks_to_update) { [ "my_cookbook" ] }
|
227
|
+
|
228
|
+
it "create the policy lock" do
|
229
|
+
install_service.run(:cookbooks_to_update)
|
230
|
+
generated_lock = result_policyfile_lock
|
231
|
+
expect(generated_lock.name).to eq("install-example")
|
232
|
+
expect(generated_lock.cookbook_locks).to have_key("local-cookbook")
|
233
|
+
end
|
234
|
+
|
235
|
+
it "create the policy lock" do
|
236
|
+
lock = install_service.policyfile_lock
|
237
|
+
expect(lock).to be_an_instance_of(ChefCLI::PolicyfileLock)
|
238
|
+
expect(lock.name).to eq("install-example")
|
239
|
+
expect(lock.cookbook_locks).to have_key("local-cookbook")
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
243
|
+
|
156
244
|
context "and a lockfile exists and `overwrite` is specified" do
|
157
245
|
|
158
246
|
let(:overwrite) { true }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|