chef-dk 0.15.16 → 0.16.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -26
- data/Gemfile +10 -4
- data/Gemfile.lock +73 -64
- data/LICENSE +201 -201
- data/README.md +2 -1
- data/acceptance/.shared/kitchen_acceptance/.kitchen.digitalocean.yml +27 -27
- data/acceptance/.shared/kitchen_acceptance/.kitchen.ec2.yml +288 -288
- data/acceptance/.shared/kitchen_acceptance/.kitchen.vagrant.yml +52 -52
- data/acceptance/.shared/kitchen_acceptance/libraries/kitchen.rb +51 -51
- data/acceptance/.shared/kitchen_acceptance/metadata.rb +1 -1
- data/acceptance/Gemfile +3 -0
- data/acceptance/Gemfile.lock +24 -24
- data/acceptance/README.md +132 -132
- data/acceptance/trivial/.acceptance/acceptance-cookbook/.gitignore +2 -2
- data/acceptance/trivial/.acceptance/acceptance-cookbook/metadata.rb +2 -2
- data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/destroy.rb +1 -1
- data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/provision.rb +1 -1
- data/acceptance/trivial/.acceptance/acceptance-cookbook/recipes/verify.rb +1 -1
- data/acceptance/trivial/.kitchen.yml +7 -7
- data/acceptance/trivial/test/integration/chefdk-current-install/inspec/chef_client_spec.rb +5 -5
- data/bin/chef +25 -25
- data/chef-dk.gemspec +1 -1
- data/lib/chef-dk.rb +19 -19
- data/lib/chef-dk/authenticated_http.rb +40 -40
- data/lib/chef-dk/chef_runner.rb +12 -4
- data/lib/chef-dk/command/base.rb +79 -79
- data/lib/chef-dk/command/clean_policy_cookbooks.rb +116 -116
- data/lib/chef-dk/command/clean_policy_revisions.rb +113 -113
- data/lib/chef-dk/command/delete_policy.rb +122 -122
- data/lib/chef-dk/command/delete_policy_group.rb +122 -122
- data/lib/chef-dk/command/diff.rb +316 -316
- data/lib/chef-dk/command/env.rb +90 -90
- data/lib/chef-dk/command/exec.rb +45 -45
- data/lib/chef-dk/command/gem.rb +47 -47
- data/lib/chef-dk/command/generator_commands/app.rb +107 -107
- data/lib/chef-dk/command/generator_commands/attribute.rb +37 -37
- data/lib/chef-dk/command/generator_commands/base.rb +3 -0
- data/lib/chef-dk/command/generator_commands/build_cookbook.rb +4 -4
- data/lib/chef-dk/command/generator_commands/chef_exts/generator_desc_resource.rb +85 -0
- data/lib/chef-dk/command/generator_commands/chef_exts/quieter_doc_formatter.rb +39 -0
- data/lib/chef-dk/command/generator_commands/chef_exts/recipe_dsl_ext.rb +40 -0
- data/lib/chef-dk/command/generator_commands/cookbook.rb +63 -8
- data/lib/chef-dk/command/generator_commands/cookbook_code_file.rb +100 -100
- data/lib/chef-dk/command/generator_commands/cookbook_file.rb +45 -45
- data/lib/chef-dk/command/generator_commands/generator_generator.rb +177 -177
- data/lib/chef-dk/command/generator_commands/lwrp.rb +36 -36
- data/lib/chef-dk/command/generator_commands/policyfile.rb +127 -127
- data/lib/chef-dk/command/generator_commands/recipe.rb +36 -36
- data/lib/chef-dk/command/generator_commands/repo.rb +125 -125
- data/lib/chef-dk/command/generator_commands/template.rb +46 -46
- data/lib/chef-dk/command/install.rb +121 -121
- data/lib/chef-dk/command/provision.rb +438 -438
- data/lib/chef-dk/command/push.rb +118 -118
- data/lib/chef-dk/command/push_archive.rb +126 -126
- data/lib/chef-dk/command/shell_init.rb +180 -180
- data/lib/chef-dk/command/show_policy.rb +165 -165
- data/lib/chef-dk/command/undelete.rb +155 -155
- data/lib/chef-dk/command/update.rb +148 -148
- data/lib/chef-dk/command/verify.rb +31 -26
- data/lib/chef-dk/completions/bash.sh.erb +5 -5
- data/lib/chef-dk/completions/chef.fish.erb +10 -10
- data/lib/chef-dk/completions/zsh.zsh.erb +21 -21
- data/lib/chef-dk/configurable.rb +69 -69
- data/lib/chef-dk/cookbook_metadata.rb +45 -45
- data/lib/chef-dk/cookbook_omnifetch.rb +32 -32
- data/lib/chef-dk/cookbook_profiler/git.rb +151 -151
- data/lib/chef-dk/cookbook_profiler/identifiers.rb +72 -72
- data/lib/chef-dk/cookbook_profiler/null_scm.rb +32 -32
- data/lib/chef-dk/exceptions.rb +129 -129
- data/lib/chef-dk/helpers.rb +10 -0
- data/lib/chef-dk/pager.rb +106 -106
- data/lib/chef-dk/policyfile/chef_repo_cookbook_source.rb +138 -138
- data/lib/chef-dk/policyfile/chef_server_cookbook_source.rb +54 -54
- data/lib/chef-dk/policyfile/community_cookbook_source.rb +97 -97
- data/lib/chef-dk/policyfile/comparison_base.rb +124 -124
- data/lib/chef-dk/policyfile/cookbook_location_specification.rb +154 -154
- data/lib/chef-dk/policyfile/cookbook_locks.rb +466 -466
- data/lib/chef-dk/policyfile/cookbook_sources.rb +22 -22
- data/lib/chef-dk/policyfile/delivery_supermarket_source.rb +90 -90
- data/lib/chef-dk/policyfile/differ.rb +266 -266
- data/lib/chef-dk/policyfile/dsl.rb +261 -261
- data/lib/chef-dk/policyfile/lister.rb +232 -232
- data/lib/chef-dk/policyfile/null_cookbook_source.rb +45 -45
- data/lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb +124 -124
- data/lib/chef-dk/policyfile/reports/install.rb +70 -70
- data/lib/chef-dk/policyfile/reports/table_printer.rb +58 -58
- data/lib/chef-dk/policyfile/reports/upload.rb +70 -70
- data/lib/chef-dk/policyfile/solution_dependencies.rb +298 -298
- data/lib/chef-dk/policyfile/storage_config.rb +100 -100
- data/lib/chef-dk/policyfile/undo_record.rb +142 -142
- data/lib/chef-dk/policyfile/undo_stack.rb +130 -130
- data/lib/chef-dk/policyfile/uploader.rb +213 -213
- data/lib/chef-dk/policyfile_compiler.rb +419 -419
- data/lib/chef-dk/policyfile_lock.rb +552 -552
- data/lib/chef-dk/policyfile_services/clean_policies.rb +95 -95
- data/lib/chef-dk/policyfile_services/clean_policy_cookbooks.rb +125 -125
- data/lib/chef-dk/policyfile_services/export_repo.rb +421 -421
- data/lib/chef-dk/policyfile_services/install.rb +126 -126
- data/lib/chef-dk/policyfile_services/push_archive.rb +204 -204
- data/lib/chef-dk/policyfile_services/rm_policy.rb +142 -142
- data/lib/chef-dk/policyfile_services/rm_policy_group.rb +86 -86
- data/lib/chef-dk/policyfile_services/show_policy.rb +237 -237
- data/lib/chef-dk/policyfile_services/undelete.rb +108 -108
- data/lib/chef-dk/policyfile_services/update_attributes.rb +104 -104
- data/lib/chef-dk/service_exception_inspectors.rb +25 -25
- data/lib/chef-dk/service_exception_inspectors/base.rb +40 -40
- data/lib/chef-dk/service_exception_inspectors/http.rb +121 -121
- data/lib/chef-dk/service_exceptions.rb +143 -143
- data/lib/chef-dk/shell_out.rb +36 -36
- data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +3 -3
- data/lib/chef-dk/skeletons/code_generator/files/default/{build-cookbook → build_cookbook}/.kitchen.yml +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/{build-cookbook → build_cookbook}/README.md +11 -11
- data/lib/chef-dk/skeletons/code_generator/files/default/{build-cookbook → build_cookbook}/test-fixture-recipe.rb +0 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/chefignore +102 -102
- data/lib/chef-dk/skeletons/code_generator/files/default/cookbook_readmes/README-policy.md +9 -9
- data/lib/chef-dk/skeletons/code_generator/files/default/cookbook_readmes/README.md +54 -54
- data/lib/chef-dk/skeletons/code_generator/files/default/delivery-config.json +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/delivery-project.toml +21 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/gitignore +16 -16
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/README.md +9 -13
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/README.md +5 -5
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +7 -7
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +3 -3
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +8 -8
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/README.md +3 -5
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/data_bags/example/example_item.json +3 -3
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/dot-chef-repo.txt +6 -6
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/README.md +9 -9
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/environments/example.json +12 -12
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/policies/README.md +24 -24
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/README.md +9 -9
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/roles/example.json +12 -12
- data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper.rb +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper_policyfile.rb +2 -2
- data/lib/chef-dk/skeletons/code_generator/metadata.rb +8 -8
- data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +5 -13
- data/lib/chef-dk/skeletons/code_generator/recipes/attribute.rb +12 -12
- data/lib/chef-dk/skeletons/code_generator/recipes/build_cookbook.rb +30 -7
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +12 -14
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb +24 -24
- data/lib/chef-dk/skeletons/code_generator/recipes/lwrp.rb +23 -23
- data/lib/chef-dk/skeletons/code_generator/recipes/policyfile.rb +8 -8
- data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +40 -27
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +67 -67
- data/lib/chef-dk/skeletons/code_generator/recipes/template.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.all_rights.erb +3 -3
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv2.erb +339 -339
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.gplv3.erb +674 -674
- data/lib/chef-dk/skeletons/code_generator/templates/default/LICENSE.mit.erb +21 -21
- data/lib/chef-dk/skeletons/code_generator/templates/default/Policyfile.rb.erb +25 -25
- data/lib/chef-dk/skeletons/code_generator/templates/default/README.md.erb +4 -4
- data/lib/chef-dk/skeletons/code_generator/templates/default/{build-cookbook → build_cookbook}/Berksfile.erb +0 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/{build-cookbook → build_cookbook}/metadata.rb.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/{build-cookbook → build_cookbook}/recipe.rb.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/inspec_default_test.rb.erb +18 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen.yml.erb +2 -5
- data/lib/chef-dk/skeletons/code_generator/templates/default/kitchen_policyfile.yml.erb +2 -5
- data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +7 -7
- data/lib/chef-dk/skeletons/code_generator/templates/default/recipe.rb.erb +5 -5
- data/lib/chef-dk/skeletons/code_generator/templates/default/recipe_spec.rb.erb +20 -20
- data/lib/chef-dk/skeletons/code_generator/templates/default/repo/gitignore.erb +11 -11
- data/lib/chef-dk/ui.rb +58 -58
- data/lib/chef-dk/version.rb +1 -1
- data/lib/kitchen/provisioner/policyfile_zero.rb +195 -195
- data/omnibus_overrides.rb +3 -3
- data/spec/shared/a_file_generator.rb +125 -125
- data/spec/shared/a_generated_file.rb +12 -12
- data/spec/shared/command_with_ui_object.rb +11 -11
- data/spec/shared/fixture_cookbook_checksums.rb +47 -47
- data/spec/shared/setup_git_cookbooks.rb +53 -53
- data/spec/spec_helper.rb +51 -51
- data/spec/test_helpers.rb +84 -84
- data/spec/unit/chef_runner_spec.rb +7 -5
- data/spec/unit/command/clean_policy_cookbooks_spec.rb +181 -181
- data/spec/unit/command/clean_policy_revisions_spec.rb +181 -181
- data/spec/unit/command/delete_policy_group_spec.rb +207 -207
- data/spec/unit/command/delete_policy_spec.rb +207 -207
- data/spec/unit/command/diff_spec.rb +312 -312
- data/spec/unit/command/env_spec.rb +52 -52
- data/spec/unit/command/exec_spec.rb +179 -179
- data/spec/unit/command/export_spec.rb +200 -200
- data/spec/unit/command/generate_spec.rb +142 -142
- data/spec/unit/command/generator_commands/app_spec.rb +5 -8
- data/spec/unit/command/generator_commands/attribute_spec.rb +32 -32
- data/spec/unit/command/generator_commands/base_spec.rb +136 -136
- data/spec/unit/command/generator_commands/build_cookbook_spec.rb +9 -9
- data/spec/unit/command/generator_commands/chef_exts/generator_desc_resource_spec.rb +97 -0
- data/spec/unit/command/generator_commands/chef_exts/recipe_dsl_ext_spec.rb +111 -0
- data/spec/unit/command/generator_commands/cookbook_file_spec.rb +32 -32
- data/spec/unit/command/generator_commands/cookbook_spec.rb +291 -111
- data/spec/unit/command/generator_commands/generator_generator_spec.rb +229 -229
- data/spec/unit/command/generator_commands/lwrp_spec.rb +32 -32
- data/spec/unit/command/generator_commands/policyfile_spec.rb +225 -225
- data/spec/unit/command/generator_commands/recipe_spec.rb +36 -34
- data/spec/unit/command/generator_commands/template_spec.rb +1 -1
- data/spec/unit/command/install_spec.rb +179 -179
- data/spec/unit/command/provision_spec.rb +592 -592
- data/spec/unit/command/push_archive_spec.rb +153 -153
- data/spec/unit/command/push_spec.rb +199 -199
- data/spec/unit/command/shell_init_spec.rb +329 -329
- data/spec/unit/command/show_policy_spec.rb +235 -235
- data/spec/unit/command/undelete_spec.rb +246 -246
- data/spec/unit/command/update_spec.rb +275 -275
- data/spec/unit/command/verify_spec.rb +0 -1
- data/spec/unit/commands_map_spec.rb +57 -57
- data/spec/unit/configurable_spec.rb +41 -41
- data/spec/unit/cookbook_metadata_spec.rb +98 -98
- data/spec/unit/cookbook_profiler/git_spec.rb +176 -176
- data/spec/unit/cookbook_profiler/identifiers_spec.rb +83 -83
- data/spec/unit/fixtures/chef-runner-cookbooks/test_cookbook/recipes/recipe_one.rb +9 -9
- data/spec/unit/fixtures/chef-runner-cookbooks/test_cookbook/recipes/recipe_two.rb +9 -9
- data/spec/unit/fixtures/command/cli_test_command.rb +26 -26
- data/spec/unit/fixtures/command/explicit_path_example.rb +7 -7
- data/spec/unit/fixtures/configurable/test_config_loader.rb +5 -5
- data/spec/unit/fixtures/configurable/test_configurable.rb +10 -10
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml +16 -16
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/Berksfile +3 -3
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md +4 -4
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/chefignore +96 -96
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb +8 -8
- data/spec/unit/fixtures/cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb +8 -8
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/.kitchen.yml +16 -16
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/Berksfile +3 -3
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/README.md +4 -4
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/chefignore +96 -96
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/metadata.rb +8 -8
- data/spec/unit/fixtures/cookbook_cache/dep_of_bar-1.2.3/recipes/default.rb +8 -8
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/.kitchen.yml +16 -16
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/Berksfile +3 -3
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/README.md +4 -4
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/chefignore +96 -96
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/metadata.rb +8 -8
- data/spec/unit/fixtures/cookbook_cache/foo-1.0.0/recipes/default.rb +8 -8
- data/spec/unit/fixtures/cookbooks_api/pruned_small_universe.json +1321 -1321
- data/spec/unit/fixtures/cookbooks_api/small_universe.json +2987 -2987
- data/spec/unit/fixtures/cookbooks_api/universe.json +1 -1
- data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +36 -36
- data/spec/unit/fixtures/dev_cookbooks/README.md +16 -16
- data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/berkshelf/integration_test +2 -2
- data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/berkshelf/verify_me +5 -5
- data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/chef/verify_me +3 -3
- data/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/test-kitchen/verify_me +2 -2
- data/spec/unit/fixtures/example_cookbook/.gitignore +17 -17
- data/spec/unit/fixtures/example_cookbook/.kitchen.yml +16 -16
- data/spec/unit/fixtures/example_cookbook/Berksfile +3 -3
- data/spec/unit/fixtures/example_cookbook/README.md +4 -4
- data/spec/unit/fixtures/example_cookbook/chefignore +96 -96
- data/spec/unit/fixtures/example_cookbook/metadata.rb +8 -8
- data/spec/unit/fixtures/example_cookbook/recipes/default.rb +8 -8
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/.gitignore +17 -17
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/.kitchen.yml +16 -16
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/Berksfile +3 -3
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/README.md +4 -4
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/chefignore +96 -96
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/metadata.json +5 -5
- data/spec/unit/fixtures/example_cookbook_metadata_json_only/recipes/default.rb +8 -8
- data/spec/unit/fixtures/example_cookbook_no_metadata/.gitignore +17 -17
- data/spec/unit/fixtures/example_cookbook_no_metadata/.kitchen.yml +16 -16
- data/spec/unit/fixtures/example_cookbook_no_metadata/Berksfile +3 -3
- data/spec/unit/fixtures/example_cookbook_no_metadata/README.md +4 -4
- data/spec/unit/fixtures/example_cookbook_no_metadata/chefignore +96 -96
- data/spec/unit/fixtures/example_cookbook_no_metadata/recipes/default.rb +8 -8
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/README.md +4 -4
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/chefignore +96 -96
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/metadata.rb +8 -8
- data/spec/unit/fixtures/local_path_cookbooks/another-local-cookbook/recipes/default.rb +8 -8
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/Berksfile +3 -3
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/README.md +4 -4
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/chefignore +96 -96
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/metadata.rb +9 -9
- data/spec/unit/fixtures/local_path_cookbooks/cookbook-with-a-dep/recipes/default.rb +8 -8
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/.kitchen.yml +16 -16
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/Berksfile +3 -3
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/README.md +4 -4
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/chefignore +96 -96
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/metadata.rb +8 -8
- data/spec/unit/fixtures/local_path_cookbooks/local-cookbook/recipes/default.rb +8 -8
- data/spec/unit/fixtures/local_path_cookbooks/metadata-missing/README.md +2 -2
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/.kitchen.yml +16 -16
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/README.md +4 -4
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/metadata.rb +8 -8
- data/spec/unit/fixtures/local_path_cookbooks/noignore-f59ee7a5bca6a4e606b67f7f856b768d847c39bb/recipes/default.rb +8 -8
- data/spec/unit/helpers_spec.rb +14 -5
- data/spec/unit/pager_spec.rb +119 -119
- data/spec/unit/policyfile/chef_repo_cookbook_source_spec.rb +93 -93
- data/spec/unit/policyfile/chef_server_cookbook_source_spec.rb +34 -34
- data/spec/unit/policyfile/community_cookbook_source_spec.rb +84 -84
- data/spec/unit/policyfile/comparison_base_spec.rb +343 -343
- data/spec/unit/policyfile/cookbook_location_specification_spec.rb +277 -277
- data/spec/unit/policyfile/cookbook_locks_spec.rb +529 -529
- data/spec/unit/policyfile/delivery_supermarket_source_spec.rb +130 -130
- data/spec/unit/policyfile/differ_spec.rb +687 -687
- data/spec/unit/policyfile/lister_spec.rb +272 -272
- data/spec/unit/policyfile/null_cookbook_source_spec.rb +35 -35
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +92 -92
- data/spec/unit/policyfile/reports/install_spec.rb +115 -115
- data/spec/unit/policyfile/reports/upload_spec.rb +96 -96
- data/spec/unit/policyfile/solution_dependencies_spec.rb +145 -145
- data/spec/unit/policyfile/storage_config_spec.rb +172 -172
- data/spec/unit/policyfile/undo_record_spec.rb +260 -260
- data/spec/unit/policyfile/undo_stack_spec.rb +266 -266
- data/spec/unit/policyfile/uploader_spec.rb +410 -410
- data/spec/unit/policyfile_demands_spec.rb +1203 -1203
- data/spec/unit/policyfile_evaluation_spec.rb +642 -642
- data/spec/unit/policyfile_lock_build_spec.rb +1056 -1056
- data/spec/unit/policyfile_lock_install_spec.rb +138 -138
- data/spec/unit/policyfile_lock_serialization_spec.rb +425 -425
- data/spec/unit/policyfile_lock_validation_spec.rb +611 -611
- data/spec/unit/policyfile_services/clean_policies_spec.rb +236 -236
- data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +275 -275
- data/spec/unit/policyfile_services/export_repo_spec.rb +481 -481
- data/spec/unit/policyfile_services/install_spec.rb +211 -211
- data/spec/unit/policyfile_services/push_archive_spec.rb +378 -378
- data/spec/unit/policyfile_services/push_spec.rb +233 -233
- data/spec/unit/policyfile_services/rm_policy_group_spec.rb +241 -241
- data/spec/unit/policyfile_services/rm_policy_spec.rb +266 -266
- data/spec/unit/policyfile_services/show_policy_spec.rb +889 -889
- data/spec/unit/policyfile_services/undelete_spec.rb +304 -304
- data/spec/unit/policyfile_services/update_attributes_spec.rb +217 -217
- data/spec/unit/service_exception_inspectors/base_spec.rb +43 -43
- data/spec/unit/service_exception_inspectors/http_spec.rb +140 -140
- data/spec/unit/shell_out_spec.rb +34 -34
- data/tasks/bin/bundle-platform +0 -0
- data/tasks/bin/bundle-platform.bat +0 -0
- data/tasks/bin/create-override-gemfile +0 -0
- data/version_policy.rb +4 -3
- data/warning.txt +9 -9
- metadata +23 -10
- data/lib/chef-dk/skeletons/code_generator/files/default/serverspec_spec_helper.rb +0 -8
- data/lib/chef-dk/skeletons/code_generator/templates/default/serverspec_default_spec.rb.erb +0 -9
@@ -0,0 +1,111 @@
|
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) 2016 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 'spec_helper'
|
19
|
+
require 'stringio'
|
20
|
+
|
21
|
+
require 'chef/config'
|
22
|
+
require 'chef/recipe'
|
23
|
+
require 'chef/run_context'
|
24
|
+
require 'chef/event_dispatch/dispatcher'
|
25
|
+
require 'chef/policy_builder'
|
26
|
+
require 'chef/formatters/doc'
|
27
|
+
require 'chef/cookbook/file_vendor'
|
28
|
+
require 'chef/cookbook/file_system_file_vendor'
|
29
|
+
require 'chef/cookbook/cookbook_collection'
|
30
|
+
require 'chef/cookbook_loader'
|
31
|
+
|
32
|
+
require 'ohai/system'
|
33
|
+
|
34
|
+
require 'chef-dk/command/generator_commands/chef_exts/recipe_dsl_ext'
|
35
|
+
require 'chef-dk/command/generator_commands/chef_exts/quieter_doc_formatter'
|
36
|
+
|
37
|
+
describe ChefDK::RecipeDSLExt do
|
38
|
+
|
39
|
+
before(:all) { Chef.reset! }
|
40
|
+
|
41
|
+
let(:stdout) { StringIO.new }
|
42
|
+
|
43
|
+
let(:stderr) { StringIO.new }
|
44
|
+
|
45
|
+
let(:doc_formatter) do
|
46
|
+
Chef::Formatters.new(:chefdk_doc, stdout, stderr)
|
47
|
+
end
|
48
|
+
|
49
|
+
let(:event_dispatcher) do
|
50
|
+
Chef::EventDispatch::Dispatcher.new.tap do |d|
|
51
|
+
d.register(doc_formatter)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
let(:run_list) { [ ] }
|
56
|
+
|
57
|
+
let(:ohai) do
|
58
|
+
Ohai::System.new.tap do |o|
|
59
|
+
o.all_plugins(["platform", "platform_version"])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
let(:policy_builder) do
|
64
|
+
Chef::PolicyBuilder::Dynamic.new("chef-dk", ohai.data, {}, nil, event_dispatcher).tap do |b|
|
65
|
+
b.load_node
|
66
|
+
b.build_node
|
67
|
+
b.node.run_list(*run_list)
|
68
|
+
b.expand_run_list
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# In some circumstances (not totally clear about what), compat resource gets
|
73
|
+
# loaded and it does some weird stuff to `Chef::Recipe.new` which can fail if
|
74
|
+
# you pass in a cookbook name that is bogus and not-falsey. Using `nil` for
|
75
|
+
# the cookbook name works around that.
|
76
|
+
# https://github.com/chef-cookbooks/compat_resource/blob/3d948a5a9cabccddc7cf5e48dfea796a6b557a44/files/lib/chef_compat/monkeypatches/chef/recipe.rb#L8-L15
|
77
|
+
let(:cookbook_name) { nil }
|
78
|
+
|
79
|
+
let(:recipe_name) { "example" }
|
80
|
+
|
81
|
+
let(:run_context) { policy_builder.setup_run_context }
|
82
|
+
|
83
|
+
let(:recipe) { Chef::Recipe.new(cookbook_name, recipe_name, run_context) }
|
84
|
+
|
85
|
+
before do
|
86
|
+
Chef::Config.solo_legacy_mode = true
|
87
|
+
Chef::Config.color = true
|
88
|
+
Chef::Config.diff_disabled = true
|
89
|
+
Chef::Config.use_policyfile = false
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "silence_chef_formatter" do
|
93
|
+
|
94
|
+
before do
|
95
|
+
recipe.silence_chef_formatter
|
96
|
+
end
|
97
|
+
|
98
|
+
let(:formatter) { run_context.events.subscribers.first }
|
99
|
+
|
100
|
+
it "replaces the default formatter with a null formatter" do
|
101
|
+
expect(formatter).to be_a(Chef::Formatters::NullFormatter)
|
102
|
+
end
|
103
|
+
|
104
|
+
it "passes stdout and stderr from the default formatter to the new one" do
|
105
|
+
expect(formatter.output.out).to be(stdout)
|
106
|
+
expect(formatter.output.err).to be(stderr)
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
#
|
2
|
-
# Copyright:: Copyright (c) 2014 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 'spec_helper'
|
19
|
-
require 'shared/a_file_generator'
|
20
|
-
require 'chef-dk/command/generator_commands/cookbook_file'
|
21
|
-
|
22
|
-
describe ChefDK::Command::GeneratorCommands::CookbookFile do
|
23
|
-
|
24
|
-
include_examples "a file generator" do
|
25
|
-
|
26
|
-
let(:generator_name) { "file" }
|
27
|
-
let(:generated_files) { [ "files/default/new_file.txt" ] }
|
28
|
-
let(:new_file_name) { "new_file.txt" }
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
1
|
+
#
|
2
|
+
# Copyright:: Copyright (c) 2014 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 'spec_helper'
|
19
|
+
require 'shared/a_file_generator'
|
20
|
+
require 'chef-dk/command/generator_commands/cookbook_file'
|
21
|
+
|
22
|
+
describe ChefDK::Command::GeneratorCommands::CookbookFile do
|
23
|
+
|
24
|
+
include_examples "a file generator" do
|
25
|
+
|
26
|
+
let(:generator_name) { "file" }
|
27
|
+
let(:generated_files) { [ "files/default/new_file.txt" ] }
|
28
|
+
let(:new_file_name) { "new_file.txt" }
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -34,11 +34,8 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
34
34
|
.gitignore
|
35
35
|
.kitchen.yml
|
36
36
|
test
|
37
|
-
test/
|
38
|
-
test/
|
39
|
-
test/integration/default/serverspec
|
40
|
-
test/integration/default/serverspec/default_spec.rb
|
41
|
-
test/integration/helpers/serverspec/spec_helper.rb
|
37
|
+
test/recipes
|
38
|
+
test/recipes/default_test.rb
|
42
39
|
Berksfile
|
43
40
|
chefignore
|
44
41
|
metadata.rb
|
@@ -59,6 +56,23 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
59
56
|
end
|
60
57
|
end
|
61
58
|
|
59
|
+
let(:non_delivery_breadcrumb) do
|
60
|
+
<<-EOF
|
61
|
+
Your cookbook is ready. Type `cd new_cookbook` to enter it.
|
62
|
+
|
63
|
+
There are several commands you can run to get started locally developing and testing your cookbook.
|
64
|
+
Type `delivery local --help` to see a full list.
|
65
|
+
|
66
|
+
Why not start by writing a test? Tests for the default recipe are stored at:
|
67
|
+
|
68
|
+
test/recipes/default_test.rb
|
69
|
+
|
70
|
+
If you'd prefer to dive right in, the default recipe can be found at:
|
71
|
+
|
72
|
+
recipes/default.rb
|
73
|
+
EOF
|
74
|
+
end
|
75
|
+
|
62
76
|
subject(:cookbook_generator) do
|
63
77
|
g = described_class.new(argv)
|
64
78
|
allow(g).to receive(:cookbook_path_in_git_repo?).and_return(false)
|
@@ -112,6 +126,12 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
112
126
|
expect(stderr_io.string).to include(message)
|
113
127
|
end
|
114
128
|
|
129
|
+
it "errors if a hyphenated cookbook name is passed" do
|
130
|
+
expect(with_argv(%w{my-cookbook}).run).to eq(1)
|
131
|
+
message = "Hyphens are not allowed in cookbook names. Please specify a cookbook name without hyphens."
|
132
|
+
expect(stderr_io.string).to include(message)
|
133
|
+
end
|
134
|
+
|
115
135
|
end
|
116
136
|
|
117
137
|
context "when given the name of the cookbook to generate" do
|
@@ -128,6 +148,7 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
128
148
|
expect(generator_context.cookbook_root).to eq(Dir.pwd)
|
129
149
|
expect(generator_context.cookbook_name).to eq("new_cookbook")
|
130
150
|
expect(generator_context.recipe_name).to eq("default")
|
151
|
+
expect(generator_context.verbose).to be(false)
|
131
152
|
end
|
132
153
|
|
133
154
|
it "creates a new cookbook" do
|
@@ -141,6 +162,263 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
141
162
|
end
|
142
163
|
end
|
143
164
|
|
165
|
+
context "by default configure for delivery" do
|
166
|
+
|
167
|
+
let(:dot_delivery) { File.join(tempdir, "new_cookbook", ".delivery") }
|
168
|
+
|
169
|
+
before do
|
170
|
+
Dir.chdir(tempdir) do
|
171
|
+
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
172
|
+
expect(cookbook_generator.run).to eq(0)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
describe ".delivery/project.toml" do
|
177
|
+
|
178
|
+
let(:file) { File.join(tempdir, "new_cookbook", ".delivery", "project.toml") }
|
179
|
+
|
180
|
+
let(:expected_content) do
|
181
|
+
<<-PROJECT_DOT_TOML
|
182
|
+
# Delivery Prototype for Local Phases Execution
|
183
|
+
#
|
184
|
+
# The purpose of this file is to prototype a new way to execute
|
185
|
+
# phases locally on your workstation. The delivery-cli will read
|
186
|
+
# this file and execute the command(s) that are configured for
|
187
|
+
# each phase. You can customize them by just modifying the phase
|
188
|
+
# key on this file.
|
189
|
+
#
|
190
|
+
# By default these phases are configured for Cookbook Workflow only
|
191
|
+
#
|
192
|
+
# As this is still a prototype we are not modifying the current
|
193
|
+
# config.json file and it will continue working as usual.
|
194
|
+
|
195
|
+
[local_phases]
|
196
|
+
unit = "rspec spec/"
|
197
|
+
lint = "cookstyle"
|
198
|
+
syntax = "foodcritic . --exclude spec -f any"
|
199
|
+
provision = "chef exec kitchen create"
|
200
|
+
deploy = "chef exec kitchen converge"
|
201
|
+
smoke = "chef exec kitchen verify"
|
202
|
+
cleanup = "chef exec kitchen destroy"
|
203
|
+
PROJECT_DOT_TOML
|
204
|
+
end
|
205
|
+
|
206
|
+
it "exists with default config for Cookbook Workflow" do
|
207
|
+
expect(IO.read(file)).to eq(expected_content)
|
208
|
+
end
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
describe ".delivery/config.json" do
|
213
|
+
|
214
|
+
let(:file) { File.join(tempdir, "new_cookbook", ".delivery", "config.json") }
|
215
|
+
|
216
|
+
let(:expected_content) do
|
217
|
+
<<-CONFIG_DOT_JSON
|
218
|
+
{
|
219
|
+
"version": "2",
|
220
|
+
"build_cookbook": {
|
221
|
+
"name": "build_cookbook",
|
222
|
+
"path": ".delivery/build_cookbook"
|
223
|
+
},
|
224
|
+
"skip_phases": [],
|
225
|
+
"build_nodes": {},
|
226
|
+
"dependencies": []
|
227
|
+
}
|
228
|
+
CONFIG_DOT_JSON
|
229
|
+
end
|
230
|
+
|
231
|
+
it "configures delivery to use a local build cookbook" do
|
232
|
+
expect(IO.read(file)).to eq(expected_content)
|
233
|
+
end
|
234
|
+
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "build cookbook recipes" do
|
238
|
+
|
239
|
+
let(:file) do
|
240
|
+
File.join(dot_delivery, "build_cookbook", "recipes", "publish.rb")
|
241
|
+
end
|
242
|
+
|
243
|
+
let(:expected_content) do
|
244
|
+
<<-CONFIG_DOT_JSON
|
245
|
+
#
|
246
|
+
# Cookbook Name:: build_cookbook
|
247
|
+
# Recipe:: publish
|
248
|
+
#
|
249
|
+
# Copyright (c) 2016 The Authors, All Rights Reserved.
|
250
|
+
include_recipe 'delivery-truck::publish'
|
251
|
+
CONFIG_DOT_JSON
|
252
|
+
end
|
253
|
+
|
254
|
+
it "delegates functionality to delivery-truck" do
|
255
|
+
expect(IO.read(file)).to include(expected_content)
|
256
|
+
end
|
257
|
+
|
258
|
+
end
|
259
|
+
|
260
|
+
describe "build cookbook Berksfile" do
|
261
|
+
|
262
|
+
let(:file) do
|
263
|
+
File.join(dot_delivery, "build_cookbook", "Berksfile")
|
264
|
+
end
|
265
|
+
|
266
|
+
let(:expected_content) do
|
267
|
+
<<-CONFIG_DOT_JSON
|
268
|
+
source 'https://supermarket.chef.io'
|
269
|
+
|
270
|
+
metadata
|
271
|
+
|
272
|
+
cookbook 'delivery-truck',
|
273
|
+
git: 'https://github.com/chef-cookbooks/delivery-truck.git',
|
274
|
+
branch: 'master'
|
275
|
+
|
276
|
+
# This is so we know where to get delivery-truck's dependency
|
277
|
+
cookbook 'delivery-sugar',
|
278
|
+
git: 'https://github.com/chef-cookbooks/delivery-sugar.git',
|
279
|
+
branch: 'master'
|
280
|
+
|
281
|
+
group :delivery do
|
282
|
+
cookbook 'delivery_build', git: 'https://github.com/chef-cookbooks/delivery_build'
|
283
|
+
cookbook 'delivery-base', git: 'https://github.com/chef-cookbooks/delivery-base'
|
284
|
+
cookbook 'test', path: './test/fixtures/cookbooks/test'
|
285
|
+
end
|
286
|
+
CONFIG_DOT_JSON
|
287
|
+
end
|
288
|
+
|
289
|
+
it "sets the sources for delivery library cookbooks to github" do
|
290
|
+
expect(IO.read(file)).to include(expected_content)
|
291
|
+
end
|
292
|
+
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
context "when passed delivery option" do
|
297
|
+
|
298
|
+
let(:argv) { %w[new_cookbook --delivery] }
|
299
|
+
|
300
|
+
it 'still works with no action' do
|
301
|
+
Dir.chdir(tempdir) do
|
302
|
+
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
303
|
+
expect(cookbook_generator.run).to eq(0)
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
context "when given the verbose flag" do
|
309
|
+
|
310
|
+
let(:argv) { %w[ new_cookbook --verbose ] }
|
311
|
+
|
312
|
+
it "configures the generator context with verbose mode enabled" do
|
313
|
+
cookbook_generator.read_and_validate_params
|
314
|
+
cookbook_generator.setup_context
|
315
|
+
expect(generator_context.verbose).to be(true)
|
316
|
+
end
|
317
|
+
|
318
|
+
it "emits verbose output" do
|
319
|
+
Dir.chdir(tempdir) do
|
320
|
+
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
321
|
+
expect(cookbook_generator.run).to eq(0)
|
322
|
+
end
|
323
|
+
|
324
|
+
# The normal chef formatter puts a heading for each recipe like this.
|
325
|
+
# Full output is large and subject to change with minor changes in the
|
326
|
+
# generator cookbook, so we just look for this line
|
327
|
+
expected_line = "Recipe: code_generator::cookbook"
|
328
|
+
|
329
|
+
actual = stdout_io.string
|
330
|
+
|
331
|
+
expect(actual).to include(expected_line)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
context "when no delivery CLI configuration is present" do
|
336
|
+
|
337
|
+
it "detects no delivery config" do
|
338
|
+
Dir.chdir(tempdir) do
|
339
|
+
expect(cookbook_generator.have_delivery_config?).to be(false)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
it "emits concise output" do
|
344
|
+
Dir.chdir(tempdir) do
|
345
|
+
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
346
|
+
expect(cookbook_generator.run).to eq(0)
|
347
|
+
end
|
348
|
+
|
349
|
+
expected = <<-OUTPUT
|
350
|
+
Generating cookbook new_cookbook
|
351
|
+
- Ensuring correct cookbook file content
|
352
|
+
- Committing cookbook files to git
|
353
|
+
- Ensuring delivery configuration
|
354
|
+
- Ensuring correct delivery build cookbook content
|
355
|
+
- Adding delivery configuration to feature branch
|
356
|
+
- Adding build cookbook to feature branch
|
357
|
+
- Merging delivery content feature branch to master
|
358
|
+
|
359
|
+
#{non_delivery_breadcrumb}
|
360
|
+
OUTPUT
|
361
|
+
|
362
|
+
actual = stdout_io.string
|
363
|
+
|
364
|
+
# the formatter will add escape sequences to turn off any colors
|
365
|
+
actual.gsub!("\e[0m", "")
|
366
|
+
expect(actual).to eq(expected)
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
context "when a delivery CLI config is present" do
|
371
|
+
|
372
|
+
# Setup a situation like this:
|
373
|
+
# there is a dir for the delivery organization with the
|
374
|
+
# `.delivery/cli.toml` in it. Inside that is another dir (maybe IRL this
|
375
|
+
# would be "cookbooks"), then we create the cookbook inside that.
|
376
|
+
|
377
|
+
let(:tempdir_subdir) { File.join(tempdir, "subdirectory") }
|
378
|
+
|
379
|
+
let(:dot_delivery_dir) { File.join(tempdir, ".delivery") }
|
380
|
+
|
381
|
+
let(:dot_delivery_cli_toml) { File.join(dot_delivery_dir, "cli.toml") }
|
382
|
+
|
383
|
+
before do
|
384
|
+
Dir.mkdir(tempdir_subdir)
|
385
|
+
Dir.mkdir(dot_delivery_dir)
|
386
|
+
FileUtils.touch(dot_delivery_cli_toml)
|
387
|
+
end
|
388
|
+
|
389
|
+
it "detects the delivery config" do
|
390
|
+
Dir.chdir(tempdir_subdir) do
|
391
|
+
expect(cookbook_generator.have_delivery_config?).to be(true)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
it "emits concise output" do
|
396
|
+
Dir.chdir(tempdir) do
|
397
|
+
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
398
|
+
expect(cookbook_generator.run).to eq(0)
|
399
|
+
end
|
400
|
+
|
401
|
+
expected = <<-OUTPUT
|
402
|
+
Generating cookbook new_cookbook
|
403
|
+
- Ensuring correct cookbook file content
|
404
|
+
- Committing cookbook files to git
|
405
|
+
- Ensuring delivery configuration
|
406
|
+
- Ensuring correct delivery build cookbook content
|
407
|
+
- Adding delivery configuration to feature branch
|
408
|
+
- Adding build cookbook to feature branch
|
409
|
+
- Merging delivery content feature branch to master
|
410
|
+
|
411
|
+
Your cookbook is ready. To setup the pipeline, type `cd new_cookbook`, then run `delivery init`
|
412
|
+
OUTPUT
|
413
|
+
|
414
|
+
actual = stdout_io.string
|
415
|
+
|
416
|
+
# the formatter will add escape sequences to turn off any colors
|
417
|
+
actual.gsub!("\e[0m", "")
|
418
|
+
expect(actual).to eq(expected)
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
144
422
|
shared_examples_for "a generated file" do |context_var|
|
145
423
|
before do
|
146
424
|
Dir.chdir(tempdir) do
|
@@ -185,11 +463,11 @@ describe ChefDK::Command::GeneratorCommands::Cookbook do
|
|
185
463
|
|
186
464
|
end
|
187
465
|
|
188
|
-
describe "test/
|
189
|
-
let(:file) { File.join(tempdir, "new_cookbook", "test", "
|
466
|
+
describe "test/recipes/default_test.rb" do
|
467
|
+
let(:file) { File.join(tempdir, "new_cookbook", "test", "recipes", "default_test.rb") }
|
190
468
|
|
191
469
|
include_examples "a generated file", :cookbook_name do
|
192
|
-
let(:line) { "describe
|
470
|
+
let(:line) { "describe port" }
|
193
471
|
end
|
194
472
|
end
|
195
473
|
end
|
@@ -284,11 +562,8 @@ provisioner:
|
|
284
562
|
|
285
563
|
# require_chef_omnibus: 12.8.1
|
286
564
|
|
287
|
-
|
288
|
-
|
289
|
-
# verifier:
|
290
|
-
# name: inspec
|
291
|
-
# format: doc
|
565
|
+
verifier:
|
566
|
+
name: inspec
|
292
567
|
|
293
568
|
platforms:
|
294
569
|
- name: ubuntu-16.04
|
@@ -355,11 +630,8 @@ driver:
|
|
355
630
|
provisioner:
|
356
631
|
name: chef_zero
|
357
632
|
|
358
|
-
|
359
|
-
|
360
|
-
# verifier:
|
361
|
-
# name: inspec
|
362
|
-
# format: doc
|
633
|
+
verifier:
|
634
|
+
name: inspec
|
363
635
|
|
364
636
|
platforms:
|
365
637
|
- name: ubuntu-16.04
|
@@ -388,98 +660,6 @@ SPEC_HELPER
|
|
388
660
|
|
389
661
|
end
|
390
662
|
|
391
|
-
context "when configured for delivery" do
|
392
|
-
|
393
|
-
let(:argv) { %w[new_cookbook --delivery] }
|
394
|
-
|
395
|
-
let(:dot_delivery) { File.join(tempdir, "new_cookbook", ".delivery") }
|
396
|
-
|
397
|
-
before do
|
398
|
-
Dir.chdir(tempdir) do
|
399
|
-
allow(cookbook_generator.chef_runner).to receive(:stdout).and_return(stdout_io)
|
400
|
-
expect(cookbook_generator.run).to eq(0)
|
401
|
-
end
|
402
|
-
end
|
403
|
-
|
404
|
-
describe ".delivery/config.json" do
|
405
|
-
|
406
|
-
let(:file) { File.join(tempdir, "new_cookbook", ".delivery", "config.json") }
|
407
|
-
|
408
|
-
let(:expected_content) do
|
409
|
-
<<-CONFIG_DOT_JSON
|
410
|
-
{
|
411
|
-
"version": "2",
|
412
|
-
"build_cookbook": {
|
413
|
-
"name": "build-cookbook",
|
414
|
-
"path": ".delivery/build-cookbook"
|
415
|
-
},
|
416
|
-
"skip_phases": [],
|
417
|
-
"build_nodes": {},
|
418
|
-
"dependencies": []
|
419
|
-
}
|
420
|
-
CONFIG_DOT_JSON
|
421
|
-
end
|
422
|
-
|
423
|
-
it "configures delivery to use a local build cookbook" do
|
424
|
-
expect(IO.read(file)).to eq(expected_content)
|
425
|
-
end
|
426
|
-
|
427
|
-
end
|
428
|
-
|
429
|
-
describe "build cookbook recipes" do
|
430
|
-
|
431
|
-
let(:file) do
|
432
|
-
File.join(dot_delivery, "build-cookbook", "recipes", "publish.rb")
|
433
|
-
end
|
434
|
-
|
435
|
-
let(:expected_content) do
|
436
|
-
<<-CONFIG_DOT_JSON
|
437
|
-
include_recipe 'delivery-truck::publish'
|
438
|
-
CONFIG_DOT_JSON
|
439
|
-
end
|
440
|
-
|
441
|
-
it "delegates functionality to delivery-truck" do
|
442
|
-
expect(IO.read(file)).to include(expected_content)
|
443
|
-
end
|
444
|
-
|
445
|
-
end
|
446
|
-
|
447
|
-
describe "build cookbook Berksfile" do
|
448
|
-
|
449
|
-
let(:file) do
|
450
|
-
File.join(dot_delivery, "build-cookbook", "Berksfile")
|
451
|
-
end
|
452
|
-
|
453
|
-
let(:expected_content) do
|
454
|
-
<<-CONFIG_DOT_JSON
|
455
|
-
source 'https://supermarket.chef.io'
|
456
|
-
|
457
|
-
metadata
|
458
|
-
|
459
|
-
cookbook 'delivery-truck',
|
460
|
-
git: 'https://github.com/chef-cookbooks/delivery-truck.git',
|
461
|
-
branch: 'master'
|
462
|
-
|
463
|
-
# This is so we know where to get delivery-truck's dependency
|
464
|
-
cookbook 'delivery-sugar',
|
465
|
-
git: 'https://github.com/chef-cookbooks/delivery-sugar.git',
|
466
|
-
branch: 'master'
|
467
|
-
|
468
|
-
group :delivery do
|
469
|
-
cookbook 'delivery_build', git: 'https://github.com/chef-cookbooks/delivery_build'
|
470
|
-
cookbook 'delivery-base', git: 'https://github.com/chef-cookbooks/delivery-base'
|
471
|
-
cookbook 'test', path: './test/fixtures/cookbooks/test'
|
472
|
-
end
|
473
|
-
CONFIG_DOT_JSON
|
474
|
-
end
|
475
|
-
|
476
|
-
it "sets the sources for delivery library cookbooks to github" do
|
477
|
-
expect(IO.read(file)).to include(expected_content)
|
478
|
-
end
|
479
|
-
|
480
|
-
end
|
481
|
-
end
|
482
|
-
|
483
663
|
describe "metadata.rb" do
|
484
664
|
let(:file) { File.join(tempdir, "new_cookbook", "metadata.rb") }
|
485
665
|
|
@@ -500,7 +680,7 @@ CONFIG_DOT_JSON
|
|
500
680
|
let(:file) { File.join(tempdir, "new_cookbook", "spec", "unit", "recipes", "default_spec.rb") }
|
501
681
|
|
502
682
|
include_examples "a generated file", :cookbook_name do
|
503
|
-
let(:line) { "describe
|
683
|
+
let(:line) { "describe 'new_cookbook::default' do" }
|
504
684
|
end
|
505
685
|
end
|
506
686
|
|