chef-dk 1.2.22 → 1.3.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +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/lib/chef-dk/configurable.rb
CHANGED
|
@@ -15,18 +15,17 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require
|
|
19
|
-
require
|
|
20
|
-
require
|
|
21
|
-
require
|
|
18
|
+
require "cookbook-omnifetch"
|
|
19
|
+
require "chef-dk/shell_out"
|
|
20
|
+
require "chef-dk/cookbook_metadata"
|
|
21
|
+
require "chef-dk/helpers"
|
|
22
22
|
|
|
23
|
-
require
|
|
23
|
+
require "chef/http/simple"
|
|
24
24
|
|
|
25
25
|
# Configure CookbookOmnifetch's dependency injection settings to use our classes and config.
|
|
26
26
|
CookbookOmnifetch.configure do |c|
|
|
27
|
-
c.cache_path = File.expand_path(File.join(ChefDK::Helpers.chefdk_home,
|
|
28
|
-
c.storage_path = Pathname.new(File.expand_path(File.join(ChefDK::Helpers.chefdk_home,
|
|
27
|
+
c.cache_path = File.expand_path(File.join(ChefDK::Helpers.chefdk_home, "cache"))
|
|
28
|
+
c.storage_path = Pathname.new(File.expand_path(File.join(ChefDK::Helpers.chefdk_home, "cache", "cookbooks")))
|
|
29
29
|
c.shell_out_class = ChefDK::ShellOut
|
|
30
30
|
c.cached_cookbook_class = ChefDK::CookbookMetadata
|
|
31
31
|
end
|
|
32
|
-
|
|
@@ -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
|
module ChefDK
|
|
21
21
|
module CookbookProfiler
|
|
@@ -42,7 +42,7 @@ module ChefDK
|
|
|
42
42
|
"revision" => revision,
|
|
43
43
|
"working_tree_clean" => clean?,
|
|
44
44
|
"published" => !unpublished_commits?,
|
|
45
|
-
"synchronized_remote_branches" => synchronized_remotes
|
|
45
|
+
"synchronized_remote_branches" => synchronized_remotes,
|
|
46
46
|
}
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -60,7 +60,7 @@ module ChefDK
|
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def clean?
|
|
63
|
-
git!("diff-files --quiet", returns: [0,1]).exitstatus == 0
|
|
63
|
+
git!("diff-files --quiet", returns: [0, 1]).exitstatus == 0
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def unpublished_commits?
|
|
@@ -90,11 +90,11 @@ module ChefDK
|
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
def remote_name
|
|
93
|
-
@remote_name ||= git!("config --get branch.#{current_branch}.remote", returns: [0,1]).stdout.strip
|
|
93
|
+
@remote_name ||= git!("config --get branch.#{current_branch}.remote", returns: [0, 1]).stdout.strip
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
def have_remote?
|
|
97
|
-
!remote_name.empty? && remote_name !=
|
|
97
|
+
!remote_name.empty? && remote_name != "."
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
def current_branch
|
|
@@ -103,19 +103,19 @@ module ChefDK
|
|
|
103
103
|
|
|
104
104
|
private
|
|
105
105
|
|
|
106
|
-
def git!(subcommand, options={})
|
|
106
|
+
def git!(subcommand, options = {})
|
|
107
107
|
cmd = git(subcommand, options)
|
|
108
108
|
cmd.error!
|
|
109
109
|
cmd
|
|
110
110
|
end
|
|
111
111
|
|
|
112
|
-
def git(subcommand, options={})
|
|
112
|
+
def git(subcommand, options = {})
|
|
113
113
|
options = { cwd: cookbook_path }.merge(options)
|
|
114
114
|
system_command("git #{subcommand}", options)
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
def detect_current_branch
|
|
118
|
-
branch = git!(
|
|
118
|
+
branch = git!("rev-parse --abbrev-ref HEAD").stdout.strip
|
|
119
119
|
@unborn_branch = false
|
|
120
120
|
branch
|
|
121
121
|
rescue Mixlib::ShellOut::ShellCommandFailed => e
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
#
|
|
17
17
|
|
|
18
18
|
# TODO: Chef should require its dependency correctly.
|
|
19
|
-
require
|
|
20
|
-
require
|
|
21
|
-
require
|
|
19
|
+
require "singleton"
|
|
20
|
+
require "chef/cookbook/cookbook_version_loader"
|
|
21
|
+
require "digest/sha1"
|
|
22
22
|
|
|
23
|
-
require
|
|
23
|
+
require "chef/digester"
|
|
24
24
|
|
|
25
|
-
require
|
|
25
|
+
require "chef-dk/exceptions"
|
|
26
26
|
|
|
27
27
|
module ChefDK
|
|
28
28
|
module CookbookProfiler
|
|
@@ -47,12 +47,12 @@ module ChefDK
|
|
|
47
47
|
major = hex_id[0...14]
|
|
48
48
|
minor = hex_id[14...28]
|
|
49
49
|
patch = hex_id[28..40]
|
|
50
|
-
decimal_integers =[major, minor, patch].map {|hex| hex.to_i(16) }
|
|
50
|
+
decimal_integers = [major, minor, patch].map { |hex| hex.to_i(16) }
|
|
51
51
|
decimal_integers.join(".")
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def fingerprint_text
|
|
55
|
-
files_with_checksums.sort {|a,b| a[0] <=> b[0]}.inject("") do |fingerprint, file_spec|
|
|
55
|
+
files_with_checksums.sort { |a, b| a[0] <=> b[0] }.inject("") do |fingerprint, file_spec|
|
|
56
56
|
fingerprint << "#{file_spec[0]}:#{file_spec[1]}\n"
|
|
57
57
|
end
|
|
58
58
|
end
|
data/lib/chef-dk/exceptions.rb
CHANGED
|
@@ -116,7 +116,7 @@ module ChefDK
|
|
|
116
116
|
source_a.universe_graph.key?(cookbook_name) && source_b.universe_graph.key?(cookbook_name)
|
|
117
117
|
end
|
|
118
118
|
"Source #{source_a.desc} and #{source_b.desc} contain conflicting cookbooks:\n" +
|
|
119
|
-
overlapping_cookbooks.sort.map {|c| "- #{c}"}.join("\n") + "\n\n" +
|
|
119
|
+
overlapping_cookbooks.sort.map { |c| "- #{c}" }.join("\n") + "\n\n" +
|
|
120
120
|
resolution_message(overlapping_cookbooks)
|
|
121
121
|
end
|
|
122
122
|
conflicting_cookbook_sets.join("\n")
|
data/lib/chef-dk/generator.rb
CHANGED
|
@@ -49,7 +49,7 @@ module ChefDK
|
|
|
49
49
|
@context ||= Context.new
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
def self.add_attr_to_context(name, value=nil)
|
|
52
|
+
def self.add_attr_to_context(name, value = nil)
|
|
53
53
|
sym_name = name.to_sym
|
|
54
54
|
ChefDK::Generator::Context.add_attr(sym_name)
|
|
55
55
|
ChefDK::Generator::TemplateHelper.delegate_to_app_context(sym_name)
|
|
@@ -70,11 +70,11 @@ module ChefDK
|
|
|
70
70
|
|
|
71
71
|
# Prints the short description of the license, suitable for use in a
|
|
72
72
|
# preamble to a file. Optionally specify a comment to prepend to each line.
|
|
73
|
-
def license_description(comment=nil)
|
|
73
|
+
def license_description(comment = nil)
|
|
74
74
|
case license
|
|
75
|
-
when
|
|
75
|
+
when "all_rights", "none"
|
|
76
76
|
result = "Copyright:: #{year}, #{copyright_holder}, All Rights Reserved."
|
|
77
|
-
when
|
|
77
|
+
when "apachev2"
|
|
78
78
|
result = <<-EOH
|
|
79
79
|
Copyright:: #{year}, #{copyright_holder}
|
|
80
80
|
|
|
@@ -90,7 +90,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
90
90
|
See the License for the specific language governing permissions and
|
|
91
91
|
limitations under the License.
|
|
92
92
|
EOH
|
|
93
|
-
when
|
|
93
|
+
when "mit"
|
|
94
94
|
result = <<-EOH
|
|
95
95
|
The MIT License (MIT)
|
|
96
96
|
|
|
@@ -114,7 +114,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
114
114
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
115
115
|
THE SOFTWARE.
|
|
116
116
|
EOH
|
|
117
|
-
when
|
|
117
|
+
when "gplv2"
|
|
118
118
|
result = <<-EOH
|
|
119
119
|
Copyright:: #{year}, #{copyright_holder}
|
|
120
120
|
|
|
@@ -132,7 +132,7 @@ You should have received a copy of the GNU General Public License along
|
|
|
132
132
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
133
133
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
134
134
|
EOH
|
|
135
|
-
when
|
|
135
|
+
when "gplv3"
|
|
136
136
|
result = <<-EOH
|
|
137
137
|
Copyright:: #{year}, #{copyright_holder}
|
|
138
138
|
|
|
@@ -149,6 +149,8 @@ GNU General Public License for more details.
|
|
|
149
149
|
You should have received a copy of the GNU General Public License
|
|
150
150
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
151
151
|
EOH
|
|
152
|
+
else
|
|
153
|
+
raise ArgumentError, "Invalid generator.license setting: #{license}. See available licenses at https://docs.chef.io/ctl_chef.html#chef-generate-cookbook"
|
|
152
154
|
end
|
|
153
155
|
if comment
|
|
154
156
|
# Ensure there's no trailing whitespace
|
data/lib/chef-dk/helpers.rb
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require
|
|
19
|
-
require
|
|
18
|
+
require "mixlib/shellout"
|
|
19
|
+
require "chef-dk/exceptions"
|
|
20
20
|
|
|
21
21
|
module ChefDK
|
|
22
22
|
module Helpers
|
|
@@ -72,14 +72,14 @@ module ChefDK
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def omnibus_chefdk_location
|
|
75
|
-
@omnibus_chefdk_location ||= File.expand_path(
|
|
75
|
+
@omnibus_chefdk_location ||= File.expand_path("embedded/apps/chef-dk", expected_omnibus_root)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
def chefdk_home
|
|
79
79
|
@chefdk_home ||= begin
|
|
80
|
-
chefdk_home_set = !([nil,
|
|
80
|
+
chefdk_home_set = !([nil, ""].include? ENV["CHEFDK_HOME"])
|
|
81
81
|
if chefdk_home_set
|
|
82
|
-
ENV[
|
|
82
|
+
ENV["CHEFDK_HOME"]
|
|
83
83
|
else
|
|
84
84
|
default_chefdk_home
|
|
85
85
|
end
|
|
@@ -119,15 +119,15 @@ module ChefDK
|
|
|
119
119
|
def omnibus_env
|
|
120
120
|
@omnibus_env ||=
|
|
121
121
|
begin
|
|
122
|
-
user_bin_dir = File.expand_path(File.join(Gem.user_dir,
|
|
123
|
-
path = [ omnibus_bin_dir, user_bin_dir, omnibus_embedded_bin_dir, ENV[
|
|
122
|
+
user_bin_dir = File.expand_path(File.join(Gem.user_dir, "bin"))
|
|
123
|
+
path = [ omnibus_bin_dir, user_bin_dir, omnibus_embedded_bin_dir, ENV["PATH"] ]
|
|
124
124
|
path << git_bin_dir if Dir.exists?(git_bin_dir)
|
|
125
125
|
path << git_windows_bin_dir if Dir.exists?(git_windows_bin_dir)
|
|
126
126
|
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
127
|
+
"PATH" => path.join(File::PATH_SEPARATOR),
|
|
128
|
+
"GEM_ROOT" => Gem.default_dir,
|
|
129
|
+
"GEM_HOME" => Gem.user_dir,
|
|
130
|
+
"GEM_PATH" => Gem.path.join(File::PATH_SEPARATOR),
|
|
131
131
|
}
|
|
132
132
|
end
|
|
133
133
|
end
|
|
@@ -136,7 +136,7 @@ module ChefDK
|
|
|
136
136
|
|
|
137
137
|
def omnibus_expand_path(*paths)
|
|
138
138
|
dir = File.expand_path(File.join(paths))
|
|
139
|
-
raise OmnibusInstallNotFound.new() unless
|
|
139
|
+
raise OmnibusInstallNotFound.new() unless dir && File.directory?(dir)
|
|
140
140
|
dir
|
|
141
141
|
end
|
|
142
142
|
|
|
@@ -146,16 +146,16 @@ module ChefDK
|
|
|
146
146
|
|
|
147
147
|
def default_chefdk_home
|
|
148
148
|
if Chef::Platform.windows?
|
|
149
|
-
File.join(ENV[
|
|
149
|
+
File.join(ENV["LOCALAPPDATA"], "chefdk")
|
|
150
150
|
else
|
|
151
|
-
File.expand_path(
|
|
151
|
+
File.expand_path("~/.chefdk")
|
|
152
152
|
end
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
# Open a file. By default, the mode is for read+write,
|
|
156
156
|
# and binary so that windows writes out what we tell it,
|
|
157
157
|
# as this is the most common case we have.
|
|
158
|
-
def with_file(path, mode=
|
|
158
|
+
def with_file(path, mode = "wb+", &block)
|
|
159
159
|
File.open(path, mode, &block)
|
|
160
160
|
end
|
|
161
161
|
|
data/lib/chef-dk/pager.rb
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require
|
|
18
|
+
require "chef-dk/ui"
|
|
19
19
|
|
|
20
20
|
module ChefDK
|
|
21
21
|
class Pager
|
|
@@ -98,9 +98,8 @@ module ChefDK
|
|
|
98
98
|
end
|
|
99
99
|
|
|
100
100
|
def pager_env
|
|
101
|
-
{"LESS" => "-FRX", "LV" => "-c"}
|
|
101
|
+
{ "LESS" => "-FRX", "LV" => "-c" }
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
|
-
|
|
@@ -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/exceptions"
|
|
19
|
+
require "chef/cookbook_loader"
|
|
20
|
+
require "chef/cookbook/file_system_file_vendor"
|
|
21
|
+
require "chef-dk/ui"
|
|
22
22
|
|
|
23
23
|
module ChefDK
|
|
24
24
|
module Policyfile
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require
|
|
19
|
-
require
|
|
20
|
-
require
|
|
21
|
-
require
|
|
18
|
+
require "ffi_yajl"
|
|
19
|
+
require "chef-dk/exceptions"
|
|
20
|
+
require "chef-dk/policyfile/source_uri"
|
|
21
|
+
require "chef-dk/authenticated_http"
|
|
22
22
|
|
|
23
23
|
module ChefDK
|
|
24
24
|
module Policyfile
|
|
@@ -67,7 +67,7 @@ module ChefDK
|
|
|
67
67
|
{
|
|
68
68
|
chef_server: uri.to_s,
|
|
69
69
|
version: cookbook_version,
|
|
70
|
-
http_client: http_connection_for(uri.to_s)
|
|
70
|
+
http_client: http_connection_for(uri.to_s),
|
|
71
71
|
}
|
|
72
72
|
end
|
|
73
73
|
|
|
@@ -90,7 +90,7 @@ module ChefDK
|
|
|
90
90
|
def full_chef_server_graph
|
|
91
91
|
@full_chef_server_graph ||=
|
|
92
92
|
begin
|
|
93
|
-
http_connection_for(uri.to_s).get(
|
|
93
|
+
http_connection_for(uri.to_s).get("/universe")
|
|
94
94
|
end
|
|
95
95
|
end
|
|
96
96
|
end
|
|
@@ -15,10 +15,10 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require
|
|
19
|
-
require
|
|
20
|
-
require
|
|
21
|
-
require
|
|
18
|
+
require "json"
|
|
19
|
+
require "chef-dk/cookbook_omnifetch"
|
|
20
|
+
require "chef-dk/exceptions"
|
|
21
|
+
require "chef/http/simple"
|
|
22
22
|
|
|
23
23
|
module ChefDK
|
|
24
24
|
module Policyfile
|
|
@@ -82,7 +82,6 @@ module ChefDK
|
|
|
82
82
|
@http_connections[base_url] ||= Chef::HTTP::Simple.new(base_url)
|
|
83
83
|
end
|
|
84
84
|
|
|
85
|
-
|
|
86
85
|
def full_community_graph
|
|
87
86
|
@full_community_graph ||=
|
|
88
87
|
begin
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require
|
|
19
|
-
require
|
|
20
|
-
require
|
|
18
|
+
require "ffi_yajl"
|
|
19
|
+
require "mixlib/shellout"
|
|
20
|
+
require "chef-dk/service_exceptions"
|
|
21
21
|
|
|
22
22
|
module ChefDK
|
|
23
23
|
module Policyfile
|
|
@@ -121,4 +121,3 @@ module ChefDK
|
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
123
|
end
|
|
124
|
-
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require
|
|
19
|
-
require
|
|
20
|
-
require
|
|
18
|
+
require "semverse"
|
|
19
|
+
require "chef-dk/cookbook_omnifetch"
|
|
20
|
+
require "chef-dk/policyfile/storage_config"
|
|
21
21
|
|
|
22
22
|
module ChefDK
|
|
23
23
|
module Policyfile
|
|
@@ -54,9 +54,9 @@ module ChefDK
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def ==(other)
|
|
57
|
-
other.kind_of?(self.class)
|
|
58
|
-
other.name == name
|
|
59
|
-
other.version_constraint == version_constraint
|
|
57
|
+
other.kind_of?(self.class) &&
|
|
58
|
+
other.name == name &&
|
|
59
|
+
other.version_constraint == version_constraint &&
|
|
60
60
|
other.source_options == source_options
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require
|
|
18
|
+
require "forwardable"
|
|
19
19
|
|
|
20
|
-
require
|
|
20
|
+
require "chef-dk/exceptions"
|
|
21
21
|
|
|
22
|
-
require
|
|
23
|
-
require
|
|
22
|
+
require "chef-dk/cookbook_profiler/null_scm"
|
|
23
|
+
require "chef-dk/cookbook_profiler/git"
|
|
24
24
|
|
|
25
|
-
require
|
|
26
|
-
require
|
|
25
|
+
require "chef-dk/cookbook_profiler/identifiers"
|
|
26
|
+
require "chef-dk/policyfile/storage_config"
|
|
27
27
|
|
|
28
|
-
require
|
|
28
|
+
require "chef-dk/policyfile/cookbook_location_specification"
|
|
29
29
|
|
|
30
30
|
module ChefDK
|
|
31
31
|
|
|
@@ -164,7 +164,7 @@ module ChefDK
|
|
|
164
164
|
private
|
|
165
165
|
|
|
166
166
|
def assert_required_keys_valid!(lock_data)
|
|
167
|
-
missing_keys = REQUIRED_LOCK_DATA_KEYS.reject {|key| lock_data.key?(key) }
|
|
167
|
+
missing_keys = REQUIRED_LOCK_DATA_KEYS.reject { |key| lock_data.key?(key) }
|
|
168
168
|
unless missing_keys.empty?
|
|
169
169
|
raise InvalidLockfile, "Lockfile cookbook_lock for #{name} missing required attributes `#{missing_keys.join("', `")}'"
|
|
170
170
|
end
|
|
@@ -241,7 +241,7 @@ module ChefDK
|
|
|
241
241
|
"dotted_decimal_identifier" => dotted_decimal_identifier,
|
|
242
242
|
"cache_key" => cache_key,
|
|
243
243
|
"origin" => origin,
|
|
244
|
-
"source_options" => source_options
|
|
244
|
+
"source_options" => source_options,
|
|
245
245
|
}
|
|
246
246
|
end
|
|
247
247
|
|
|
@@ -261,7 +261,7 @@ module ChefDK
|
|
|
261
261
|
# This behavior fits better with the intent of the #validate! method,
|
|
262
262
|
# but we cannot check for modifications there because the user may be
|
|
263
263
|
# setting custom identifiers.
|
|
264
|
-
if @identifier
|
|
264
|
+
if @identifier && identifiers.content_identifier != @identifier
|
|
265
265
|
message = "Cached cookbook `#{name}' (#{version}) has been modified since the lockfile was generated. " +
|
|
266
266
|
"Cached cookbooks cannot be modified. (full path: `#{cookbook_path}')"
|
|
267
267
|
raise CachedCookbookModified, message
|
|
@@ -318,7 +318,7 @@ module ChefDK
|
|
|
318
318
|
"source" => source,
|
|
319
319
|
"cache_key" => nil,
|
|
320
320
|
"scm_info" => scm_info,
|
|
321
|
-
"source_options" => source_options
|
|
321
|
+
"source_options" => source_options,
|
|
322
322
|
}
|
|
323
323
|
end
|
|
324
324
|
|