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
@@ -15,10 +15,10 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
18
|
+
require "chef-dk/command/base"
|
19
|
+
require "chef-dk/ui"
|
20
|
+
require "chef-dk/policyfile_services/push_archive"
|
21
|
+
require "chef-dk/configurable"
|
22
22
|
|
23
23
|
module ChefDK
|
24
24
|
module Command
|
@@ -123,4 +123,3 @@ E
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
end
|
126
|
-
|
@@ -15,12 +15,12 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
18
|
+
require "erb"
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
20
|
+
require "chef-dk/commands_map"
|
21
|
+
require "chef-dk/builtin_commands"
|
22
|
+
require "chef-dk/command/base"
|
23
|
+
require "mixlib/shellout"
|
24
24
|
|
25
25
|
module ChefDK
|
26
26
|
|
@@ -41,7 +41,7 @@ module ChefDK
|
|
41
41
|
module Command
|
42
42
|
class ShellInit < ChefDK::Command::Base
|
43
43
|
|
44
|
-
SUPPORTED_SHELLS = %w
|
44
|
+
SUPPORTED_SHELLS = %w{ bash fish zsh sh powershell posh}.map(&:freeze).freeze
|
45
45
|
|
46
46
|
banner(<<-HELP)
|
47
47
|
Usage: chef shell-init
|
@@ -117,7 +117,7 @@ HELP
|
|
117
117
|
def completion_for(shell)
|
118
118
|
return "" unless (completion_template_basename = completion_template_for(shell))
|
119
119
|
completion_template_path = expand_completion_template_path(completion_template_basename)
|
120
|
-
erb = ERB.new(File.read(completion_template_path), nil,
|
120
|
+
erb = ERB.new(File.read(completion_template_path), nil, "-")
|
121
121
|
context_binding = shell_completion_template_context.get_binding
|
122
122
|
erb.result(context_binding)
|
123
123
|
end
|
@@ -134,7 +134,6 @@ HELP
|
|
134
134
|
# Pull requests accepted!
|
135
135
|
nil
|
136
136
|
end
|
137
|
-
|
138
137
|
end
|
139
138
|
|
140
139
|
def expand_completion_template_path(basename)
|
@@ -147,17 +146,17 @@ HELP
|
|
147
146
|
|
148
147
|
def export(shell, var, val)
|
149
148
|
case shell
|
150
|
-
when
|
149
|
+
when "sh", "bash", "zsh"
|
151
150
|
posix_shell_export(var, val)
|
152
|
-
when
|
151
|
+
when "fish"
|
153
152
|
fish_shell_export(var, val)
|
154
|
-
when
|
153
|
+
when "powershell", "posh"
|
155
154
|
powershell_export(var, val)
|
156
155
|
end
|
157
156
|
end
|
158
157
|
|
159
158
|
def posix_shell_export(var, val)
|
160
|
-
emit_shell_cmd(%Q
|
159
|
+
emit_shell_cmd(%Q{export #{var}="#{val}"})
|
161
160
|
end
|
162
161
|
|
163
162
|
def fish_shell_export(var, val)
|
@@ -165,15 +164,15 @@ HELP
|
|
165
164
|
# divided by spaces (instead of colons). We also send STDERR to
|
166
165
|
# /dev/null to avoid Fish's helpful warnings about nonexistent
|
167
166
|
# PATH elements.
|
168
|
-
if var ==
|
169
|
-
emit_shell_cmd(%Q
|
167
|
+
if var == "PATH"
|
168
|
+
emit_shell_cmd(%Q{set -gx #{var} "#{val.split(':').join('" "')}" 2>/dev/null;})
|
170
169
|
else
|
171
|
-
emit_shell_cmd(%Q
|
170
|
+
emit_shell_cmd(%Q{set -gx #{var} "#{val}";})
|
172
171
|
end
|
173
172
|
end
|
174
173
|
|
175
174
|
def powershell_export(var, val)
|
176
|
-
emit_shell_cmd(%Q
|
175
|
+
emit_shell_cmd(%Q{$env:#{var}="#{val}"})
|
177
176
|
end
|
178
177
|
end
|
179
178
|
end
|
@@ -15,16 +15,15 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
18
|
+
require "chef-dk/command/base"
|
19
|
+
require "chef-dk/ui"
|
20
|
+
require "chef-dk/configurable"
|
21
|
+
require "chef-dk/policyfile/lister"
|
22
|
+
require "chef-dk/policyfile_services/show_policy"
|
23
23
|
|
24
24
|
module ChefDK
|
25
25
|
module Command
|
26
26
|
|
27
|
-
|
28
27
|
class ShowPolicy < Base
|
29
28
|
|
30
29
|
banner(<<-BANNER)
|
@@ -162,4 +161,3 @@ BANNER
|
|
162
161
|
end
|
163
162
|
end
|
164
163
|
end
|
165
|
-
|
@@ -15,10 +15,10 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
18
|
+
require "chef-dk/command/base"
|
19
|
+
require "chef-dk/ui"
|
20
|
+
require "chef-dk/configurable"
|
21
|
+
require "chef-dk/policyfile_services/undelete"
|
22
22
|
|
23
23
|
module ChefDK
|
24
24
|
module Command
|
@@ -102,8 +102,8 @@ BANNER
|
|
102
102
|
def undelete_service
|
103
103
|
@undelete_service ||=
|
104
104
|
PolicyfileServices::Undelete.new(config: chef_config,
|
105
|
-
|
106
|
-
|
105
|
+
ui: ui,
|
106
|
+
undo_record_id: undo_record_id)
|
107
107
|
end
|
108
108
|
|
109
109
|
def debug?
|
@@ -152,4 +152,3 @@ BANNER
|
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
155
|
-
|
@@ -15,11 +15,11 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
18
|
+
require "chef-dk/command/base"
|
19
|
+
require "chef-dk/ui"
|
20
|
+
require "chef-dk/policyfile_services/install"
|
21
|
+
require "chef-dk/policyfile_services/update_attributes"
|
22
|
+
require "chef-dk/configurable"
|
23
23
|
|
24
24
|
module ChefDK
|
25
25
|
module Command
|
@@ -145,4 +145,3 @@ BANNER
|
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
|
-
|
@@ -15,9 +15,9 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
18
|
+
require "chef-dk/command/base"
|
19
|
+
require "chef-dk/exceptions"
|
20
|
+
require "chef-dk/component_test"
|
21
21
|
|
22
22
|
module ChefDK
|
23
23
|
module Command
|
@@ -44,7 +44,7 @@ module ChefDK
|
|
44
44
|
:description => "Display all test output, not just failing tests"
|
45
45
|
|
46
46
|
class << self
|
47
|
-
def add_component(name, _delete_me=nil)
|
47
|
+
def add_component(name, _delete_me = nil)
|
48
48
|
component = ComponentTest.new(name)
|
49
49
|
yield component if block_given? #delete this conditional
|
50
50
|
component_map[name] = component
|
@@ -92,7 +92,7 @@ module ChefDK
|
|
92
92
|
|
93
93
|
c.smoke_test do
|
94
94
|
tmpdir do |cwd|
|
95
|
-
FileUtils.touch(File.join(cwd,"Berksfile"))
|
95
|
+
FileUtils.touch(File.join(cwd, "Berksfile"))
|
96
96
|
sh("#{bin("berks")} install", cwd: cwd)
|
97
97
|
end
|
98
98
|
end
|
@@ -215,7 +215,7 @@ KITCHEN_YML
|
|
215
215
|
def format_gem_failure(name, versions)
|
216
216
|
<<-EOS
|
217
217
|
#{name} has multiple versions installed:
|
218
|
-
#{versions.sort.map { |gv| " #{gv
|
218
|
+
#{versions.sort.map { |gv| " #{gv}" }.join("\n")}
|
219
219
|
EOS
|
220
220
|
end
|
221
221
|
|
@@ -237,7 +237,7 @@ EOS
|
|
237
237
|
# ------------
|
238
238
|
# load the core gem and all of the drivers (ignoring versions).
|
239
239
|
require "chef/provisioning"
|
240
|
-
drivers.map { |d| "#{d.
|
240
|
+
drivers.map { |d| "#{d.tr('-', '/')}_driver" }.each do |driver_gem|
|
241
241
|
begin
|
242
242
|
begin
|
243
243
|
require driver_gem
|
@@ -258,18 +258,18 @@ EOS
|
|
258
258
|
|
259
259
|
# write out the gemfile for this chef-provisioning version, and see if Bundler can make it go.
|
260
260
|
with_file(File.join(cwd, gemfile)) do |f|
|
261
|
-
f.puts %Q
|
262
|
-
drivers.each { |d| f.puts %Q
|
261
|
+
f.puts %Q{gem "chef-provisioning", "= #{provisioning_version}"}
|
262
|
+
drivers.each { |d| f.puts %Q{gem "#{d}"} }
|
263
263
|
end
|
264
264
|
|
265
265
|
result = bundle_install_mutex.synchronize do
|
266
|
-
sh("#{embedded_bin("bundle")} install --local --quiet", cwd: cwd, env: {"BUNDLE_GEMFILE" => gemfile })
|
266
|
+
sh("#{embedded_bin("bundle")} install --local --quiet", cwd: cwd, env: { "BUNDLE_GEMFILE" => gemfile })
|
267
267
|
end
|
268
268
|
|
269
269
|
if result.exitstatus != 0
|
270
270
|
failures << result.stdout
|
271
271
|
end
|
272
|
-
end
|
272
|
+
end # end provisioning versions.
|
273
273
|
|
274
274
|
failures.each { |fail| puts fail }
|
275
275
|
|
@@ -281,7 +281,6 @@ EOS
|
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
284
|
-
|
285
284
|
add_component "chefspec" do |c|
|
286
285
|
c.gem_base_dir = "chefspec"
|
287
286
|
c.unit_test do
|
@@ -329,7 +328,7 @@ require 'spec_helper'
|
|
329
328
|
c.gem_base_dir = "rubocop"
|
330
329
|
c.smoke_test do
|
331
330
|
tmpdir do |cwd|
|
332
|
-
with_file(File.join(cwd,
|
331
|
+
with_file(File.join(cwd, "foo.rb")) do |f|
|
333
332
|
f.write <<-EOF
|
334
333
|
def foo
|
335
334
|
puts 'foo'
|
@@ -348,7 +347,7 @@ end
|
|
348
347
|
|
349
348
|
add_component "knife-spork" do |c|
|
350
349
|
c.gem_base_dir = "knife-spork"
|
351
|
-
c.smoke_test { sh("#{bin("knife")} spork info")}
|
350
|
+
c.smoke_test { sh("#{bin("knife")} spork info") }
|
352
351
|
end
|
353
352
|
|
354
353
|
add_component "kitchen-vagrant" do |c|
|
@@ -468,34 +467,34 @@ end
|
|
468
467
|
add_component "git" do |c|
|
469
468
|
c.base_dir = "embedded/bin"
|
470
469
|
c.smoke_test do
|
471
|
-
|
470
|
+
tmpdir do |cwd|
|
472
471
|
sh!("#{embedded_bin("git")} config -l")
|
473
|
-
|
474
|
-
|
472
|
+
sh!("#{embedded_bin("git")} clone https://github.com/chef/chef-provisioning", cwd: cwd)
|
473
|
+
end
|
475
474
|
end
|
476
475
|
end
|
477
476
|
else
|
478
477
|
add_component "git" do |c|
|
479
478
|
c.base_dir = "gitbin"
|
480
479
|
c.smoke_test do
|
481
|
-
|
480
|
+
tmpdir do |cwd|
|
482
481
|
sh!("#{File.join(omnibus_root, "gitbin", "git")} config -l")
|
483
|
-
|
482
|
+
sh!("#{File.join(omnibus_root, "gitbin", "git")} clone https://github.com/chef/chef-provisioning", cwd: cwd)
|
484
483
|
|
485
|
-
|
486
|
-
|
487
|
-
|
484
|
+
# If /usr/bin/git is a symlink, fail the test.
|
485
|
+
# Note that this test cannot go last because it does not return a
|
486
|
+
# Mixlib::Shellout object in the windows case, which will break the tests.
|
488
487
|
failure_str = "#{nix_platform_native_bin_dir}/git contains a symlink which might mean we accidentally overwrote system git via chefdk."
|
489
488
|
result = sh("readlink #{nix_platform_native_bin_dir}/git")
|
490
489
|
# if a symlink was found, test to see if it is in a chefdk install
|
491
490
|
if result.status.exitstatus == 0
|
492
|
-
|
491
|
+
raise failure_str if result.stdout =~ /chefdk/
|
493
492
|
end
|
494
493
|
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
494
|
+
# <chef_dk>/bin/ should not contain a git binary.
|
495
|
+
failure_str = "`<chef_dk>/bin/git --help` should fail as git should be installed in gitbin"
|
496
|
+
fail_if_exit_zero("#{bin("git")} --help", failure_str)
|
497
|
+
end
|
499
498
|
end
|
500
499
|
end
|
501
500
|
end
|
@@ -520,7 +519,7 @@ end
|
|
520
519
|
c.gem_base_dir = "chef-sugar"
|
521
520
|
c.smoke_test do
|
522
521
|
tmpdir do |cwd|
|
523
|
-
with_file(File.join(cwd,
|
522
|
+
with_file(File.join(cwd, "foo.rb")) do |f|
|
524
523
|
f.write <<-EOF
|
525
524
|
require 'chef/sugar'
|
526
525
|
log 'something' do
|
@@ -593,7 +592,7 @@ end
|
|
593
592
|
results << component.run_integration_test
|
594
593
|
end
|
595
594
|
|
596
|
-
if results.any? {|r| r.exitstatus != 0 }
|
595
|
+
if results.any? { |r| r.exitstatus != 0 }
|
597
596
|
component_status = 1
|
598
597
|
@verification_status = 1
|
599
598
|
else
|
@@ -603,7 +602,7 @@ end
|
|
603
602
|
{
|
604
603
|
:component => component,
|
605
604
|
:results => results,
|
606
|
-
:component_status => component_status
|
605
|
+
:component_status => component_status,
|
607
606
|
}
|
608
607
|
end
|
609
608
|
|
@@ -612,7 +611,7 @@ end
|
|
612
611
|
end
|
613
612
|
|
614
613
|
def wait_for_tests
|
615
|
-
|
614
|
+
until verification_threads.empty?
|
616
615
|
verification_threads.each do |t|
|
617
616
|
if t.join(1)
|
618
617
|
verification_threads.delete t
|
data/lib/chef-dk/commands_map.rb
CHANGED
@@ -74,7 +74,7 @@ module ChefDK
|
|
74
74
|
|
75
75
|
def builtin(name, constant_name, require_path: NULL_ARG, desc: "")
|
76
76
|
if null?(require_path)
|
77
|
-
snake_case_path = name.
|
77
|
+
snake_case_path = name.tr("-", "_")
|
78
78
|
require_path = "chef-dk/command/#{snake_case_path}"
|
79
79
|
end
|
80
80
|
command_specs[name] = CommandSpec.new(name, constant_name, require_path, desc)
|
@@ -111,5 +111,3 @@ module ChefDK
|
|
111
111
|
yield commands_map
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|
115
|
-
|
@@ -15,8 +15,8 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
require
|
19
|
-
require
|
18
|
+
require "chef-dk/exceptions"
|
19
|
+
require "chef-dk/helpers"
|
20
20
|
|
21
21
|
# https://github.com/bundler/bundler/issues/4368
|
22
22
|
# As of rubygems 2.6.2, Rubygems will call Bundler::SpecSet#size, which does
|
@@ -107,7 +107,7 @@ module ChefDK
|
|
107
107
|
File.join(omnibus_embedded_bin_dir, binary)
|
108
108
|
end
|
109
109
|
|
110
|
-
def sh(command, options={})
|
110
|
+
def sh(command, options = {})
|
111
111
|
combined_opts = default_command_options.merge(options)
|
112
112
|
|
113
113
|
# Env is a hash, so it needs to be merged separately
|
@@ -132,15 +132,15 @@ module ChefDK
|
|
132
132
|
# otherwise, if it returns non-zero or doesn't exist,
|
133
133
|
# return a passing command so that the test parser doesn't
|
134
134
|
# crash.
|
135
|
-
def fail_if_exit_zero(cmd_string, failure_string=
|
135
|
+
def fail_if_exit_zero(cmd_string, failure_string = "")
|
136
136
|
result = sh(cmd_string)
|
137
137
|
if result.status.exitstatus == 0
|
138
|
-
|
138
|
+
raise failure_string
|
139
139
|
else
|
140
|
-
|
140
|
+
sh("true")
|
141
141
|
end
|
142
142
|
rescue Errno::ENOENT
|
143
|
-
sh(
|
143
|
+
sh("true")
|
144
144
|
end
|
145
145
|
|
146
146
|
def nix_platform_native_bin_dir
|
@@ -153,7 +153,7 @@ module ChefDK
|
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
def run_in_tmpdir(command, options={})
|
156
|
+
def run_in_tmpdir(command, options = {})
|
157
157
|
tmpdir do |dir|
|
158
158
|
options[:cwd] = dir
|
159
159
|
sh(command, options)
|
@@ -180,9 +180,9 @@ module ChefDK
|
|
180
180
|
:env => {
|
181
181
|
# Add the embedded/bin to the PATH so that bundle executable can
|
182
182
|
# be found while running the tests.
|
183
|
-
path_variable_key => omnibus_path
|
183
|
+
path_variable_key => omnibus_path,
|
184
184
|
},
|
185
|
-
:timeout => 3600
|
185
|
+
:timeout => 3600,
|
186
186
|
}
|
187
187
|
end
|
188
188
|
|
@@ -203,7 +203,7 @@ module ChefDK
|
|
203
203
|
# is a prerelease version. ">= 0.a" is how we ask for a prerelease version, because a
|
204
204
|
# prerelease version is defined as "any version with a letter in it."
|
205
205
|
gem = Gem::Specification.find_by_name(@gem_name_for_base_dir)
|
206
|
-
gem ||= Gem::Specification.find_by_name(@gem_name_for_base_dir,
|
206
|
+
gem ||= Gem::Specification.find_by_name(@gem_name_for_base_dir, ">= 0.a")
|
207
207
|
gem.gem_dir
|
208
208
|
end
|
209
209
|
|
@@ -212,11 +212,11 @@ module ChefDK
|
|
212
212
|
end
|
213
213
|
|
214
214
|
def omnibus_root
|
215
|
-
@omnibus_root
|
215
|
+
@omnibus_root || raise("`omnibus_root` must be set before running tests")
|
216
216
|
end
|
217
217
|
|
218
218
|
def omnibus_path
|
219
|
-
[omnibus_bin_dir, omnibus_embedded_bin_dir, ENV[
|
219
|
+
[omnibus_bin_dir, omnibus_embedded_bin_dir, ENV["PATH"]].join(File::PATH_SEPARATOR)
|
220
220
|
end
|
221
221
|
|
222
222
|
def path_variable_key
|