chef-dk 1.2.22 → 1.3.40
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -12
- data/Gemfile.lock +120 -116
- data/README.md +4 -3
- data/Rakefile +54 -0
- data/acceptance/Gemfile.lock +36 -47
- data/bin/chef +1 -1
- data/chef-dk.gemspec +9 -9
- data/lib/chef-dk/authenticated_http.rb +6 -7
- data/lib/chef-dk/builtin_commands.rb +3 -4
- data/lib/chef-dk/chef_runner.rb +7 -8
- data/lib/chef-dk/cli.rb +11 -11
- data/lib/chef-dk/command/base.rb +4 -4
- data/lib/chef-dk/command/clean_policy_cookbooks.rb +4 -5
- data/lib/chef-dk/command/clean_policy_revisions.rb +4 -6
- data/lib/chef-dk/command/delete_policy.rb +4 -6
- data/lib/chef-dk/command/delete_policy_group.rb +6 -8
- data/lib/chef-dk/command/diff.rb +9 -10
- data/lib/chef-dk/command/env.rb +26 -27
- data/lib/chef-dk/command/exec.rb +5 -6
- data/lib/chef-dk/command/export.rb +8 -10
- data/lib/chef-dk/command/gem.rb +5 -5
- data/lib/chef-dk/command/generate.rb +19 -19
- data/lib/chef-dk/command/generator_commands.rb +8 -8
- data/lib/chef-dk/command/generator_commands/app.rb +2 -3
- data/lib/chef-dk/command/generator_commands/attribute.rb +2 -3
- data/lib/chef-dk/command/generator_commands/base.rb +13 -13
- data/lib/chef-dk/command/generator_commands/build_cookbook.rb +2 -2
- data/lib/chef-dk/command/generator_commands/chef_exts/generator_desc_resource.rb +2 -2
- data/lib/chef-dk/command/generator_commands/chef_exts/quieter_doc_formatter.rb +1 -2
- data/lib/chef-dk/command/generator_commands/chef_exts/recipe_dsl_ext.rb +1 -2
- data/lib/chef-dk/command/generator_commands/cookbook.rb +2 -2
- data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +3 -3
- data/lib/chef-dk/command/generator_commands/cookbook_file.rb +2 -2
- data/lib/chef-dk/command/generator_commands/generator_generator.rb +4 -7
- data/lib/chef-dk/command/generator_commands/lwrp.rb +2 -2
- data/lib/chef-dk/command/generator_commands/policyfile.rb +2 -3
- data/lib/chef-dk/command/generator_commands/recipe.rb +2 -2
- data/lib/chef-dk/command/generator_commands/repo.rb +1 -3
- data/lib/chef-dk/command/generator_commands/template.rb +2 -2
- data/lib/chef-dk/command/install.rb +4 -5
- data/lib/chef-dk/command/provision.rb +12 -14
- data/lib/chef-dk/command/push.rb +5 -6
- data/lib/chef-dk/command/push_archive.rb +4 -5
- data/lib/chef-dk/command/shell_init.rb +15 -16
- data/lib/chef-dk/command/show_policy.rb +5 -7
- data/lib/chef-dk/command/undelete.rb +6 -7
- data/lib/chef-dk/command/update.rb +5 -6
- data/lib/chef-dk/command/verify.rb +30 -31
- data/lib/chef-dk/commands_map.rb +1 -3
- data/lib/chef-dk/component_test.rb +13 -13
- data/lib/chef-dk/configurable.rb +2 -2
- data/lib/chef-dk/cookbook_metadata.rb +2 -2
- data/lib/chef-dk/cookbook_omnifetch.rb +7 -8
- data/lib/chef-dk/cookbook_profiler/git.rb +8 -8
- data/lib/chef-dk/cookbook_profiler/identifiers.rb +7 -7
- data/lib/chef-dk/cookbook_profiler/null_scm.rb +0 -1
- data/lib/chef-dk/exceptions.rb +1 -1
- data/lib/chef-dk/generator.rb +9 -7
- data/lib/chef-dk/helpers.rb +15 -15
- data/lib/chef-dk/pager.rb +2 -3
- data/lib/chef-dk/policyfile/chef_repo_cookbook_source.rb +4 -4
- data/lib/chef-dk/policyfile/chef_server_cookbook_source.rb +6 -6
- data/lib/chef-dk/policyfile/community_cookbook_source.rb +4 -5
- data/lib/chef-dk/policyfile/comparison_base.rb +3 -4
- data/lib/chef-dk/policyfile/cookbook_location_specification.rb +6 -6
- data/lib/chef-dk/policyfile/cookbook_locks.rb +11 -11
- data/lib/chef-dk/policyfile/cookbook_sources.rb +5 -5
- data/lib/chef-dk/policyfile/delivery_supermarket_source.rb +8 -9
- data/lib/chef-dk/policyfile/differ.rb +7 -10
- data/lib/chef-dk/policyfile/dsl.rb +10 -11
- data/lib/chef-dk/policyfile/lister.rb +3 -6
- data/lib/chef-dk/policyfile/null_cookbook_source.rb +3 -3
- data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +3 -3
- data/lib/chef-dk/policyfile/reports/install.rb +3 -4
- data/lib/chef-dk/policyfile/reports/table_printer.rb +0 -1
- data/lib/chef-dk/policyfile/reports/upload.rb +4 -4
- data/lib/chef-dk/policyfile/solution_dependencies.rb +22 -22
- data/lib/chef-dk/policyfile/source_uri.rb +2 -2
- data/lib/chef-dk/policyfile/storage_config.rb +4 -5
- data/lib/chef-dk/policyfile/undo_record.rb +6 -9
- data/lib/chef-dk/policyfile/undo_stack.rb +5 -7
- data/lib/chef-dk/policyfile/uploader.rb +8 -8
- data/lib/chef-dk/policyfile_compiler.rb +16 -20
- data/lib/chef-dk/policyfile_lock.rb +10 -11
- data/lib/chef-dk/policyfile_services/clean_policies.rb +3 -3
- data/lib/chef-dk/policyfile_services/clean_policy_cookbooks.rb +3 -5
- data/lib/chef-dk/policyfile_services/export_repo.rb +13 -14
- data/lib/chef-dk/policyfile_services/install.rb +6 -6
- data/lib/chef-dk/policyfile_services/push.rb +6 -8
- data/lib/chef-dk/policyfile_services/push_archive.rb +6 -10
- data/lib/chef-dk/policyfile_services/rm_policy.rb +4 -5
- data/lib/chef-dk/policyfile_services/rm_policy_group.rb +4 -5
- data/lib/chef-dk/policyfile_services/show_policy.rb +5 -6
- data/lib/chef-dk/policyfile_services/undelete.rb +3 -3
- data/lib/chef-dk/policyfile_services/update_attributes.rb +4 -6
- data/lib/chef-dk/service_exception_inspectors.rb +2 -3
- data/lib/chef-dk/service_exception_inspectors/base.rb +0 -1
- data/lib/chef-dk/service_exception_inspectors/http.rb +1 -3
- data/lib/chef-dk/service_exceptions.rb +1 -2
- data/lib/chef-dk/shell_out.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/.kitchen.yml +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/README.md +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/metadata.rb +0 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +6 -6
- data/lib/chef-dk/skeletons/code_generator/recipes/attribute.rb +3 -3
- data/lib/chef-dk/skeletons/code_generator/recipes/build_cookbook.rb +43 -39
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +31 -22
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb +5 -5
- data/lib/chef-dk/skeletons/code_generator/recipes/lwrp.rb +4 -4
- data/lib/chef-dk/skeletons/code_generator/recipes/policyfile.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +8 -8
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +15 -15
- data/lib/chef-dk/skeletons/code_generator/recipes/template.rb +6 -6
- data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/Berksfile.erb +0 -2
- data/lib/chef-dk/skeletons/code_generator/templates/default/build_cookbook/metadata.rb.erb +1 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +4 -4
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen.yml.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +4 -3
- data/lib/chef-dk/skeletons/code_generator/templates/default/recipe_spec.rb.erb +4 -2
- data/lib/chef-dk/ui.rb +0 -1
- data/lib/chef-dk/version.rb +1 -1
- data/lib/kitchen/provisioner/policyfile_zero.rb +7 -7
- data/omnibus_overrides.rb +3 -3
- data/spec/shared/a_file_generator.rb +3 -3
- data/spec/shared/custom_generator_cookbook.rb +6 -6
- data/spec/shared/fixture_cookbook_checksums.rb +2 -3
- data/spec/shared/setup_git_committer_config.rb +1 -1
- data/spec/shared/setup_git_cookbooks.rb +2 -2
- data/spec/spec_helper.rb +5 -5
- data/spec/test_helpers.rb +2 -2
- data/spec/unit/chef_runner_spec.rb +5 -7
- data/spec/unit/cli_spec.rb +36 -37
- data/spec/unit/command/base_spec.rb +4 -5
- data/spec/unit/command/clean_policy_cookbooks_spec.rb +8 -9
- data/spec/unit/command/clean_policy_revisions_spec.rb +8 -9
- data/spec/unit/command/delete_policy_group_spec.rb +11 -12
- data/spec/unit/command/delete_policy_spec.rb +11 -12
- data/spec/unit/command/diff_spec.rb +5 -6
- data/spec/unit/command/env_spec.rb +5 -5
- data/spec/unit/command/exec_spec.rb +18 -19
- data/spec/unit/command/export_spec.rb +5 -6
- data/spec/unit/command/generate_spec.rb +10 -10
- data/spec/unit/command/generator_commands/app_spec.rb +6 -6
- data/spec/unit/command/generator_commands/attribute_spec.rb +3 -4
- data/spec/unit/command/generator_commands/base_spec.rb +46 -46
- data/spec/unit/command/generator_commands/build_cookbook_spec.rb +50 -16
- data/spec/unit/command/generator_commands/chef_exts/generator_desc_resource_spec.rb +9 -9
- data/spec/unit/command/generator_commands/chef_exts/recipe_dsl_ext_spec.rb +16 -16
- data/spec/unit/command/generator_commands/cookbook_file_spec.rb +3 -4
- data/spec/unit/command/generator_commands/cookbook_spec.rb +23 -26
- data/spec/unit/command/generator_commands/generator_generator_spec.rb +4 -6
- data/spec/unit/command/generator_commands/lwrp_spec.rb +3 -4
- data/spec/unit/command/generator_commands/policyfile_spec.rb +3 -5
- data/spec/unit/command/generator_commands/recipe_spec.rb +4 -4
- data/spec/unit/command/generator_commands/repo_spec.rb +11 -11
- data/spec/unit/command/generator_commands/template_spec.rb +3 -4
- data/spec/unit/command/install_spec.rb +6 -6
- data/spec/unit/command/provision_spec.rb +27 -30
- data/spec/unit/command/push_archive_spec.rb +3 -3
- data/spec/unit/command/push_spec.rb +5 -6
- data/spec/unit/command/shell_init_spec.rb +17 -19
- data/spec/unit/command/show_policy_spec.rb +11 -12
- data/spec/unit/command/undelete_spec.rb +12 -14
- data/spec/unit/command/update_spec.rb +8 -8
- data/spec/unit/command/verify_spec.rb +10 -10
- data/spec/unit/commands_map_spec.rb +4 -4
- data/spec/unit/component_test_spec.rb +3 -3
- data/spec/unit/configurable_spec.rb +7 -7
- data/spec/unit/cookbook_metadata_spec.rb +5 -7
- data/spec/unit/cookbook_profiler/git_spec.rb +6 -7
- data/spec/unit/cookbook_profiler/identifiers_spec.rb +5 -7
- data/spec/unit/fixtures/command/cli_test_command.rb +2 -2
- data/spec/unit/fixtures/configurable/test_configurable.rb +1 -1
- data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +13 -16
- data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/berkshelf/verify_me +1 -1
- data/spec/unit/gemfile_util_spec.rb +4 -4
- data/spec/unit/generator_spec.rb +10 -10
- data/spec/unit/helpers_spec.rb +31 -31
- data/spec/unit/pager_spec.rb +5 -7
- data/spec/unit/policyfile/chef_repo_cookbook_source_spec.rb +11 -11
- data/spec/unit/policyfile/chef_server_cookbook_source_spec.rb +13 -13
- data/spec/unit/policyfile/community_cookbook_source_spec.rb +3 -4
- data/spec/unit/policyfile/comparison_base_spec.rb +3 -6
- data/spec/unit/policyfile/cookbook_location_specification_spec.rb +3 -3
- data/spec/unit/policyfile/cookbook_locks_spec.rb +7 -9
- data/spec/unit/policyfile/delivery_supermarket_source_spec.rb +16 -17
- data/spec/unit/policyfile/differ_spec.rb +4 -5
- data/spec/unit/policyfile/lister_spec.rb +31 -35
- data/spec/unit/policyfile/null_cookbook_source_spec.rb +2 -3
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +3 -3
- data/spec/unit/policyfile/reports/install_spec.rb +4 -5
- data/spec/unit/policyfile/reports/upload_spec.rb +4 -6
- data/spec/unit/policyfile/solution_dependencies_spec.rb +13 -13
- data/spec/unit/policyfile/source_uri_spec.rb +5 -5
- data/spec/unit/policyfile/storage_config_spec.rb +3 -7
- data/spec/unit/policyfile/undo_record_spec.rb +21 -23
- data/spec/unit/policyfile/undo_stack_spec.rb +5 -6
- data/spec/unit/policyfile/uploader_spec.rb +73 -75
- data/spec/unit/policyfile_demands_spec.rb +93 -99
- data/spec/unit/policyfile_evaluation_spec.rb +14 -14
- data/spec/unit/policyfile_lock_build_spec.rb +64 -65
- data/spec/unit/policyfile_lock_install_spec.rb +5 -6
- data/spec/unit/policyfile_lock_serialization_spec.rb +14 -15
- data/spec/unit/policyfile_lock_validation_spec.rb +17 -20
- data/spec/unit/policyfile_services/clean_policies_spec.rb +16 -16
- data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +26 -29
- data/spec/unit/policyfile_services/export_repo_spec.rb +3 -6
- data/spec/unit/policyfile_services/install_spec.rb +5 -7
- data/spec/unit/policyfile_services/push_archive_spec.rb +4 -8
- data/spec/unit/policyfile_services/push_spec.rb +3 -3
- data/spec/unit/policyfile_services/rm_policy_group_spec.rb +16 -20
- data/spec/unit/policyfile_services/rm_policy_spec.rb +14 -17
- data/spec/unit/policyfile_services/show_policy_spec.rb +78 -80
- data/spec/unit/policyfile_services/undelete_spec.rb +5 -7
- data/spec/unit/policyfile_services/update_attributes_spec.rb +34 -35
- data/spec/unit/service_exception_inspectors/base_spec.rb +2 -4
- data/spec/unit/service_exception_inspectors/http_spec.rb +9 -11
- data/spec/unit/shell_out_spec.rb +2 -2
- data/spec/unit/tasks/helpers_spec.rb +2 -2
- data/tasks/bin/bundle-platform +1 -1
- data/tasks/bundle_util.rb +1 -1
- data/tasks/dependencies.rb +21 -7
- data/tasks/gemfile_util.rb +1 -1
- data/tasks/helpers.rb +2 -2
- data/tasks/version.rb +26 -1
- data/version_policy.rb +6 -6
- metadata +3 -3
data/omnibus_overrides.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# DO NOT EDIT. Generated by "rake dependencies". Edit version_policy.rb instead.
|
2
|
-
override :rubygems, version: "2.6.
|
2
|
+
override :rubygems, version: "2.6.11"
|
3
3
|
override :bundler, version: "1.12.5"
|
4
4
|
override "libffi", version: "3.2.1"
|
5
5
|
override "libiconv", version: "1.14"
|
6
|
-
override "liblzma", version: "5.2.
|
6
|
+
override "liblzma", version: "5.2.3"
|
7
7
|
override "libtool", version: "2.4.2"
|
8
8
|
override "libxml2", version: "2.9.4"
|
9
9
|
override "libxslt", version: "1.1.29"
|
@@ -17,4 +17,4 @@ override "util-macros", version: "1.19.0"
|
|
17
17
|
override "xproto", version: "7.0.28"
|
18
18
|
override "zlib", version: "1.2.8"
|
19
19
|
override "libzmq", version: "4.0.5"
|
20
|
-
override "
|
20
|
+
override "openssl", version: "1.0.2j"
|
@@ -73,9 +73,9 @@ shared_examples_for "a file generator" do
|
|
73
73
|
recipe_generator.run
|
74
74
|
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
generated_files.each do |expected_file|
|
77
|
+
expect(File).to exist(File.join(cookbook_path, expected_file))
|
78
|
+
end
|
79
79
|
end
|
80
80
|
|
81
81
|
end
|
@@ -7,12 +7,12 @@ shared_examples_for "custom generator cookbook" do
|
|
7
7
|
|
8
8
|
context "when given a generator-cookbook path" do
|
9
9
|
|
10
|
-
let(:default_generator_cookbook_path) { File.expand_path(
|
10
|
+
let(:default_generator_cookbook_path) { File.expand_path("lib/chef-dk/skeletons/code_generator", project_root) }
|
11
11
|
|
12
|
-
let(:generator_cookbook_path) { File.join(tempdir,
|
13
|
-
let(:generator_copyright_holder) {
|
14
|
-
let(:generator_email) {
|
15
|
-
let(:generator_license) {
|
12
|
+
let(:generator_cookbook_path) { File.join(tempdir, "a_generator_cookbook") }
|
13
|
+
let(:generator_copyright_holder) { "Chef" }
|
14
|
+
let(:generator_email) { "mail@chef.io" }
|
15
|
+
let(:generator_license) { "Free as in Beer" }
|
16
16
|
|
17
17
|
let(:argv) { [generator_arg, "--generator-cookbook", generator_cookbook_path] }
|
18
18
|
|
@@ -76,7 +76,7 @@ shared_examples_for "custom generator cookbook" do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
cookbook_path = File.dirname(generator_cookbook_path)
|
79
|
-
expected_msg = %Q
|
79
|
+
expected_msg = %Q{ERROR: Could not find cookbook(s) to satisfy run list ["recipe[a_generator_cookbook::#{generator_name}]"] in #{cookbook_path}}
|
80
80
|
|
81
81
|
expect(stderr_io.string).to include(expected_msg)
|
82
82
|
end
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
18
|
+
require "chef-dk/helpers"
|
19
19
|
|
20
20
|
RSpec.shared_context "fixture cookbooks checksums" do
|
21
21
|
|
@@ -23,7 +23,7 @@ RSpec.shared_context "fixture cookbooks checksums" do
|
|
23
23
|
major = sha1_id[0...14]
|
24
24
|
minor = sha1_id[14...28]
|
25
25
|
patch = sha1_id[28..40]
|
26
|
-
decimal_integers =[major, minor, patch].map {|hex| hex.to_i(16) }
|
26
|
+
decimal_integers = [major, minor, patch].map { |hex| hex.to_i(16) }
|
27
27
|
decimal_integers.join(".")
|
28
28
|
end
|
29
29
|
|
@@ -44,4 +44,3 @@ RSpec.shared_context "fixture cookbooks checksums" do
|
|
44
44
|
let(:cookbook_dep_of_bar_cksum_dotted) { id_to_dotted(cookbook_dep_of_bar_cksum) }
|
45
45
|
|
46
46
|
end
|
47
|
-
|
@@ -20,7 +20,7 @@ require "mixlib/shellout"
|
|
20
20
|
RSpec.shared_context("setup_git_committer_config") do
|
21
21
|
|
22
22
|
def _have_git_config_key?(key)
|
23
|
-
cmd = Mixlib::ShellOut.new("git config --global #{key}", returns: [0,1])
|
23
|
+
cmd = Mixlib::ShellOut.new("git config --global #{key}", returns: [0, 1])
|
24
24
|
cmd.run_command
|
25
25
|
cmd.error!
|
26
26
|
cmd.status.success?
|
@@ -15,7 +15,7 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
18
|
+
require "chef-dk/helpers"
|
19
19
|
|
20
20
|
RSpec.shared_context "setup git cookbooks" do
|
21
21
|
|
@@ -27,7 +27,7 @@ RSpec.shared_context "setup git cookbooks" do
|
|
27
27
|
|
28
28
|
let(:cookbook_path) { File.join(tempdir, "bar") }
|
29
29
|
|
30
|
-
let(:current_rev) {
|
30
|
+
let(:current_rev) { "dfc68070c47cbf4267be14ea87f80680cb5dafb3" }
|
31
31
|
|
32
32
|
before do
|
33
33
|
reset_tempdir
|
data/spec/spec_helper.rb
CHANGED
@@ -15,13 +15,13 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "rubygems"
|
19
|
+
require "rspec/mocks"
|
20
|
+
require "test_helpers"
|
21
21
|
|
22
22
|
# needed since we stub it for every test
|
23
|
-
require
|
24
|
-
require
|
23
|
+
require "chef/workstation_config_loader"
|
24
|
+
require "chef/config"
|
25
25
|
|
26
26
|
RSpec.configure do |c|
|
27
27
|
running_on_windows = (RUBY_PLATFORM =~ /mswin|mingw|windows/)
|
data/spec/test_helpers.rb
CHANGED
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "stringio"
|
20
|
+
require "chef-dk/chef_runner"
|
21
21
|
|
22
22
|
describe ChefDK::ChefRunner do
|
23
23
|
|
@@ -79,8 +79,8 @@ describe ChefDK::ChefRunner do
|
|
79
79
|
|
80
80
|
it "runs a chef converge" do
|
81
81
|
chef_runner.converge
|
82
|
-
expect(test_state[:loaded_recipes]).to eq(
|
83
|
-
expect(test_state[:converged_recipes]).to eq(
|
82
|
+
expect(test_state[:loaded_recipes]).to eq(%w{recipe_one recipe_two})
|
83
|
+
expect(test_state[:converged_recipes]).to eq(%w{recipe_one recipe_two})
|
84
84
|
end
|
85
85
|
|
86
86
|
context "when policyfile options are set in the workstation config" do
|
@@ -137,5 +137,3 @@ describe ChefDK::ChefRunner do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
end
|
140
|
-
|
141
|
-
|
data/spec/unit/cli_spec.rb
CHANGED
@@ -14,10 +14,10 @@
|
|
14
14
|
# limitations under the License.
|
15
15
|
#
|
16
16
|
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
17
|
+
require "spec_helper"
|
18
|
+
require "stringio"
|
19
|
+
require "chef-dk/cli"
|
20
|
+
require "unit/fixtures/command/cli_test_command"
|
21
21
|
|
22
22
|
describe ChefDK::CLI do
|
23
23
|
|
@@ -70,7 +70,7 @@ E
|
|
70
70
|
def run_cli_and_validate_tool_versions
|
71
71
|
full_version_message = version_message
|
72
72
|
tools.each do |name, version|
|
73
|
-
expect(cli).to receive(:shell_out).with("#{name} --version").and_return(mock_shell_out(0, "#{version["version_output"]}",
|
73
|
+
expect(cli).to receive(:shell_out).with("#{name} --version").and_return(mock_shell_out(0, "#{version["version_output"]}", ""))
|
74
74
|
full_version_message += "#{name} version: #{version["expected_version"]}\n"
|
75
75
|
end
|
76
76
|
run_cli(0)
|
@@ -97,10 +97,10 @@ E
|
|
97
97
|
commands_map.builtin "verify", :Verify, desc: "Test the embedded ChefDK applications"
|
98
98
|
|
99
99
|
commands_map.builtin "gem", :GemForwarder, require_path: "chef-dk/command/gem",
|
100
|
-
|
100
|
+
desc: "Runs the `gem` command in context of the embedded ruby"
|
101
101
|
|
102
102
|
commands_map.builtin "example", :TestCommand, require_path: "unit/fixtures/command/cli_test_command",
|
103
|
-
|
103
|
+
desc: "Example subcommand for testing"
|
104
104
|
end
|
105
105
|
|
106
106
|
context "given no arguments or options" do
|
@@ -113,7 +113,7 @@ E
|
|
113
113
|
end
|
114
114
|
|
115
115
|
context "given -h" do
|
116
|
-
let(:argv) { %w
|
116
|
+
let(:argv) { %w{-h} }
|
117
117
|
|
118
118
|
it "prints the help output" do
|
119
119
|
run_cli(0)
|
@@ -122,27 +122,27 @@ E
|
|
122
122
|
end
|
123
123
|
|
124
124
|
context "given -v" do
|
125
|
-
let(:argv) { %w
|
125
|
+
let(:argv) { %w{-v} }
|
126
126
|
let(:delivery_version) { "master (454c3f37819ed508a49c971f38e42267ce8a47de)" }
|
127
127
|
|
128
128
|
let(:tools) {
|
129
129
|
{
|
130
130
|
"chef-client" => {
|
131
131
|
"version_output" => "Chef: 12.0.3",
|
132
|
-
"expected_version" => "12.0.3"
|
132
|
+
"expected_version" => "12.0.3",
|
133
133
|
},
|
134
134
|
"delivery" => {
|
135
135
|
"version_output" => "delivery #{delivery_version}",
|
136
|
-
"expected_version" => delivery_version
|
136
|
+
"expected_version" => delivery_version,
|
137
137
|
},
|
138
138
|
"berks" => {
|
139
139
|
"version_output" => "3.2.3",
|
140
|
-
"expected_version" => "3.2.3"
|
140
|
+
"expected_version" => "3.2.3",
|
141
141
|
},
|
142
142
|
"kitchen" => {
|
143
143
|
"version_output" => "Test Kitchen version 1.3.1",
|
144
|
-
"expected_version" => "1.3.1"
|
145
|
-
}
|
144
|
+
"expected_version" => "1.3.1",
|
145
|
+
},
|
146
146
|
}
|
147
147
|
}
|
148
148
|
|
@@ -150,10 +150,10 @@ E
|
|
150
150
|
full_version_message = version_message
|
151
151
|
tools.each do |name, version|
|
152
152
|
if name == "berks"
|
153
|
-
expect(cli).to receive(:shell_out).with("#{name} --version").and_return(mock_shell_out(1, "#{version["version_output"]}",
|
153
|
+
expect(cli).to receive(:shell_out).with("#{name} --version").and_return(mock_shell_out(1, "#{version["version_output"]}", ""))
|
154
154
|
full_version_message += "#{name} version: ERROR\n"
|
155
155
|
else
|
156
|
-
expect(cli).to receive(:shell_out).with("#{name} --version").and_return(mock_shell_out(0, "#{version["version_output"]}",
|
156
|
+
expect(cli).to receive(:shell_out).with("#{name} --version").and_return(mock_shell_out(0, "#{version["version_output"]}", ""))
|
157
157
|
full_version_message += "#{name} version: #{version["expected_version"]}\n"
|
158
158
|
end
|
159
159
|
end
|
@@ -174,10 +174,9 @@ E
|
|
174
174
|
end
|
175
175
|
end
|
176
176
|
|
177
|
-
|
178
177
|
context "given an invalid option" do
|
179
178
|
|
180
|
-
let(:argv) { %w
|
179
|
+
let(:argv) { %w{-nope} }
|
181
180
|
|
182
181
|
it "prints an 'invalid option message and the help output, then exits non-zero" do
|
183
182
|
run_cli(1)
|
@@ -188,7 +187,7 @@ E
|
|
188
187
|
end
|
189
188
|
|
190
189
|
context "given an invalid/unknown subcommand" do
|
191
|
-
let(:argv) { %w
|
190
|
+
let(:argv) { %w{ancient-aliens} }
|
192
191
|
|
193
192
|
it "prints an 'unknown command' message and the help output" do
|
194
193
|
expected_err = "Unknown command `ancient-aliens'.\n"
|
@@ -202,7 +201,7 @@ E
|
|
202
201
|
end
|
203
202
|
|
204
203
|
context "given a valid subcommand" do
|
205
|
-
let(:argv) { %w
|
204
|
+
let(:argv) { %w{example with some args --and-an-option} }
|
206
205
|
|
207
206
|
def test_result
|
208
207
|
ChefDK::Command::TestCommand.test_result
|
@@ -222,7 +221,7 @@ E
|
|
222
221
|
end
|
223
222
|
|
224
223
|
it "passes arguments and options to the subcommand" do
|
225
|
-
params = %w
|
224
|
+
params = %w{with some args --and-an-option}
|
226
225
|
run_cli(23)
|
227
226
|
expect(test_result[:params]).to eq(params)
|
228
227
|
end
|
@@ -240,18 +239,18 @@ E
|
|
240
239
|
|
241
240
|
context "on unix" do
|
242
241
|
|
243
|
-
let(:ruby_path) {
|
244
|
-
let(:chefdk_embedded_path) {
|
242
|
+
let(:ruby_path) { "/opt/chefdk/embedded/bin/ruby" }
|
243
|
+
let(:chefdk_embedded_path) { "/opt/chefdk/embedded/apps/chef-dk" }
|
245
244
|
|
246
245
|
before do
|
247
|
-
stub_const("File::PATH_SEPARATOR",
|
246
|
+
stub_const("File::PATH_SEPARATOR", ":")
|
248
247
|
allow(Chef::Util::PathHelper).to receive(:cleanpath) do |path|
|
249
248
|
path
|
250
249
|
end
|
251
250
|
end
|
252
251
|
|
253
252
|
it "complains if embedded is first" do
|
254
|
-
allow(cli).to receive(:env).and_return({
|
253
|
+
allow(cli).to receive(:env).and_return({ "PATH" => "/opt/chefdk/embedded/bin:/opt/chefdk/bin" })
|
255
254
|
allow(cli).to receive(:omnibus_embedded_bin_dir).and_return("/opt/chefdk/embedded/bin")
|
256
255
|
allow(cli).to receive(:omnibus_bin_dir).and_return("/opt/chefdk/bin")
|
257
256
|
run_cli_with_sanity_check(0)
|
@@ -261,7 +260,7 @@ E
|
|
261
260
|
end
|
262
261
|
|
263
262
|
it "complains if only embedded is present" do
|
264
|
-
allow(cli).to receive(:env).and_return({
|
263
|
+
allow(cli).to receive(:env).and_return({ "PATH" => "/opt/chefdk/embedded/bin" })
|
265
264
|
allow(cli).to receive(:omnibus_embedded_bin_dir).and_return("/opt/chefdk/embedded/bin")
|
266
265
|
allow(cli).to receive(:omnibus_bin_dir).and_return("/opt/chefdk/bin")
|
267
266
|
run_cli_with_sanity_check(0)
|
@@ -271,7 +270,7 @@ E
|
|
271
270
|
end
|
272
271
|
|
273
272
|
it "passes when both are present in the correct order" do
|
274
|
-
allow(cli).to receive(:env).and_return({
|
273
|
+
allow(cli).to receive(:env).and_return({ "PATH" => "/opt/chefdk/bin:/opt/chefdk/embedded/bin" })
|
275
274
|
allow(cli).to receive(:omnibus_embedded_bin_dir).and_return("/opt/chefdk/embedded/bin")
|
276
275
|
allow(cli).to receive(:omnibus_bin_dir).and_return("/opt/chefdk/bin")
|
277
276
|
run_cli_with_sanity_check(0)
|
@@ -279,7 +278,7 @@ E
|
|
279
278
|
end
|
280
279
|
|
281
280
|
it "passes when only the omnibus bin dir is present" do
|
282
|
-
allow(cli).to receive(:env).and_return({
|
281
|
+
allow(cli).to receive(:env).and_return({ "PATH" => "/opt/chefdk/bin" })
|
283
282
|
allow(cli).to receive(:omnibus_embedded_bin_dir).and_return("/opt/chefdk/embedded/bin")
|
284
283
|
allow(cli).to receive(:omnibus_bin_dir).and_return("/opt/chefdk/bin")
|
285
284
|
run_cli_with_sanity_check(0)
|
@@ -303,14 +302,14 @@ E
|
|
303
302
|
allow(cli).to receive(:omnibus_chefdk_location).and_return(chefdk_embedded_path)
|
304
303
|
|
305
304
|
allow(Chef::Platform).to receive(:windows?).and_return(true)
|
306
|
-
stub_const("File::PATH_SEPARATOR",
|
305
|
+
stub_const("File::PATH_SEPARATOR", ";")
|
307
306
|
allow(Chef::Util::PathHelper).to receive(:cleanpath) do |path|
|
308
|
-
path.
|
307
|
+
path.tr "/", "\\"
|
309
308
|
end
|
310
309
|
end
|
311
310
|
|
312
311
|
it "complains if embedded is first" do
|
313
|
-
allow(cli).to receive(:env).and_return({
|
312
|
+
allow(cli).to receive(:env).and_return({ "PATH" => 'C:\opscode\chefdk\embedded\bin;C:\opscode\chefdk\bin' })
|
314
313
|
allow(cli).to receive(:omnibus_embedded_bin_dir).and_return("c:/opscode/chefdk/embedded/bin")
|
315
314
|
allow(cli).to receive(:omnibus_bin_dir).and_return("c:/opscode/chefdk/bin")
|
316
315
|
run_cli_with_sanity_check(0)
|
@@ -320,7 +319,7 @@ E
|
|
320
319
|
end
|
321
320
|
|
322
321
|
it "complains if only embedded is present" do
|
323
|
-
allow(cli).to receive(:env).and_return({
|
322
|
+
allow(cli).to receive(:env).and_return({ "PATH" => 'C:\opscode\chefdk\embedded\bin' })
|
324
323
|
allow(cli).to receive(:omnibus_embedded_bin_dir).and_return("c:/opscode/chefdk/embedded/bin")
|
325
324
|
allow(cli).to receive(:omnibus_bin_dir).and_return("c:/opscode/chefdk/bin")
|
326
325
|
run_cli_with_sanity_check(0)
|
@@ -330,7 +329,7 @@ E
|
|
330
329
|
end
|
331
330
|
|
332
331
|
it "passes when both are present in the correct order" do
|
333
|
-
allow(cli).to receive(:env).and_return({
|
332
|
+
allow(cli).to receive(:env).and_return({ "PATH" => 'C:\opscode\chefdk\bin;C:\opscode\chefdk\embedded\bin' })
|
334
333
|
allow(cli).to receive(:omnibus_embedded_bin_dir).and_return("c:/opscode/chefdk/embedded/bin")
|
335
334
|
allow(cli).to receive(:omnibus_bin_dir).and_return("c:/opscode/chefdk/bin")
|
336
335
|
run_cli_with_sanity_check(0)
|
@@ -338,7 +337,7 @@ E
|
|
338
337
|
end
|
339
338
|
|
340
339
|
it "passes when only the omnibus bin dir is present" do
|
341
|
-
allow(cli).to receive(:env).and_return({
|
340
|
+
allow(cli).to receive(:env).and_return({ "PATH" => 'C:\opscode\chefdk\bin' })
|
342
341
|
allow(cli).to receive(:omnibus_embedded_bin_dir).and_return("c:/opscode/chefdk/embedded/bin")
|
343
342
|
allow(cli).to receive(:omnibus_bin_dir).and_return("c:/opscode/chefdk/bin")
|
344
343
|
run_cli_with_sanity_check(0)
|
@@ -349,8 +348,8 @@ E
|
|
349
348
|
|
350
349
|
context "when not installed via omnibus" do
|
351
350
|
|
352
|
-
let(:ruby_path) {
|
353
|
-
let(:chefdk_embedded_path) {
|
351
|
+
let(:ruby_path) { "/Users/bog/.lots_o_rubies/2.1.2/bin/ruby" }
|
352
|
+
let(:chefdk_embedded_path) { "/Users/bog/.lots_o_rubies/embedded/apps/chef-dk" }
|
354
353
|
|
355
354
|
before do
|
356
355
|
allow(File).to receive(:exist?).with(chefdk_embedded_path).and_return(false)
|
@@ -359,7 +358,7 @@ E
|
|
359
358
|
:omnibus_root,
|
360
359
|
:omnibus_apps_dir,
|
361
360
|
:omnibus_bin_dir,
|
362
|
-
:omnibus_embedded_bin_dir
|
361
|
+
:omnibus_embedded_bin_dir,
|
363
362
|
].each do |method_name|
|
364
363
|
allow(cli).to receive(method_name).and_raise(ChefDK::OmnibusInstallNotFound.new)
|
365
364
|
end
|
@@ -15,8 +15,8 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "chef-dk/command/verify"
|
20
20
|
|
21
21
|
describe ChefDK::Command::Base do
|
22
22
|
class TestCommand < ChefDK::Command::Base
|
@@ -56,7 +56,6 @@ describe ChefDK::Command::Base do
|
|
56
56
|
allow(command_instance).to receive(:stderr).and_return(stderr_io)
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
59
|
def run_command(options)
|
61
60
|
command_instance.run_with_default_options(options)
|
62
61
|
end
|
@@ -99,7 +98,7 @@ describe ChefDK::Command::Base do
|
|
99
98
|
describe "when given invalid options" do
|
100
99
|
|
101
100
|
it "prints the help banner and exits gracefully" do
|
102
|
-
expect(run_command(%w
|
101
|
+
expect(run_command(%w{-foo})).to eq(1)
|
103
102
|
|
104
103
|
expect(stderr).to eq("ERROR: invalid option: -foo\n\n")
|
105
104
|
|
@@ -119,7 +118,7 @@ E
|
|
119
118
|
describe "when given an option that requires an argument with no argument" do
|
120
119
|
|
121
120
|
it "prints the help banner and exits gracefully" do
|
122
|
-
expect(run_command(%w
|
121
|
+
expect(run_command(%w{-a})).to eq(1)
|
123
122
|
|
124
123
|
expect(stderr).to eq("ERROR: missing argument: -a\n\n")
|
125
124
|
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "spec_helper"
|
19
|
+
require "shared/command_with_ui_object"
|
20
|
+
require "chef-dk/command/clean_policy_cookbooks"
|
21
21
|
|
22
22
|
describe ChefDK::Command::CleanPolicyCookbooks do
|
23
23
|
|
@@ -50,7 +50,7 @@ describe ChefDK::Command::CleanPolicyCookbooks do
|
|
50
50
|
|
51
51
|
context "when given a path to the config" do
|
52
52
|
|
53
|
-
let(:params) { %w
|
53
|
+
let(:params) { %w{ -c ~/otherstuff/config.rb } }
|
54
54
|
|
55
55
|
let(:config_arg) { "~/otherstuff/config.rb" }
|
56
56
|
|
@@ -105,7 +105,7 @@ describe ChefDK::Command::CleanPolicyCookbooks do
|
|
105
105
|
|
106
106
|
context "when given too many arguments" do
|
107
107
|
|
108
|
-
let(:params) { %w
|
108
|
+
let(:params) { %w{ wut-is-this } }
|
109
109
|
|
110
110
|
it "shows usage and exits" do
|
111
111
|
expect(command.run(params)).to eq(1)
|
@@ -134,7 +134,7 @@ describe ChefDK::Command::CleanPolicyCookbooks do
|
|
134
134
|
it "prints a debugging message and exits non-zero" do
|
135
135
|
expect(command.run([])).to eq(1)
|
136
136
|
|
137
|
-
expected_output
|
137
|
+
expected_output = <<-E
|
138
138
|
Error: Failed to delete some policy revisions.
|
139
139
|
Reason: (StandardError) some operation failed
|
140
140
|
|
@@ -147,9 +147,9 @@ E
|
|
147
147
|
|
148
148
|
it "includes the backtrace in the error" do
|
149
149
|
|
150
|
-
command.run(%w
|
150
|
+
command.run(%w{ -D })
|
151
151
|
|
152
|
-
expected_output
|
152
|
+
expected_output = <<-E
|
153
153
|
Error: Failed to delete some policy revisions.
|
154
154
|
Reason: (StandardError) some operation failed
|
155
155
|
|
@@ -178,4 +178,3 @@ E
|
|
178
178
|
|
179
179
|
end
|
180
180
|
end
|
181
|
-
|