chef-dk 4.1.7 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/Gemfile.lock +113 -17
- data/lib/chef-dk/builtin_commands.rb +3 -0
- data/lib/chef-dk/cli.rb +3 -1
- data/lib/chef-dk/command/clean_policy_cookbooks.rb +1 -0
- data/lib/chef-dk/command/clean_policy_revisions.rb +1 -0
- data/lib/chef-dk/command/delete_policy.rb +1 -0
- data/lib/chef-dk/command/delete_policy_group.rb +1 -0
- data/lib/chef-dk/command/describe_cookbook.rb +1 -0
- data/lib/chef-dk/command/diff.rb +5 -3
- data/lib/chef-dk/command/env.rb +6 -6
- data/lib/chef-dk/command/export.rb +1 -0
- data/lib/chef-dk/command/generate.rb +1 -0
- data/lib/chef-dk/command/generator_commands/chef_exts/quieter_doc_formatter.rb +2 -4
- data/lib/chef-dk/command/generator_commands/generator_generator.rb +1 -0
- data/lib/chef-dk/command/install.rb +1 -0
- data/lib/chef-dk/command/push.rb +1 -0
- data/lib/chef-dk/command/push_archive.rb +1 -1
- data/lib/chef-dk/command/shell_init.rb +3 -2
- data/lib/chef-dk/command/show_policy.rb +1 -0
- data/lib/chef-dk/command/undelete.rb +1 -0
- data/lib/chef-dk/command/update.rb +1 -0
- data/lib/chef-dk/command/verify.rb +1 -1
- data/lib/chef-dk/component_test.rb +2 -1
- data/lib/chef-dk/configurable.rb +3 -2
- data/lib/chef-dk/cookbook_profiler/null_scm.rb +1 -2
- data/lib/chef-dk/generator.rb +1 -1
- data/lib/chef-dk/helpers.rb +2 -1
- data/lib/chef-dk/policyfile/artifactory_cookbook_source.rb +1 -1
- data/lib/chef-dk/policyfile/attribute_merge_checker.rb +1 -1
- data/lib/chef-dk/policyfile/chef_repo_cookbook_source.rb +1 -1
- data/lib/chef-dk/policyfile/chef_server_cookbook_source.rb +3 -3
- data/lib/chef-dk/policyfile/chef_server_lock_fetcher.rb +5 -5
- data/lib/chef-dk/policyfile/community_cookbook_source.rb +1 -1
- data/lib/chef-dk/policyfile/comparison_base.rb +1 -0
- data/lib/chef-dk/policyfile/cookbook_location_specification.rb +4 -4
- data/lib/chef-dk/policyfile/cookbook_locks.rb +8 -5
- data/lib/chef-dk/policyfile/delivery_supermarket_source.rb +1 -1
- data/lib/chef-dk/policyfile/differ.rb +6 -2
- data/lib/chef-dk/policyfile/dsl.rb +4 -2
- data/lib/chef-dk/policyfile/git_lock_fetcher.rb +2 -2
- data/lib/chef-dk/policyfile/included_policies_cookbook_source.rb +1 -1
- data/lib/chef-dk/policyfile/lister.rb +2 -2
- data/lib/chef-dk/policyfile/local_lock_fetcher.rb +7 -5
- data/lib/chef-dk/policyfile/lock_applier.rb +1 -1
- data/lib/chef-dk/policyfile/null_cookbook_source.rb +1 -2
- data/lib/chef-dk/policyfile/policyfile_location_specification.rb +3 -3
- data/lib/chef-dk/policyfile/remote_lock_fetcher.rb +1 -1
- data/lib/chef-dk/policyfile/solution_dependencies.rb +13 -11
- data/lib/chef-dk/policyfile/storage_config.rb +1 -0
- data/lib/chef-dk/policyfile/undo_record.rb +10 -8
- data/lib/chef-dk/policyfile/uploader.rb +3 -1
- data/lib/chef-dk/policyfile_compiler.rb +17 -13
- data/lib/chef-dk/policyfile_lock.rb +17 -15
- data/lib/chef-dk/policyfile_services/clean_policies.rb +3 -3
- data/lib/chef-dk/policyfile_services/clean_policy_cookbooks.rb +2 -2
- data/lib/chef-dk/policyfile_services/export_repo.rb +4 -2
- data/lib/chef-dk/policyfile_services/install.rb +3 -1
- data/lib/chef-dk/policyfile_services/push.rb +6 -5
- data/lib/chef-dk/policyfile_services/push_archive.rb +6 -5
- data/lib/chef-dk/policyfile_services/rm_policy.rb +6 -2
- data/lib/chef-dk/policyfile_services/rm_policy_group.rb +2 -2
- data/lib/chef-dk/policyfile_services/show_policy.rb +2 -2
- data/lib/chef-dk/policyfile_services/undelete.rb +2 -2
- data/lib/chef-dk/version.rb +1 -1
- data/lib/kitchen/provisioner/policyfile_zero.rb +3 -6
- data/spec/unit/cli_spec.rb +6 -6
- data/spec/unit/command/base_spec.rb +1 -1
- data/spec/unit/command/env_spec.rb +1 -1
- data/spec/unit/command/exec_spec.rb +1 -1
- data/spec/unit/command/export_spec.rb +1 -1
- data/spec/unit/command/generator_commands/recipe_spec.rb +2 -1
- data/spec/unit/command/generator_commands/repo_spec.rb +6 -6
- data/spec/unit/command/verify_spec.rb +1 -1
- data/spec/unit/policyfile/attribute_merge_checker_spec.rb +10 -8
- data/spec/unit/policyfile/chef_server_lock_fetcher_spec.rb +4 -2
- data/spec/unit/policyfile/cookbook_locks_spec.rb +9 -9
- data/spec/unit/policyfile/git_lock_fetcher_spec.rb +5 -5
- data/spec/unit/policyfile/included_policies_cookbook_source_spec.rb +5 -3
- data/spec/unit/policyfile/lister_spec.rb +5 -5
- data/spec/unit/policyfile/local_lock_fetcher_spec.rb +1 -1
- data/spec/unit/policyfile/lock_applier_spec.rb +2 -2
- data/spec/unit/policyfile/reports/install_spec.rb +14 -14
- data/spec/unit/policyfile/reports/upload_spec.rb +3 -3
- data/spec/unit/policyfile/uploader_spec.rb +13 -12
- data/spec/unit/policyfile_demands_spec.rb +4 -4
- data/spec/unit/policyfile_includes_spec.rb +14 -7
- data/spec/unit/policyfile_install_with_includes_spec.rb +8 -7
- data/spec/unit/policyfile_lock_build_spec.rb +17 -18
- data/spec/unit/policyfile_services/clean_policy_cookbooks_spec.rb +5 -5
- data/spec/unit/policyfile_services/push_archive_spec.rb +6 -6
- data/spec/unit/policyfile_services/push_spec.rb +8 -8
- data/spec/unit/policyfile_services/rm_policy_group_spec.rb +5 -5
- data/spec/unit/policyfile_services/rm_policy_spec.rb +5 -5
- data/spec/unit/policyfile_services/update_attributes_spec.rb +2 -1
- data/spec/unit/service_exception_inspectors/http_spec.rb +7 -7
- metadata +2 -2
@@ -28,11 +28,9 @@ module ChefDK
|
|
28
28
|
cli_name(:chefdk_doc)
|
29
29
|
|
30
30
|
# Called when starting to collect gems from the cookbooks
|
31
|
-
def cookbook_gem_start(gems)
|
32
|
-
end
|
31
|
+
def cookbook_gem_start(gems); end
|
33
32
|
|
34
33
|
# Called when cookbook loading starts.
|
35
|
-
def library_load_start(file_count)
|
36
|
-
end
|
34
|
+
def library_load_start(file_count); end
|
37
35
|
end
|
38
36
|
end
|
@@ -71,6 +71,7 @@ module ChefDK
|
|
71
71
|
|
72
72
|
def run(params = [])
|
73
73
|
return 1 unless apply_params!(params)
|
74
|
+
|
74
75
|
# Force config file to be loaded. We don't use the configuration
|
75
76
|
# directly, but the user may have SSL configuration options that they
|
76
77
|
# need to talk to a private supermarket (e.g., trusted_certs or
|
data/lib/chef-dk/command/push.rb
CHANGED
@@ -95,7 +95,7 @@ module ChefDK
|
|
95
95
|
return 1
|
96
96
|
elsif !SUPPORTED_SHELLS.include?(shell_name)
|
97
97
|
err("Shell `#{shell_name}' is not currently supported")
|
98
|
-
err("Supported shells are: #{SUPPORTED_SHELLS.join(
|
98
|
+
err("Supported shells are: #{SUPPORTED_SHELLS.join(" ")}")
|
99
99
|
return 1
|
100
100
|
end
|
101
101
|
|
@@ -116,6 +116,7 @@ module ChefDK
|
|
116
116
|
|
117
117
|
def completion_for(shell)
|
118
118
|
return "" unless (completion_template_basename = completion_template_for(shell))
|
119
|
+
|
119
120
|
completion_template_path = expand_completion_template_path(completion_template_basename)
|
120
121
|
erb = ERB.new(File.read(completion_template_path), nil, "-")
|
121
122
|
context_binding = shell_completion_template_context.get_binding
|
@@ -165,7 +166,7 @@ module ChefDK
|
|
165
166
|
# /dev/null to avoid Fish's helpful warnings about nonexistent
|
166
167
|
# PATH elements.
|
167
168
|
if var == "PATH"
|
168
|
-
emit_shell_cmd(%Q{set -gx #{var} "#{val.split(
|
169
|
+
emit_shell_cmd(%Q{set -gx #{var} "#{val.split(":").join('" "')}" 2>/dev/null;})
|
169
170
|
else
|
170
171
|
emit_shell_cmd(%Q{set -gx #{var} "#{val}";})
|
171
172
|
end
|
@@ -71,7 +71,7 @@ module ChefDK
|
|
71
71
|
bundle_install_mutex = Mutex.new
|
72
72
|
|
73
73
|
#
|
74
|
-
# Components included in
|
74
|
+
# Components included in ChefDK:
|
75
75
|
# :base_dir => Relative path of the component w.r.t. omnibus_apps_dir
|
76
76
|
# :gem_base_dir => Takes a gem name instead and uses first gem found
|
77
77
|
# :test_cmd => Test command to be launched for the component
|
@@ -125,7 +125,7 @@ module ChefDK
|
|
125
125
|
# the return value of the test block. For tests that run a lot of commands,
|
126
126
|
# this is inconvenient so you can use #sh! instead.
|
127
127
|
def sh!(*args)
|
128
|
-
sh(*args).tap
|
128
|
+
sh(*args).tap(&:error!)
|
129
129
|
end
|
130
130
|
|
131
131
|
# Run a command, if the command returns zero, raise an error,
|
@@ -197,6 +197,7 @@ module ChefDK
|
|
197
197
|
|
198
198
|
def gem_base_dir
|
199
199
|
return nil if @gem_name_for_base_dir.nil?
|
200
|
+
|
200
201
|
# There is no way to say "give me the latest prerelease OR normal version of this gem.
|
201
202
|
# So we first ask if there is a normal version, and if there is not, we ask if there
|
202
203
|
# is a prerelease version. ">= 0.a" is how we ask for a prerelease version, because a
|
data/lib/chef-dk/configurable.rb
CHANGED
@@ -49,6 +49,7 @@ module ChefDK
|
|
49
49
|
|
50
50
|
def chef_config
|
51
51
|
return @chef_config if @chef_config
|
52
|
+
|
52
53
|
config_loader.load
|
53
54
|
@chef_config = Chef::Config
|
54
55
|
CookbookOmnifetch.integration.default_chef_server_http_client = default_chef_server_http_client
|
@@ -79,8 +80,8 @@ module ChefDK
|
|
79
80
|
def default_chef_server_http_client
|
80
81
|
lambda do
|
81
82
|
ChefServerAPIMulti.new(@chef_config.chef_server_url,
|
82
|
-
|
83
|
-
|
83
|
+
signing_key_filename: @chef_config.client_key,
|
84
|
+
client_name: @chef_config.node_name)
|
84
85
|
end
|
85
86
|
end
|
86
87
|
|
data/lib/chef-dk/generator.rb
CHANGED
data/lib/chef-dk/helpers.rb
CHANGED
@@ -136,7 +136,8 @@ module ChefDK
|
|
136
136
|
|
137
137
|
def omnibus_expand_path(*paths)
|
138
138
|
dir = File.expand_path(File.join(paths))
|
139
|
-
raise OmnibusInstallNotFound.new
|
139
|
+
raise OmnibusInstallNotFound.new unless dir && File.directory?(dir)
|
140
|
+
|
140
141
|
dir
|
141
142
|
end
|
142
143
|
|
@@ -42,7 +42,7 @@ module ChefDK
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def ==(other)
|
45
|
-
other.
|
45
|
+
other.is_a?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
|
46
46
|
end
|
47
47
|
|
48
48
|
def preferred_for(*cookbook_names)
|
@@ -54,7 +54,7 @@ module ChefDK
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def ==(other)
|
57
|
-
other.
|
57
|
+
other.is_a?(self.class) && other.path == path && other.preferred_cookbooks == preferred_cookbooks
|
58
58
|
end
|
59
59
|
|
60
60
|
# Calls the slurp_metadata! helper once to calculate the @universe_graph
|
@@ -40,7 +40,7 @@ module ChefDK
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def ==(other)
|
43
|
-
other.
|
43
|
+
other.is_a?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
|
44
44
|
end
|
45
45
|
|
46
46
|
def preferred_for(*cookbook_names)
|
@@ -84,8 +84,8 @@ module ChefDK
|
|
84
84
|
def http_connection_for(base_url)
|
85
85
|
@http_connections[base_url] ||=
|
86
86
|
ChefServerAPIMulti.new(base_url,
|
87
|
-
|
88
|
-
|
87
|
+
signing_key_filename: chef_config.client_key,
|
88
|
+
client_name: chef_config.node_name)
|
89
89
|
end
|
90
90
|
|
91
91
|
def full_chef_server_graph
|
@@ -73,11 +73,11 @@ module ChefDK
|
|
73
73
|
def errors
|
74
74
|
error_messages = []
|
75
75
|
|
76
|
-
|
76
|
+
%i{server policy_name}.each do |key|
|
77
77
|
error_messages << "include_policy for #{name} is missing key #{key}" unless source_options[key]
|
78
78
|
end
|
79
79
|
|
80
|
-
if
|
80
|
+
if %i{policy_revision_id policy_group}.all? { |key| source_options[key].nil? }
|
81
81
|
error_messages << "include_policy for #{name} must specify policy_revision_id or policy_group"
|
82
82
|
end
|
83
83
|
|
@@ -101,7 +101,7 @@ module ChefDK
|
|
101
101
|
acc
|
102
102
|
end
|
103
103
|
source_options.merge!(options)
|
104
|
-
raise ChefDK::InvalidLockfile, "Invalid source_options provided from lock data: #{options_from_lock_file.inspect}"
|
104
|
+
raise ChefDK::InvalidLockfile, "Invalid source_options provided from lock data: #{options_from_lock_file.inspect}" unless valid?
|
105
105
|
end
|
106
106
|
|
107
107
|
# @return [String] of the policyfile lock data
|
@@ -158,8 +158,8 @@ module ChefDK
|
|
158
158
|
# @return [Hash] Returns a parsed JSON object... I think.
|
159
159
|
def http_client
|
160
160
|
@http_client ||= Chef::ServerAPI.new(source_options[:server],
|
161
|
-
|
162
|
-
|
161
|
+
signing_key_filename: chef_config.client_key,
|
162
|
+
client_name: chef_config.node_name)
|
163
163
|
end
|
164
164
|
|
165
165
|
end
|
@@ -48,7 +48,7 @@ module ChefDK
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def ==(other)
|
51
|
-
other.
|
51
|
+
other.is_a?(self.class) && other.uri == uri && other.preferred_cookbooks == preferred_cookbooks
|
52
52
|
end
|
53
53
|
|
54
54
|
def universe_graph
|
@@ -38,6 +38,7 @@ module ChefDK
|
|
38
38
|
def lock
|
39
39
|
raise LockfileNotFound, "Expected lockfile at #{policyfile_lock_relpath} does not exist" unless File.exist?(policyfile_lock_relpath)
|
40
40
|
raise LockfileNotFound, "Expected lockfile at #{policyfile_lock_relpath} cannot be read" unless File.readable?(policyfile_lock_relpath)
|
41
|
+
|
41
42
|
FFI_Yajl::Parser.parse(IO.read(policyfile_lock_relpath))
|
42
43
|
rescue FFI_Yajl::ParseError => e
|
43
44
|
raise MalformedLockfile, "Invalid JSON in lockfile at #{policyfile_lock_relpath}:\n #{e.message}"
|
@@ -29,7 +29,7 @@ module ChefDK
|
|
29
29
|
# API contract
|
30
30
|
include StorageConfigDelegation
|
31
31
|
|
32
|
-
SOURCE_TYPES =
|
32
|
+
SOURCE_TYPES = %i{git github path artifactserver chef_server chef_server_artifact artifactory}.freeze
|
33
33
|
|
34
34
|
#--
|
35
35
|
# Required by CookbookOmnifetch API contract
|
@@ -54,7 +54,7 @@ module ChefDK
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def ==(other)
|
57
|
-
other.
|
57
|
+
other.is_a?(self.class) &&
|
58
58
|
other.name == name &&
|
59
59
|
other.version_constraint == version_constraint &&
|
60
60
|
other.source_options == source_options
|
@@ -69,7 +69,7 @@ module ChefDK
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def mirrors_canonical_upstream?
|
72
|
-
|
72
|
+
%i{git github artifactserver chef_server chef_server_artifact artifactory}.include?(source_type)
|
73
73
|
end
|
74
74
|
|
75
75
|
def installed?
|
@@ -112,7 +112,7 @@ module ChefDK
|
|
112
112
|
end
|
113
113
|
|
114
114
|
def version_fixed?
|
115
|
-
|
115
|
+
%i{git github path chef_server_artifact}.include?(@source_type)
|
116
116
|
end
|
117
117
|
|
118
118
|
def version
|
@@ -82,6 +82,7 @@ module ChefDK
|
|
82
82
|
def cookbook_location_spec
|
83
83
|
raise InvalidCookbookLockData, "Cannot create CookbookLocationSpecification for #{name} without version" if version.nil?
|
84
84
|
raise InvalidCookbookLockData, "Cannot create CookbookLocationSpecification for #{name} without source options" if source_options.nil?
|
85
|
+
|
85
86
|
@location_spec ||= CookbookLocationSpecification.new(name, "= #{version}", source_options, storage_config)
|
86
87
|
end
|
87
88
|
|
@@ -170,22 +171,22 @@ module ChefDK
|
|
170
171
|
end
|
171
172
|
|
172
173
|
version = lock_data["version"]
|
173
|
-
unless version.
|
174
|
+
unless version.is_a?(String)
|
174
175
|
raise InvalidLockfile, "Lockfile cookbook_lock for #{name} `version' attribute must be a string (got: #{version})"
|
175
176
|
end
|
176
177
|
|
177
178
|
identifier = lock_data["identifier"]
|
178
|
-
unless identifier.
|
179
|
+
unless identifier.is_a?(String)
|
179
180
|
raise InvalidLockfile, "Lockfile cookbook_lock for #{name} `identifier' attribute must be a string (got: #{identifier})"
|
180
181
|
end
|
181
182
|
|
182
183
|
cache_key = lock_data["cache_key"]
|
183
|
-
unless cache_key.
|
184
|
+
unless cache_key.is_a?(String) || cache_key.nil?
|
184
185
|
raise InvalidLockfile, "Lockfile cookbook_lock for #{name} `cache_key' attribute must be a string (got: #{cache_key})"
|
185
186
|
end
|
186
187
|
|
187
188
|
source_options = lock_data["source_options"]
|
188
|
-
unless source_options.
|
189
|
+
unless source_options.is_a?(Hash)
|
189
190
|
raise InvalidLockfile, "Lockfile cookbook_lock for #{name} `source_options' attribute must be a Hash (JSON object) (got: #{source_options})"
|
190
191
|
end
|
191
192
|
end
|
@@ -220,6 +221,7 @@ module ChefDK
|
|
220
221
|
if cache_key.nil?
|
221
222
|
raise MissingCookbookLockData, "Cannot locate cached cookbook `#{name}' because the `cache_key' attribute is not set"
|
222
223
|
end
|
224
|
+
|
223
225
|
File.join(cache_path, cache_key)
|
224
226
|
end
|
225
227
|
|
@@ -340,6 +342,7 @@ module ChefDK
|
|
340
342
|
unless File.exist?(cookbook_path)
|
341
343
|
raise LocalCookbookNotFound, "Cookbook `#{name}' not found at path source `#{source}` (full path: `#{cookbook_path}')"
|
342
344
|
end
|
345
|
+
|
343
346
|
unless cookbook_version.name.to_s == name
|
344
347
|
msg = "The cookbook at path source `#{source}' is expected to be named `#{name}', but is now named `#{cookbook_version.name}' (full path: #{cookbook_path})"
|
345
348
|
raise MalformedCookbook, msg
|
@@ -385,7 +388,7 @@ module ChefDK
|
|
385
388
|
raise InvalidLockfile, "Lockfile cookbook_lock for #{name} is invalid. Lock data for a local cookbook must have a `source' attribute"
|
386
389
|
end
|
387
390
|
|
388
|
-
unless source.
|
391
|
+
unless source.is_a?(String)
|
389
392
|
raise InvalidLockfile, "Lockfile cookbook_lock for #{name} is invalid: `source' attribute must be a String (got: #{source.inspect})"
|
390
393
|
end
|
391
394
|
end
|
@@ -95,6 +95,7 @@ module ChefDK
|
|
95
95
|
|
96
96
|
def report_run_list_changes
|
97
97
|
return nil unless updated_sections.include?("run_list")
|
98
|
+
|
98
99
|
h1("RUN LIST CHANGED")
|
99
100
|
|
100
101
|
old_run_list = old_lock["run_list"]
|
@@ -105,6 +106,7 @@ module ChefDK
|
|
105
106
|
|
106
107
|
def report_removed_cookbooks
|
107
108
|
return nil if removed_cookbooks.empty?
|
109
|
+
|
108
110
|
h1("REMOVED COOKBOOKS")
|
109
111
|
removed_cookbooks.each do |cb_name|
|
110
112
|
ui.print("\n")
|
@@ -117,6 +119,7 @@ module ChefDK
|
|
117
119
|
|
118
120
|
def report_added_cookbooks
|
119
121
|
return nil if added_cookbooks.empty?
|
122
|
+
|
120
123
|
h1("ADDED COOKBOOKS")
|
121
124
|
added_cookbooks.each do |cb_name|
|
122
125
|
ui.print("\n")
|
@@ -129,6 +132,7 @@ module ChefDK
|
|
129
132
|
|
130
133
|
def report_modified_cookbooks
|
131
134
|
return nil if modified_cookbooks.empty?
|
135
|
+
|
132
136
|
h1("MODIFIED COOKBOOKS")
|
133
137
|
modified_cookbooks.each do |cb_name|
|
134
138
|
ui.print("\n")
|
@@ -202,7 +206,7 @@ module ChefDK
|
|
202
206
|
|
203
207
|
maybe_contiguous_hunks = (previous_hunk.nil? || hunk.merge(previous_hunk))
|
204
208
|
|
205
|
-
|
209
|
+
unless maybe_contiguous_hunks
|
206
210
|
print_color_diff("#{previous_hunk.diff(FORMAT)}\n")
|
207
211
|
end
|
208
212
|
previous_hunk = hunk
|
@@ -231,7 +235,7 @@ module ChefDK
|
|
231
235
|
end
|
232
236
|
|
233
237
|
def pretty_json(data)
|
234
|
-
FFI_Yajl::Encoder.encode(data, pretty: true).lines.map
|
238
|
+
FFI_Yajl::Encoder.encode(data, pretty: true).lines.map(&:chomp)
|
235
239
|
end
|
236
240
|
|
237
241
|
def detect_cookbook_changes
|