chef-cli 1.0.3 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/chef-cli.gemspec +2 -2
- data/lib/chef-cli/builtin_commands.rb +3 -0
- data/lib/chef-cli/cli.rb +3 -1
- data/lib/chef-cli/command/clean_policy_cookbooks.rb +1 -0
- data/lib/chef-cli/command/clean_policy_revisions.rb +1 -0
- data/lib/chef-cli/command/delete_policy.rb +1 -0
- data/lib/chef-cli/command/delete_policy_group.rb +1 -0
- data/lib/chef-cli/command/describe_cookbook.rb +1 -0
- data/lib/chef-cli/command/diff.rb +5 -3
- data/lib/chef-cli/command/env.rb +3 -3
- data/lib/chef-cli/command/export.rb +1 -0
- data/lib/chef-cli/command/generate.rb +1 -0
- data/lib/chef-cli/command/generator_commands/chef_exts/quieter_doc_formatter.rb +2 -4
- data/lib/chef-cli/command/generator_commands/generator_generator.rb +1 -0
- data/lib/chef-cli/command/install.rb +1 -0
- data/lib/chef-cli/command/push.rb +1 -0
- data/lib/chef-cli/command/push_archive.rb +1 -1
- data/lib/chef-cli/command/shell_init.rb +3 -2
- data/lib/chef-cli/command/show_policy.rb +1 -0
- data/lib/chef-cli/command/undelete.rb +1 -0
- data/lib/chef-cli/command/update.rb +1 -0
- data/lib/chef-cli/component_test.rb +2 -1
- data/lib/chef-cli/configurable.rb +3 -2
- data/lib/chef-cli/cookbook_profiler/null_scm.rb +1 -2
- data/lib/chef-cli/generator.rb +1 -1
- data/lib/chef-cli/helpers.rb +2 -1
- data/lib/chef-cli/policyfile/artifactory_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/attribute_merge_checker.rb +1 -1
- data/lib/chef-cli/policyfile/chef_repo_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/chef_server_cookbook_source.rb +3 -3
- data/lib/chef-cli/policyfile/chef_server_lock_fetcher.rb +5 -5
- data/lib/chef-cli/policyfile/community_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/comparison_base.rb +1 -0
- data/lib/chef-cli/policyfile/cookbook_location_specification.rb +4 -4
- data/lib/chef-cli/policyfile/cookbook_locks.rb +8 -5
- data/lib/chef-cli/policyfile/delivery_supermarket_source.rb +1 -1
- data/lib/chef-cli/policyfile/differ.rb +6 -2
- data/lib/chef-cli/policyfile/dsl.rb +4 -2
- data/lib/chef-cli/policyfile/git_lock_fetcher.rb +2 -2
- data/lib/chef-cli/policyfile/included_policies_cookbook_source.rb +1 -1
- data/lib/chef-cli/policyfile/lister.rb +2 -2
- data/lib/chef-cli/policyfile/local_lock_fetcher.rb +7 -5
- data/lib/chef-cli/policyfile/lock_applier.rb +1 -1
- data/lib/chef-cli/policyfile/null_cookbook_source.rb +1 -2
- data/lib/chef-cli/policyfile/policyfile_location_specification.rb +3 -3
- data/lib/chef-cli/policyfile/remote_lock_fetcher.rb +1 -1
- data/lib/chef-cli/policyfile/solution_dependencies.rb +13 -11
- data/lib/chef-cli/policyfile/storage_config.rb +1 -0
- data/lib/chef-cli/policyfile/undo_record.rb +10 -8
- data/lib/chef-cli/policyfile/uploader.rb +3 -1
- data/lib/chef-cli/policyfile_compiler.rb +17 -13
- data/lib/chef-cli/policyfile_lock.rb +17 -15
- data/lib/chef-cli/policyfile_services/clean_policies.rb +3 -3
- data/lib/chef-cli/policyfile_services/clean_policy_cookbooks.rb +2 -2
- data/lib/chef-cli/policyfile_services/export_repo.rb +4 -2
- data/lib/chef-cli/policyfile_services/install.rb +3 -1
- data/lib/chef-cli/policyfile_services/push.rb +6 -5
- data/lib/chef-cli/policyfile_services/push_archive.rb +6 -5
- data/lib/chef-cli/policyfile_services/rm_policy.rb +6 -2
- data/lib/chef-cli/policyfile_services/rm_policy_group.rb +2 -2
- data/lib/chef-cli/policyfile_services/show_policy.rb +2 -2
- data/lib/chef-cli/policyfile_services/undelete.rb +2 -2
- data/lib/chef-cli/version.rb +1 -1
- data/lib/kitchen/provisioner/policyfile_zero.rb +3 -6
- data/spec/unit/cli_spec.rb +5 -5
- 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 +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1985081b5bf2886c0caecfd05a999a3b57e772cbac8a9ae359052f555eef721c
|
4
|
+
data.tar.gz: ebe9aa6a7395a044c28e352c019dff6a94ade162c4313ca266f4ce3e24666100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 332b60af49070b9a9450e34d8782c760ccd319f801a45e423a66050af2202071dede00f605181c1c232e0e7bbb1c69f83845baadfb8bfedd37d9139d5705b361
|
7
|
+
data.tar.gz: ae9f8a2ec4a7c6c8f2e34fdc06925f3747cd6f9742d99e130cea3bfc3043186e59a3e8bb55fb018d53a4efee32f128d817c8b742e9babdd91d54e510756ba5ab
|
data/Gemfile
CHANGED
@@ -9,6 +9,10 @@ group :docs do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
group :test do
|
12
|
+
# For ruby 2.4 testing we need to use ohai 14
|
13
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.5")
|
14
|
+
gem "ohai", "~> 14"
|
15
|
+
end
|
12
16
|
gem "rake"
|
13
17
|
gem "rspec", "~> 3.8"
|
14
18
|
gem "rspec-expectations", "~> 3.8"
|
data/chef-cli.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.license = "Apache-2.0"
|
30
30
|
gem.homepage = "https://www.chef.io/"
|
31
31
|
|
32
|
-
gem.required_ruby_version = ">= 2.
|
32
|
+
gem.required_ruby_version = ">= 2.4"
|
33
33
|
|
34
34
|
gem.files = %w{Rakefile LICENSE} +
|
35
35
|
Dir.glob("Gemfile*") + # Includes Gemfile and locks
|
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
|
|
43
43
|
gem.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
|
44
44
|
gem.add_dependency "ffi-yajl", ">= 1.0", "< 3.0"
|
45
45
|
gem.add_dependency "minitar", "~> 0.6"
|
46
|
-
gem.add_dependency "chef", "
|
46
|
+
gem.add_dependency "chef", ">= 14.0"
|
47
47
|
gem.add_dependency "solve", "< 5.0", "> 2.0"
|
48
48
|
gem.add_dependency "addressable", ">= 2.3.5", "< 2.6"
|
49
49
|
gem.add_dependency "cookbook-omnifetch", "~> 0.5"
|
@@ -59,4 +59,7 @@ ChefCLI.commands do |c|
|
|
59
59
|
desc: "Prints cookbook checksum information used for cookbook identifier"
|
60
60
|
|
61
61
|
c.builtin "verify", :Verify, desc: "Test the embedded #{ChefCLI::Dist::PRODUCT} applications", hidden: true
|
62
|
+
|
63
|
+
# deprecated command that throws a failure warning if used. This was removed 4.2019
|
64
|
+
c.builtin "provision", :Provision, desc: "Provision VMs and clusters via cookbook", hidden: true
|
62
65
|
end
|
data/lib/chef-cli/cli.rb
CHANGED
@@ -120,6 +120,7 @@ module ChefCLI
|
|
120
120
|
justify_length = subcommands.map(&:length).max + 2
|
121
121
|
subcommand_specs.each do |name, spec|
|
122
122
|
next if spec.hidden
|
123
|
+
|
123
124
|
msg(" #{"#{name}".ljust(justify_length)}#{spec.description}")
|
124
125
|
end
|
125
126
|
end
|
@@ -155,7 +156,7 @@ module ChefCLI
|
|
155
156
|
private
|
156
157
|
|
157
158
|
def normalized_exit_code(maybe_integer)
|
158
|
-
if maybe_integer.
|
159
|
+
if maybe_integer.is_a?(Integer) && (0..255).cover?(maybe_integer)
|
159
160
|
maybe_integer
|
160
161
|
else
|
161
162
|
0
|
@@ -186,6 +187,7 @@ module ChefCLI
|
|
186
187
|
def sanity_check!
|
187
188
|
# When installed outside of omnibus, trust the user to configure their PATH
|
188
189
|
return true unless omnibus_install?
|
190
|
+
|
189
191
|
paths = env[path_key].split(File::PATH_SEPARATOR)
|
190
192
|
paths.map! { |p| drive_upcase(Chef::Util::PathHelper.cleanpath(p)) }
|
191
193
|
embed_index = paths.index(drive_upcase(Chef::Util::PathHelper.cleanpath(omnibus_embedded_bin_dir)))
|
@@ -125,6 +125,7 @@ module ChefCLI
|
|
125
125
|
|
126
126
|
def run(params = [])
|
127
127
|
return 1 unless apply_params!(params)
|
128
|
+
|
128
129
|
print_diff
|
129
130
|
0
|
130
131
|
rescue PolicyfileServiceError => e
|
@@ -153,7 +154,7 @@ module ChefCLI
|
|
153
154
|
end
|
154
155
|
end
|
155
156
|
|
156
|
-
def differ(ui = self.ui
|
157
|
+
def differ(ui = self.ui)
|
157
158
|
Policyfile::Differ.new(old_name: old_base.name,
|
158
159
|
old_lock: old_lock,
|
159
160
|
new_name: new_base.name,
|
@@ -163,8 +164,8 @@ module ChefCLI
|
|
163
164
|
|
164
165
|
def http_client
|
165
166
|
@http_client ||= Chef::ServerAPI.new(chef_config.chef_server_url,
|
166
|
-
|
167
|
-
|
167
|
+
signing_key_filename: chef_config.client_key,
|
168
|
+
client_name: chef_config.node_name)
|
168
169
|
end
|
169
170
|
|
170
171
|
def old_lock
|
@@ -290,6 +291,7 @@ module ChefCLI
|
|
290
291
|
def policy_group_comparison?(args)
|
291
292
|
return false if args.empty?
|
292
293
|
return true if args.size > 1
|
294
|
+
|
293
295
|
!(args.first =~ /\.rb\Z/)
|
294
296
|
end
|
295
297
|
|
data/lib/chef-cli/command/env.rb
CHANGED
@@ -57,10 +57,10 @@ module ChefCLI
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def ruby_info
|
60
|
-
|
60
|
+
{}.tap do |ruby|
|
61
61
|
ruby["Executable"] = Gem.ruby
|
62
62
|
ruby["Version"] = RUBY_VERSION
|
63
|
-
ruby["RubyGems"] =
|
63
|
+
ruby["RubyGems"] = {}.tap do |rubygems|
|
64
64
|
rubygems["RubyGems Version"] = Gem::VERSION
|
65
65
|
rubygems["RubyGems Platforms"] = Gem.platforms.map(&:to_s)
|
66
66
|
rubygems["Gem Environment"] = gem_environment
|
@@ -88,7 +88,7 @@ module ChefCLI
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def policyfile_config
|
91
|
-
|
91
|
+
{}.tap do |h|
|
92
92
|
h["Cache Path"] = CookbookOmnifetch.cache_path
|
93
93
|
h["Storage Path"] = CookbookOmnifetch.storage_path.to_s
|
94
94
|
end
|
@@ -28,11 +28,9 @@ module ChefCLI
|
|
28
28
|
cli_name(:chefcli_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 ChefCLI
|
|
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
|
@@ -96,7 +96,7 @@ module ChefCLI
|
|
96
96
|
return 1
|
97
97
|
elsif !SUPPORTED_SHELLS.include?(shell_name)
|
98
98
|
err("Shell `#{shell_name}' is not currently supported")
|
99
|
-
err("Supported shells are: #{SUPPORTED_SHELLS.join(
|
99
|
+
err("Supported shells are: #{SUPPORTED_SHELLS.join(" ")}")
|
100
100
|
return 1
|
101
101
|
end
|
102
102
|
|
@@ -117,6 +117,7 @@ module ChefCLI
|
|
117
117
|
|
118
118
|
def completion_for(shell)
|
119
119
|
return "" unless (completion_template_basename = completion_template_for(shell))
|
120
|
+
|
120
121
|
completion_template_path = expand_completion_template_path(completion_template_basename)
|
121
122
|
erb = ERB.new(File.read(completion_template_path), nil, "-")
|
122
123
|
context_binding = shell_completion_template_context.get_binding
|
@@ -166,7 +167,7 @@ module ChefCLI
|
|
166
167
|
# /dev/null to avoid Fish's helpful warnings about nonexistent
|
167
168
|
# PATH elements.
|
168
169
|
if var == "PATH"
|
169
|
-
emit_shell_cmd(%Q{set -gx #{var} "#{val.split(
|
170
|
+
emit_shell_cmd(%Q{set -gx #{var} "#{val.split(":").join('" "')}" 2>/dev/null;})
|
170
171
|
else
|
171
172
|
emit_shell_cmd(%Q{set -gx #{var} "#{val}";})
|
172
173
|
end
|
@@ -125,7 +125,7 @@ module ChefCLI
|
|
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 ChefCLI
|
|
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
|
@@ -49,6 +49,7 @@ module ChefCLI
|
|
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 ChefCLI
|
|
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-cli/generator.rb
CHANGED
data/lib/chef-cli/helpers.rb
CHANGED
@@ -130,7 +130,8 @@ module ChefCLI
|
|
130
130
|
|
131
131
|
def omnibus_expand_path(*paths)
|
132
132
|
dir = File.expand_path(File.join(paths))
|
133
|
-
raise OmnibusInstallNotFound.new
|
133
|
+
raise OmnibusInstallNotFound.new unless dir && File.directory?(dir)
|
134
|
+
|
134
135
|
dir
|
135
136
|
end
|
136
137
|
|
@@ -42,7 +42,7 @@ module ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
101
101
|
acc
|
102
102
|
end
|
103
103
|
source_options.merge!(options)
|
104
|
-
raise ChefCLI::InvalidLockfile, "Invalid source_options provided from lock data: #{options_from_lock_file.inspect}"
|
104
|
+
raise ChefCLI::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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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 ChefCLI
|
|
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
|