chef-cli 5.4.1 → 5.5.5

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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/lib/chef-cli/builtin_commands.rb +0 -3
  4. data/lib/chef-cli/command/base.rb +11 -0
  5. data/lib/chef-cli/command/clean_policy_cookbooks.rb +0 -11
  6. data/lib/chef-cli/command/clean_policy_revisions.rb +0 -11
  7. data/lib/chef-cli/command/delete_policy.rb +0 -11
  8. data/lib/chef-cli/command/delete_policy_group.rb +0 -11
  9. data/lib/chef-cli/command/diff.rb +0 -11
  10. data/lib/chef-cli/command/generate.rb +0 -5
  11. data/lib/chef-cli/command/generator_commands/cookbook.rb +14 -40
  12. data/lib/chef-cli/command/install.rb +0 -11
  13. data/lib/chef-cli/command/push.rb +0 -11
  14. data/lib/chef-cli/command/push_archive.rb +0 -11
  15. data/lib/chef-cli/command/show_policy.rb +0 -11
  16. data/lib/chef-cli/command/undelete.rb +0 -11
  17. data/lib/chef-cli/cookbook_profiler/git.rb +2 -2
  18. data/lib/chef-cli/skeletons/code_generator/recipes/cookbook.rb +0 -15
  19. data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_dokken.yml.erb +1 -1
  20. data/lib/chef-cli/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +2 -3
  21. data/lib/chef-cli/skeletons/code_generator/templates/default/recipe_spec.rb.erb +2 -2
  22. data/lib/chef-cli/version.rb +1 -1
  23. data/spec/shared/custom_generator_cookbook.rb +0 -44
  24. data/spec/spec_helper.rb +2 -0
  25. data/spec/unit/command/base_spec.rb +5 -0
  26. data/spec/unit/command/generate_spec.rb +0 -8
  27. data/spec/unit/command/generator_commands/cookbook_spec.rb +5 -336
  28. metadata +2 -5
  29. data/lib/chef-cli/command/provision.rb +0 -36
  30. data/lib/chef-cli/skeletons/code_generator/files/default/delivery-project.toml +0 -32
  31. data/lib/chef-cli/skeletons/code_generator/templates/default/delivery-project.toml.erb +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b300aa2d718271ab384ceed0a02e76fd2438740b86928ed439640b9d3b5625c
4
- data.tar.gz: ef10c53f9088e32fa35df3756276f84e5adb1255169d8b98f7226a4256a15512
3
+ metadata.gz: 1716bb7f053b4836d2e2a2fc6e309ca583a059d537606361dabf0c8b40e7cc98
4
+ data.tar.gz: 75e3112b7e47f3bd96aa84727e76ec65d80c3ef977321c5132f0bebef962e201
5
5
  SHA512:
6
- metadata.gz: 6c4cb1358e202649a77cca11c42c0238ca23c465c64ac5e13b29350f072d4df6305b4e9d08a37e45808af692361c0059b4d9fcb237af2e956e0aa24118af7052
7
- data.tar.gz: c083c5d2a81b2215a4b6df359d638f87c16470d3620f40877e598bec9231625c337d82ec52ff926b48b0801162ce491d8097c20605bfda00e30b48427db378f6
6
+ metadata.gz: c10e74154812fc6db2b0b81f8bfa48d4e0e284824b8c3beb24e19518be85d909d5ca4f6f1c8263e09b019f6469479a071b78a09ee15b1e15566c7234d580708e
7
+ data.tar.gz: f2684d4b818592bbd2c1575aa46105292a3903c2f93d3b68b60f260001474ae52b26b593fdaf9fa73113cf9e3db9397732dccbb724b605f9b50e21f6f744044b
data/Gemfile CHANGED
@@ -19,6 +19,8 @@ group :test do
19
19
  if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7")
20
20
  gem "ohai", "~> 16"
21
21
  end
22
+
23
+ gem "simplecov", require: false
22
24
  end
23
25
 
24
26
  group :development do
@@ -57,7 +57,4 @@ ChefCLI.commands do |c|
57
57
 
58
58
  c.builtin "describe-cookbook", :DescribeCookbook, require_path: "chef-cli/command/describe_cookbook",
59
59
  desc: "Prints cookbook checksum information used for cookbook identifier"
60
-
61
- # deprecated command that throws a failure warning if used. This was removed 4.2019
62
- c.builtin "provision", :Provision, desc: "Provision VMs and clusters via cookbook", hidden: true
63
60
  end
@@ -42,6 +42,17 @@ module ChefCLI
42
42
  description: "Show #{ChefCLI::Dist::PRODUCT} version",
43
43
  boolean: true
44
44
 
45
+ option :debug,
46
+ short: "-D",
47
+ long: "--debug",
48
+ description: "Enable stacktraces and other debug output",
49
+ default: false
50
+
51
+ option :config_file,
52
+ short: "-c CONFIG_FILE",
53
+ long: "--config CONFIG_FILE",
54
+ description: "Path to configuration file"
55
+
45
56
  def initialize
46
57
  super
47
58
  end
@@ -43,17 +43,6 @@ module ChefCLI
43
43
 
44
44
  BANNER
45
45
 
46
- option :config_file,
47
- short: "-c CONFIG_FILE",
48
- long: "--config CONFIG_FILE",
49
- description: "Path to configuration file"
50
-
51
- option :debug,
52
- short: "-D",
53
- long: "--debug",
54
- description: "Enable stacktraces and other debug output",
55
- default: false
56
-
57
46
  include Configurable
58
47
 
59
48
  attr_accessor :ui
@@ -42,17 +42,6 @@ module ChefCLI
42
42
 
43
43
  BANNER
44
44
 
45
- option :config_file,
46
- short: "-c CONFIG_FILE",
47
- long: "--config CONFIG_FILE",
48
- description: "Path to configuration file"
49
-
50
- option :debug,
51
- short: "-D",
52
- long: "--debug",
53
- description: "Enable stacktraces and other debug output",
54
- default: false
55
-
56
45
  include Configurable
57
46
 
58
47
  attr_accessor :ui
@@ -42,17 +42,6 @@ module ChefCLI
42
42
 
43
43
  BANNER
44
44
 
45
- option :config_file,
46
- short: "-c CONFIG_FILE",
47
- long: "--config CONFIG_FILE",
48
- description: "Path to configuration file"
49
-
50
- option :debug,
51
- short: "-D",
52
- long: "--debug",
53
- description: "Enable stacktraces and other debug output",
54
- default: false
55
-
56
45
  include Configurable
57
46
 
58
47
  attr_accessor :ui
@@ -42,17 +42,6 @@ module ChefCLI
42
42
 
43
43
  BANNER
44
44
 
45
- option :config_file,
46
- short: "-c CONFIG_FILE",
47
- long: "--config CONFIG_FILE",
48
- description: "Path to configuration file"
49
-
50
- option :debug,
51
- short: "-D",
52
- long: "--debug",
53
- description: "Enable stacktraces and other debug output",
54
- default: false
55
-
56
45
  include Configurable
57
46
 
58
47
  attr_accessor :ui
@@ -86,17 +86,6 @@ module ChefCLI
86
86
  default: true,
87
87
  boolean: true
88
88
 
89
- option :config_file,
90
- short: "-c CONFIG_FILE",
91
- long: "--config CONFIG_FILE",
92
- description: "Path to configuration file."
93
-
94
- option :debug,
95
- short: "-D",
96
- long: "--debug",
97
- description: "Enable stacktraces and other debug output.",
98
- default: false
99
-
100
89
  attr_accessor :ui
101
90
 
102
91
  attr_reader :old_base
@@ -55,7 +55,6 @@ module ChefCLI
55
55
  generator(:repo, :Repo, "Generate a #{ChefCLI::Dist::INFRA_PRODUCT} code repository")
56
56
  generator(:policyfile, :Policyfile, "Generate a Policyfile for use with the install/push commands")
57
57
  generator(:generator, :GeneratorGenerator, "Copy #{ChefCLI::Dist::PRODUCT}'s generator cookbook so you can customize it")
58
- generator(:'build-cookbook', :BuildCookbook, "DEPRECATED: Generate a build cookbook for use with #{ChefCLI::Dist::WORKFLOW}")
59
58
 
60
59
  def self.banner_headline
61
60
  <<~E
@@ -82,10 +81,6 @@ module ChefCLI
82
81
  end
83
82
 
84
83
  def run(params)
85
- if params[0] == "build-cookbook"
86
- warn "[DEPRECATION] Chef Workflow (Delivery) is end of life (EOL) as of December 31, 2020 and this generator subcommand has been removed".freeze
87
- return 1
88
- end
89
84
  if ( generator_spec = generator_for(params[0]) )
90
85
  params.shift
91
86
  generator = GeneratorCommands.build(generator_spec.class_name, params)
@@ -65,7 +65,7 @@ module ChefCLI
65
65
  option :workflow,
66
66
  short: "-w",
67
67
  long: "--workflow",
68
- description: "DEPRECATED: Generate a cookbook with a full #{ChefCLI::Dist::WORKFLOW} build cookbook.",
68
+ description: "REMOVED: #{ChefCLI::Dist::WORKFLOW} is EOL. This option has been removed.",
69
69
  boolean: true,
70
70
  default: false
71
71
 
@@ -85,7 +85,7 @@ module ChefCLI
85
85
 
86
86
  option :pipeline,
87
87
  long: "--pipeline PIPELINE",
88
- description: "Use PIPELINE to set target branch to something other than master for the #{ChefCLI::Dist::WORKFLOW} build_cookbook",
88
+ description: "REMOVED: #{ChefCLI::Dist::WORKFLOW} is EOL. This option has been removed.",
89
89
  default: "master"
90
90
 
91
91
  options.merge!(SharedGeneratorOptions.options)
@@ -119,17 +119,12 @@ module ChefCLI
119
119
 
120
120
  def emit_post_create_message
121
121
  default_recipe_file = yaml ? "default.yml" : "default.rb"
122
- if have_delivery_config?
123
- msg("Your cookbook is ready. To setup the pipeline, type `cd #{cookbook_name_or_path}`, then run `delivery init`")
124
- else
125
- msg("Your cookbook is ready. Type `cd #{cookbook_name_or_path}` to enter it.")
126
- msg("\nThere are several commands you can run to get started locally developing and testing your cookbook.")
127
- msg("Type `delivery local --help` to see a full list of local testing commands.")
128
- msg("\nWhy not start by writing an InSpec test? Tests for the default recipe are stored at:\n")
129
- msg("test/integration/default/default_test.rb")
130
- msg("\nIf you'd prefer to dive right in, the default recipe can be found at:")
131
- msg("\nrecipes/#{default_recipe_file}\n")
132
- end
122
+ msg("Your cookbook is ready. Type `cd #{cookbook_name_or_path}` to enter it.")
123
+ msg("\nThere are several commands you can run to get started locally developing and testing your cookbook.")
124
+ msg("\nWhy not start by writing an InSpec test? Tests for the default recipe are stored at:\n")
125
+ msg("test/integration/default/default_test.rb")
126
+ msg("\nIf you'd prefer to dive right in, the default recipe can be found at:")
127
+ msg("\nrecipes/#{default_recipe_file}\n")
133
128
  end
134
129
 
135
130
  def setup_context
@@ -143,16 +138,10 @@ module ChefCLI
143
138
  Generator.add_attr_to_context(:policy_run_list, policy_run_list)
144
139
  Generator.add_attr_to_context(:policy_local_cookbook, ".")
145
140
 
146
- Generator.add_attr_to_context(:enable_workflow, enable_workflow?)
147
- Generator.add_attr_to_context(:workflow_project_dir, cookbook_full_path)
148
- Generator.add_attr_to_context(:build_cookbook_parent_is_cookbook, true)
149
- Generator.add_attr_to_context(:workflow_project_git_initialized, have_git? && !cookbook_path_in_git_repo?)
150
-
151
141
  Generator.add_attr_to_context(:verbose, verbose?)
152
142
  Generator.add_attr_to_context(:specs, specs?)
153
143
 
154
144
  Generator.add_attr_to_context(:use_policyfile, policy_mode?)
155
- Generator.add_attr_to_context(:pipeline, pipeline)
156
145
  Generator.add_attr_to_context(:kitchen, kitchen)
157
146
  Generator.add_attr_to_context(:vscode_dir, create_vscode_dir?)
158
147
  Generator.add_attr_to_context(:yaml, yaml)
@@ -162,10 +151,6 @@ module ChefCLI
162
151
  config[:kitchen]
163
152
  end
164
153
 
165
- def pipeline
166
- config[:pipeline]
167
- end
168
-
169
154
  def yaml
170
155
  config[:yaml]
171
156
  end
@@ -202,10 +187,6 @@ module ChefCLI
202
187
  @policy_mode
203
188
  end
204
189
 
205
- def enable_workflow?
206
- config[:workflow]
207
- end
208
-
209
190
  def verbose?
210
191
  @verbose
211
192
  end
@@ -214,22 +195,10 @@ module ChefCLI
214
195
  @specs
215
196
  end
216
197
 
217
- #
218
- # Is there a .delivery/cli.toml in the current dir or any of the parent dirs
219
- #
220
- # @return [Boolean]
221
- #
222
- def have_delivery_config?
223
- # delivery-cli's logic is to look recursively upward for
224
- # .delivery/cli.toml starting from pwd:
225
- # https://github.com/chef/delivery-cli/blob/22cbef3987ebd0aee98405b7e161a100edc87e49/src/delivery/config/mod.rs#L225-L247
226
-
227
- Pathname.pwd.ascend.any? { |path| path.join(".delivery/cli.toml").exist? }
228
- end
229
-
230
198
  def read_and_validate_params
231
199
  arguments = parse_options(params)
232
200
  @cookbook_name_or_path = arguments[0]
201
+
233
202
  if !@cookbook_name_or_path
234
203
  @params_valid = false
235
204
  elsif File.basename(@cookbook_name_or_path).include?("-")
@@ -241,6 +210,11 @@ module ChefCLI
241
210
  @params_valid = false
242
211
  end
243
212
 
213
+ if config[:workflow] || config[:pipeline]
214
+ err("[DEPRECATION] Chef Workflow (Delivery) is end of life (EOL) as of December 31, 2020 and the --workflow and --pipeline flags have been removed")
215
+ @params_valid = false
216
+ end
217
+
244
218
  if config[:berks]
245
219
  @policy_mode = false
246
220
  end
@@ -46,17 +46,6 @@ module ChefCLI
46
46
 
47
47
  E
48
48
 
49
- option :config_file,
50
- short: "-c CONFIG_FILE",
51
- long: "--config CONFIG_FILE",
52
- description: "Path to configuration file"
53
-
54
- option :debug,
55
- short: "-D",
56
- long: "--debug",
57
- description: "Enable stacktraces and other debug output",
58
- default: false
59
-
60
49
  attr_reader :policyfile_relative_path
61
50
 
62
51
  attr_accessor :ui
@@ -44,17 +44,6 @@ module ChefCLI
44
44
 
45
45
  E
46
46
 
47
- option :config_file,
48
- short: "-c CONFIG_FILE",
49
- long: "--config CONFIG_FILE",
50
- description: "Path to configuration file"
51
-
52
- option :debug,
53
- short: "-D",
54
- long: "--debug",
55
- description: "Enable stacktraces and other debug output",
56
- default: false
57
-
58
47
  attr_reader :policyfile_relative_path
59
48
  attr_reader :policy_group
60
49
 
@@ -43,17 +43,6 @@ module ChefCLI
43
43
  Options:
44
44
  E
45
45
 
46
- option :config_file,
47
- short: "-c CONFIG_FILE",
48
- long: "--config CONFIG_FILE",
49
- description: "Path to configuration file"
50
-
51
- option :debug,
52
- short: "-D",
53
- long: "--debug",
54
- description: "Enable stacktraces and other debug output",
55
- default: false
56
-
57
46
  attr_accessor :ui
58
47
 
59
48
  attr_reader :policy_group
@@ -58,17 +58,6 @@ module ChefCLI
58
58
  default: true,
59
59
  boolean: true
60
60
 
61
- option :config_file,
62
- short: "-c CONFIG_FILE",
63
- long: "--config CONFIG_FILE",
64
- description: "Path to configuration file"
65
-
66
- option :debug,
67
- short: "-D",
68
- long: "--debug",
69
- description: "Enable stacktraces and other debug output",
70
- default: false
71
-
72
61
  include Configurable
73
62
 
74
63
  attr_accessor :ui
@@ -63,17 +63,6 @@ module ChefCLI
63
63
  long: "--id ID",
64
64
  description: "Undo the delete operation with the given ID"
65
65
 
66
- option :config_file,
67
- short: "-c CONFIG_FILE",
68
- long: "--config CONFIG_FILE",
69
- description: "Path to configuration file"
70
-
71
- option :debug,
72
- short: "-D",
73
- long: "--debug",
74
- description: "Enable stacktraces and other debug output",
75
- default: false
76
-
77
66
  include Configurable
78
67
 
79
68
  attr_accessor :ui
@@ -36,8 +36,8 @@ module ChefCLI
36
36
  {
37
37
  "scm" => "git",
38
38
  # To get this info, you need to do something like:
39
- # figure out branch or assume 'master'
40
- # git config --get branch.master.remote
39
+ # figure out branch or assume 'main'
40
+ # git config --get branch.main.remote
41
41
  # git config --get remote.opscode.url
42
42
  "remote" => remote,
43
43
  "revision" => revision,
@@ -189,18 +189,3 @@ if context.vscode_dir
189
189
  CONTENT
190
190
  end
191
191
  end
192
-
193
- if context.enable_workflow
194
- warn "\n---------WARNING---------\nThe --workflow flag is deprecated as #{ChefCLI::Dist::WORKFLOW} is EOL as of December 2020.\n\nThis flag will be ignored and will be removed in a future release.\n-------------------------\n\n"
195
- directory "#{cookbook_dir}/.delivery"
196
-
197
- template "#{cookbook_dir}/.delivery/project.toml" do
198
- variables(
199
- specs: context.specs
200
- )
201
- source 'delivery-project.toml.erb'
202
- helpers(ChefCLI::Generator::TemplateHelper)
203
- action :create_if_missing
204
- end
205
-
206
- end
@@ -13,7 +13,7 @@ verifier:
13
13
  name: inspec
14
14
 
15
15
  platforms:
16
- # @see https://github.com/chef-cookbooks/testing_examples/blob/master/kitchen.dokken.yml
16
+ # @see https://github.com/chef-cookbooks/testing_examples/blob/main/kitchen.dokken.yml
17
17
  # @see https://hub.docker.com/u/dokken
18
18
  - name: ubuntu-20.04
19
19
  driver:
@@ -2,8 +2,8 @@
2
2
  driver:
3
3
  name: vagrant
4
4
 
5
- ## The forwarded_port port feature lets you connect to ports on the VM guest via
6
- ## localhost on the host.
5
+ ## The forwarded_port port feature lets you connect to ports on the VM guest
6
+ ## via localhost on the host.
7
7
  ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
8
8
 
9
9
  # network:
@@ -29,4 +29,3 @@ suites:
29
29
  verifier:
30
30
  inspec_tests:
31
31
  - test/integration/default
32
- attributes:
@@ -9,7 +9,7 @@ require 'spec_helper'
9
9
  describe '<%= cookbook_name %>::<%= recipe_name %>' do
10
10
  context 'When all attributes are default, on Ubuntu 20.04' do
11
11
  # for a complete list of available platforms and versions see:
12
- # https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
12
+ # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
13
13
  platform 'ubuntu', '20.04'
14
14
 
15
15
  it 'converges successfully' do
@@ -19,7 +19,7 @@ describe '<%= cookbook_name %>::<%= recipe_name %>' do
19
19
 
20
20
  context 'When all attributes are default, on CentOS 8' do
21
21
  # for a complete list of available platforms and versions see:
22
- # https://github.com/chefspec/fauxhai/blob/master/PLATFORMS.md
22
+ # https://github.com/chefspec/fauxhai/blob/main/PLATFORMS.md
23
23
  platform 'centos', '8'
24
24
 
25
25
  it 'converges successfully' do
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module ChefCLI
19
- VERSION = "5.4.1".freeze
19
+ VERSION = "5.5.5".freeze
20
20
  end
@@ -66,23 +66,6 @@ shared_examples_for "custom generator cookbook" do
66
66
  end
67
67
  end
68
68
 
69
- context "with an invalid generator-cookbook path" do
70
-
71
- it "fails with an informative error" do
72
- Dir.chdir(tempdir) do
73
- allow(code_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
74
- allow(code_generator).to receive(:stderr).and_return(stderr_io)
75
- expect(code_generator.run).to eq(1)
76
- end
77
-
78
- cookbook_path = File.dirname(generator_cookbook_path)
79
- expected_msg = %Q{ERROR: Could not find cookbook(s) to satisfy run list ["recipe[a_generator_cookbook::#{generator_name}]"] in #{cookbook_path}}
80
-
81
- expect(stderr_io.string).to include(expected_msg)
82
- end
83
-
84
- end
85
-
86
69
  context "with a generator-cookbook path to a specific cookbook" do
87
70
 
88
71
  let(:metadata_file) { File.join(generator_cookbook_path, "metadata.rb") }
@@ -105,32 +88,5 @@ shared_examples_for "custom generator cookbook" do
105
88
  end
106
89
 
107
90
  end
108
-
109
- context "with a generator-cookbook path to a directory containing a 'code_generator' cookbook" do
110
-
111
- before do
112
- FileUtils.mkdir_p(generator_cookbook_path)
113
- FileUtils.cp_r(default_generator_cookbook_path, generator_cookbook_path)
114
-
115
- allow(code_generator).to receive(:stderr).and_return(stderr_io)
116
- end
117
-
118
- it "creates the new_files (and warns about deprecated usage)" do
119
- allow(code_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
120
-
121
- Dir.chdir(tempdir) do
122
- code_generator.run
123
- end
124
- generated_files = Dir.glob("#{tempdir}/#{generator_arg}/**/*", File::FNM_DOTMATCH)
125
- expected_cookbook_files.each do |expected_file|
126
- expect(generated_files).to include(expected_file)
127
- end
128
-
129
- code_generator_path = File.join(generator_cookbook_path, "code_generator")
130
- warning_message = "WARN: Please configure the generator cookbook by giving the full path to the desired cookbook (like '#{code_generator_path}')"
131
-
132
- expect(stderr_io.string).to include(warning_message)
133
- end
134
- end
135
91
  end
136
92
  end
data/spec/spec_helper.rb CHANGED
@@ -24,6 +24,8 @@ require "chef/workstation_config_loader"
24
24
  require "chef/config"
25
25
 
26
26
  require "chef-cli/cli"
27
+ require "simplecov"
28
+ SimpleCov.start
27
29
 
28
30
  RSpec.configure do |c|
29
31
  running_on_windows = (RUBY_PLATFORM =~ /mswin|mingw|windows/)
@@ -16,6 +16,7 @@
16
16
  #
17
17
 
18
18
  require "spec_helper"
19
+ require "chef-cli/command/base"
19
20
 
20
21
  describe ChefCLI::Command::Base do
21
22
  class TestCommand < ChefCLI::Command::Base
@@ -126,6 +127,8 @@ describe ChefCLI::Command::Base do
126
127
  use me please
127
128
  -a, --arg ARG An option with a required argument
128
129
  --chef-license ACCEPTANCE Accept the license for this product and any contained products ('accept', 'accept-no-persist', or 'accept-silent')
130
+ -c, --config CONFIG_FILE Path to configuration file
131
+ -D, --debug Enable stacktraces and other debug output
129
132
  -h, --help Show this message
130
133
  -u, --user If the user exists
131
134
  -v, --version Show #{ChefCLI::Dist::PRODUCT} version
@@ -147,6 +150,8 @@ describe ChefCLI::Command::Base do
147
150
  use me please
148
151
  -a, --arg ARG An option with a required argument
149
152
  --chef-license ACCEPTANCE Accept the license for this product and any contained products ('accept', 'accept-no-persist', or 'accept-silent')
153
+ -c, --config CONFIG_FILE Path to configuration file
154
+ -D, --debug Enable stacktraces and other debug output
150
155
  -h, --help Show this message
151
156
  -u, --user If the user exists
152
157
  -v, --version Show #{ChefCLI::Dist::PRODUCT} version
@@ -137,13 +137,5 @@ describe ChefCLI::Command::Generate do
137
137
  end
138
138
 
139
139
  end
140
-
141
- describe "When build-cookbookis given as subcommand" do
142
- it "shows deprecation warning when" do
143
- result = generate.run(%w{build-cookbook example})
144
- expect(result).to eq(1)
145
- end
146
- end
147
-
148
140
  end
149
141
  end
@@ -87,7 +87,6 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
87
87
  Your cookbook is ready. Type `cd new_cookbook` to enter it.
88
88
 
89
89
  There are several commands you can run to get started locally developing and testing your cookbook.
90
- Type `delivery local --help` to see a full list of local testing commands.
91
90
 
92
91
  Why not start by writing an InSpec test? Tests for the default recipe are stored at:
93
92
 
@@ -152,7 +151,7 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
152
151
  end
153
152
 
154
153
  it "warns if a hyphenated cookbook name is passed" do
155
- expect(with_argv(%w{my-cookbook}).run).to eq(0)
154
+ expect(with_argv(%w{my-cookbook}).run).to eq(1)
156
155
  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."
157
156
  expect(stdout_io.string).to include(message)
158
157
  end
@@ -177,18 +176,6 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
177
176
  expect(generator_context.specs).to be(false)
178
177
  end
179
178
 
180
- it "creates a new cookbook" do
181
-
182
- Dir.chdir(tempdir) do
183
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
184
- expect(cookbook_generator.run).to eq(0)
185
- end
186
- generated_files = Dir.glob("#{tempdir}/new_cookbook/**/*", File::FNM_DOTMATCH)
187
- expected_cookbook_files.each do |expected_file|
188
- expect(generated_files).to include(expected_file)
189
- end
190
- end
191
-
192
179
  context "when given the specs flag" do
193
180
 
194
181
  let(:argv) { %w{ new_cookbook --specs } }
@@ -198,17 +185,6 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
198
185
  cookbook_generator.setup_context
199
186
  expect(generator_context.specs).to be(true)
200
187
  end
201
-
202
- it "creates a new cookbook" do
203
- Dir.chdir(tempdir) do
204
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
205
- expect(cookbook_generator.run).to eq(0)
206
- end
207
- generated_files = Dir.glob("#{tempdir}/new_cookbook/**/*", File::FNM_DOTMATCH)
208
- expected_cookbook_files_specs.each do |expected_file|
209
- expect(generated_files).to include(expected_file)
210
- end
211
- end
212
188
  end
213
189
 
214
190
  context "when given the verbose flag" do
@@ -220,34 +196,19 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
220
196
  cookbook_generator.setup_context
221
197
  expect(generator_context.verbose).to be(true)
222
198
  end
223
-
224
- it "emits verbose output" do
225
- Dir.chdir(tempdir) do
226
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
227
- expect(cookbook_generator.run).to eq(0)
228
- end
229
-
230
- # The normal chef formatter puts a heading for each recipe like this.
231
- # Full output is large and subject to change with minor changes in the
232
- # generator cookbook, so we just look for this line
233
- expected_line = "Recipe: code_generator::cookbook"
234
-
235
- actual = stdout_io.string
236
-
237
- expect(actual).to include(expected_line)
238
- end
239
199
  end
240
200
 
241
201
  shared_examples_for "a generated file" do |context_var|
242
202
  before do
243
203
  Dir.chdir(tempdir) do
244
204
  allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
245
- expect(cookbook_generator.run).to eq(0)
205
+ expect(cookbook_generator.run).to eq(1)
246
206
  end
247
207
  end
248
208
 
249
- it "should contain #{context_var} from the generator context" do
250
- expect(File.read(file)).to match line
209
+ it "should not generate a file" do
210
+ expect(File.directory?(file)).to be false
211
+ expect(File).not_to exist(file)
251
212
  end
252
213
  end
253
214
 
@@ -267,298 +228,6 @@ describe ChefCLI::Command::GeneratorCommands::Cookbook do
267
228
  end
268
229
  end
269
230
 
270
- # This shared example group requires a let binding for
271
- # `expected_kitchen_yml_content`
272
- shared_examples_for "kitchen_yml_and_integration_tests" do
273
-
274
- describe "Generating Test Kitchen and integration testing files" do
275
-
276
- describe "generating kitchen config" do
277
-
278
- before do
279
- Dir.chdir(tempdir) do
280
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
281
- expect(cookbook_generator.run).to eq(0)
282
- end
283
- end
284
-
285
- let(:file) { File.join(tempdir, "new_cookbook", "kitchen.yml") }
286
-
287
- it "creates a kitchen.yml with the expected content" do
288
- expect(IO.read(file)).to eq(expected_kitchen_yml_content)
289
- end
290
-
291
- end
292
-
293
- describe "test/integration/default/default_test.rb" do
294
- let(:file) { File.join(tempdir, "new_cookbook", "test", "integration", "default", "default_test.rb") }
295
-
296
- include_examples "a generated file", :cookbook_name do
297
- let(:line) { "describe port" }
298
- end
299
- end
300
- end
301
- end
302
-
303
- # This shared example group requires you to define a let binding for
304
- # `expected_chefspec_spec_helper_content`
305
- shared_examples_for "chefspec_spec_helper_file" do
306
-
307
- describe "Generating ChefSpec files" do
308
-
309
- before do
310
- Dir.chdir(tempdir) do
311
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
312
- expect(cookbook_generator.run).to eq(0)
313
- end
314
- end
315
-
316
- let(:file) { File.join(tempdir, "new_cookbook", "spec", "spec_helper.rb") }
317
-
318
- it "creates a spec/spec_helper.rb for ChefSpec with the expected content" do
319
- expect(IO.read(file)).to eq(expected_chefspec_spec_helper_content)
320
- end
321
-
322
- end
323
-
324
- end
325
-
326
- context "when configured for Policyfiles" do
327
-
328
- let(:argv) { %w{new_cookbook --policy} }
329
-
330
- describe "Policyfile.rb" do
331
-
332
- let(:file) { File.join(tempdir, "new_cookbook", "Policyfile.rb") }
333
-
334
- let(:expected_content) do
335
- <<~POLICYFILE_RB
336
- # Policyfile.rb - Describe how you want Chef Infra Client to build your system.
337
- #
338
- # For more information on the Policyfile feature, visit
339
- # https://docs.chef.io/policyfile/
340
-
341
- # A name that describes what the system you're building with Chef does.
342
- name 'new_cookbook'
343
-
344
- # Where to find external cookbooks:
345
- default_source :supermarket
346
-
347
- # run_list: chef-client will run these recipes in the order specified.
348
- run_list 'new_cookbook::default'
349
-
350
- # Specify a custom source for a single cookbook:
351
- cookbook 'new_cookbook', path: '.'
352
- POLICYFILE_RB
353
- end
354
-
355
- before do
356
- Dir.chdir(tempdir) do
357
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
358
- expect(cookbook_generator.run).to eq(0)
359
- end
360
- end
361
-
362
- it "has a run_list and cookbook path that will work out of the box" do
363
- expect(IO.read(file)).to eq(expected_content)
364
- end
365
-
366
- end
367
-
368
- include_examples "kitchen_yml_and_integration_tests" do
369
-
370
- let(:expected_kitchen_yml_content) do
371
- <<~KITCHEN_YML
372
- ---
373
- driver:
374
- name: vagrant
375
-
376
- ## The forwarded_port port feature lets you connect to ports on the VM guest via
377
- ## localhost on the host.
378
- ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
379
-
380
- # network:
381
- # - ["forwarded_port", {guest: 80, host: 8080}]
382
-
383
- provisioner:
384
- name: chef_zero
385
-
386
- ## product_name and product_version specifies a specific Chef product and version to install.
387
- ## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
388
- # product_name: chef
389
- # product_version: 17
390
-
391
- verifier:
392
- name: inspec
393
-
394
- platforms:
395
- - name: ubuntu-20.04
396
- - name: centos-8
397
-
398
- suites:
399
- - name: default
400
- verifier:
401
- inspec_tests:
402
- - test/integration/default
403
- attributes:
404
- KITCHEN_YML
405
- end
406
-
407
- end
408
-
409
- include_examples "chefspec_spec_helper_file" do
410
- let(:argv) { %w{ new_cookbook --policy --specs } }
411
-
412
- let(:expected_chefspec_spec_helper_content) do
413
- <<~SPEC_HELPER
414
- require 'chefspec'
415
- require 'chefspec/policyfile'
416
- SPEC_HELPER
417
- end
418
-
419
- end
420
-
421
- end
422
-
423
- context "when YAML recipe flag is passed" do
424
-
425
- let(:argv) { %w{new_cookbook --yaml} }
426
-
427
- describe "recipes/default.yml" do
428
- let(:file) { File.join(tempdir, "new_cookbook", "recipes", "default.yml") }
429
-
430
- let(:expected_content_header) do
431
- <<~DEFAULT_YML_HEADER
432
- #
433
- # Cookbook:: new_cookbook
434
- # Recipe:: default
435
- #
436
- DEFAULT_YML_HEADER
437
- end
438
-
439
- let(:expected_content) do
440
- <<~DEFAULT_YML_CONTENT
441
- ---
442
- resources:
443
- # Example Syntax
444
- # Additional snippets are available using the Chef Infra Extension for Visual Studio Code
445
- # - type: file
446
- # name: '/path/to/file'
447
- # content: 'content'
448
- # owner: 'root'
449
- # group: 'root'
450
- # mode: '0755'
451
- # action:
452
- # - create
453
- DEFAULT_YML_CONTENT
454
- end
455
-
456
- before do
457
- Dir.chdir(tempdir) do
458
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
459
- expect(cookbook_generator.run).to eq(0)
460
- end
461
- end
462
-
463
- it "has a default.yml file with template contents" do
464
- expect(IO.read(file)).to match(expected_content_header)
465
- expect(IO.read(file)).to match(expected_content)
466
- end
467
-
468
- end
469
-
470
- end
471
-
472
- context "when configured for Berkshelf" do
473
-
474
- let(:argv) { %w{new_cookbook --berks} }
475
-
476
- describe "Berksfile" do
477
-
478
- let(:file) { File.join(tempdir, "new_cookbook", "Berksfile") }
479
-
480
- let(:expected_content) do
481
- <<~POLICYFILE_RB
482
- source 'https://supermarket.chef.io'
483
-
484
- metadata
485
- POLICYFILE_RB
486
- end
487
-
488
- before do
489
- Dir.chdir(tempdir) do
490
- allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
491
- expect(cookbook_generator.run).to eq(0)
492
- end
493
- end
494
-
495
- it "pulls deps from metadata" do
496
- expect(IO.read(file)).to eq(expected_content)
497
- end
498
-
499
- end
500
-
501
- include_examples "kitchen_yml_and_integration_tests" do
502
-
503
- let(:expected_kitchen_yml_content) do
504
- <<~KITCHEN_YML
505
- ---
506
- driver:
507
- name: vagrant
508
-
509
- ## The forwarded_port port feature lets you connect to ports on the VM guest via
510
- ## localhost on the host.
511
- ## see also: https://www.vagrantup.com/docs/networking/forwarded_ports
512
-
513
- # network:
514
- # - ["forwarded_port", {guest: 80, host: 8080}]
515
-
516
- provisioner:
517
- name: chef_zero
518
- # You may wish to disable always updating cookbooks in CI or other testing environments.
519
- # For example:
520
- # always_update_cookbooks: <%= !ENV['CI'] %>
521
- always_update_cookbooks: true
522
-
523
- ## product_name and product_version specifies a specific Chef product and version to install.
524
- ## see the Chef documentation for more details: https://docs.chef.io/workstation/config_yml_kitchen/
525
- # product_name: chef
526
- # product_version: 17
527
-
528
- verifier:
529
- name: inspec
530
-
531
- platforms:
532
- - name: ubuntu-20.04
533
- - name: centos-8
534
-
535
- suites:
536
- - name: default
537
- run_list:
538
- - recipe[new_cookbook::default]
539
- verifier:
540
- inspec_tests:
541
- - test/integration/default
542
- attributes:
543
- KITCHEN_YML
544
- end
545
-
546
- end
547
-
548
- include_examples "chefspec_spec_helper_file" do
549
- let(:argv) { %w{ new_cookbook --berks --specs } }
550
-
551
- let(:expected_chefspec_spec_helper_content) do
552
- <<~SPEC_HELPER
553
- require 'chefspec'
554
- require 'chefspec/berkshelf'
555
- SPEC_HELPER
556
- end
557
-
558
- end
559
-
560
- end
561
-
562
231
  describe "metadata.rb" do
563
232
  let(:file) { File.join(tempdir, "new_cookbook", "metadata.rb") }
564
233
 
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: 5.4.1
4
+ version: 5.5.5
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-07-31 00:00:00.000000000 Z
11
+ date: 2022-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-cli
@@ -254,7 +254,6 @@ files:
254
254
  - lib/chef-cli/command/generator_commands/resource.rb
255
255
  - lib/chef-cli/command/generator_commands/template.rb
256
256
  - lib/chef-cli/command/install.rb
257
- - lib/chef-cli/command/provision.rb
258
257
  - lib/chef-cli/command/push.rb
259
258
  - lib/chef-cli/command/push_archive.rb
260
259
  - lib/chef-cli/command/shell_init.rb
@@ -330,7 +329,6 @@ files:
330
329
  - lib/chef-cli/skeletons/code_generator/files/default/chefignore
331
330
  - lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md
332
331
  - lib/chef-cli/skeletons/code_generator/files/default/cookbook_readmes/README.md
333
- - lib/chef-cli/skeletons/code_generator/files/default/delivery-project.toml
334
332
  - lib/chef-cli/skeletons/code_generator/files/default/gitignore
335
333
  - lib/chef-cli/skeletons/code_generator/files/default/repo/README.md
336
334
  - lib/chef-cli/skeletons/code_generator/files/default/repo/cookbooks/example/README.md
@@ -367,7 +365,6 @@ files:
367
365
  - lib/chef-cli/skeletons/code_generator/templates/default/README.md.erb
368
366
  - lib/chef-cli/skeletons/code_generator/templates/default/attribute.rb.erb
369
367
  - lib/chef-cli/skeletons/code_generator/templates/default/cookbook_file.erb
370
- - lib/chef-cli/skeletons/code_generator/templates/default/delivery-project.toml.erb
371
368
  - lib/chef-cli/skeletons/code_generator/templates/default/helpers.rb.erb
372
369
  - lib/chef-cli/skeletons/code_generator/templates/default/inspec_default_test.rb.erb
373
370
  - lib/chef-cli/skeletons/code_generator/templates/default/kitchen.yml.erb
@@ -1,36 +0,0 @@
1
- #
2
- # Copyright:: Chef Software Inc.
3
- # License:: Apache License, Version 2.0
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
- #
17
-
18
- require_relative "base"
19
- require_relative "../chef_runner"
20
- require_relative "../dist"
21
-
22
- module ChefCLI
23
-
24
- module Command
25
-
26
- class Provision < Base
27
-
28
- banner("DEPRECATED: Chef provisioning has been removed from #{ChefCLI::Dist::PRODUCT}. If you require Chef Provisioning you will need to install an earlier version of these products!")
29
-
30
- def run(params = [])
31
- raise "Chef provisioning has been removed from #{ChefCLI::Dist::PRODUCT}. If you require Chef Provisioning you will need to install an earlier version of these products!"
32
- end
33
-
34
- end
35
- end
36
- end
@@ -1,32 +0,0 @@
1
- # Delivery for Local Phases Execution
2
- #
3
- # This file allows you to execute test phases locally on a workstation or
4
- # in a CI pipeline. The delivery-cli will read this file and execute the
5
- # command(s) that are configured for each phase. You can customize them
6
- # by just modifying the phase key on this file.
7
- #
8
- # By default these phases are configured for Cookbook Workflow only
9
- #
10
-
11
- [local_phases]
12
- unit = "chef exec rspec spec/"
13
- lint = "chef exec cookstyle"
14
- # foodcritic has been deprecated in favor of cookstyle so we skip the syntax
15
- # phase now.
16
- syntax = "echo skipping syntax phase. Use lint phase instead."
17
- provision = "chef exec kitchen create"
18
- deploy = "chef exec kitchen converge"
19
- smoke = "chef exec kitchen verify"
20
- # The functional phase is optional, you can define it by uncommenting
21
- # the line below and running the command: `delivery local functional`
22
- # functional = ""
23
- cleanup = "chef exec kitchen destroy"
24
-
25
- # Remote project.toml file
26
- #
27
- # Instead of the local phases above, you may specify a remote URI location for
28
- # the `project.toml` file. This is useful for teams that wish to centrally
29
- # manage the behavior of the `delivery local` command across many different
30
- # projects.
31
- #
32
- # remote_file = "https://url/project.toml"
@@ -1,36 +0,0 @@
1
- # Delivery for Local Phases Execution
2
- #
3
- # This file allows you to execute test phases locally on a workstation or
4
- # in a CI pipeline. The delivery-cli will read this file and execute the
5
- # command(s) that are configured for each phase. You can customize them
6
- # by just modifying the phase key on this file.
7
- #
8
- # By default these phases are configured for Cookbook Workflow only
9
- #
10
-
11
- [local_phases]
12
- <% if @specs %>
13
- unit = "chef exec rspec spec/"
14
- <% else %>
15
- unit = "echo skipping unit phase."
16
- <% end %>
17
- lint = "chef exec cookstyle"
18
- # foodcritic has been deprecated in favor of cookstyle so we skip the syntax
19
- # phase now.
20
- syntax = "echo skipping syntax phase. Use lint phase instead."
21
- provision = "chef exec kitchen create"
22
- deploy = "chef exec kitchen converge"
23
- smoke = "chef exec kitchen verify"
24
- # The functional phase is optional, you can define it by uncommenting
25
- # the line below and running the command: `delivery local functional`
26
- # functional = ""
27
- cleanup = "chef exec kitchen destroy"
28
-
29
- # Remote project.toml file
30
- #
31
- # Instead of the local phases above, you may specify a remote URI location for
32
- # the `project.toml` file. This is useful for teams that wish to centrally
33
- # manage the behavior of the `delivery local` command across many different
34
- # projects.
35
- #
36
- # remote_file = "https://url/project.toml"