chef-cli 3.0.22 → 3.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -0
- data/bin/chef-cli +2 -2
- data/chef-cli.gemspec +2 -2
- data/lib/chef-cli/cli.rb +6 -2
- data/lib/chef-cli/command/env.rb +1 -1
- data/lib/chef-cli/command/generator_commands/cookbook.rb +1 -14
- data/lib/chef-cli/cookbook_profiler/identifiers.rb +1 -1
- data/lib/chef-cli/dist.rb +7 -2
- data/lib/chef-cli/generator.rb +1 -1
- data/lib/chef-cli/helpers.rb +1 -1
- data/lib/chef-cli/policyfile/differ.rb +8 -2
- data/lib/chef-cli/policyfile/storage_config.rb +1 -1
- data/lib/chef-cli/policyfile_services/export_repo.rb +1 -1
- data/lib/chef-cli/policyfile_services/install.rb +7 -5
- data/lib/chef-cli/policyfile_services/push_archive.rb +1 -1
- data/lib/chef-cli/version.rb +1 -1
- data/spec/test_helpers.rb +2 -2
- data/spec/unit/cli_spec.rb +4 -1
- data/spec/unit/command/exec_spec.rb +1 -1
- data/spec/unit/fixtures/cookbooks_api/update_fixtures.rb +4 -7
- data/spec/unit/policyfile/differ_spec.rb +1 -1
- data/spec/unit/policyfile/storage_config_spec.rb +2 -2
- data/spec/unit/policyfile_services/install_spec.rb +20 -0
- data/spec/unit/service_exception_inspectors/http_spec.rb +1 -1
- metadata +13 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85e388b9fab9f43a073f194f4c3c6c9378c8a9adbed5ff72110f2c9a595902b7
|
4
|
+
data.tar.gz: eb70e257bc469e1e5fe45f8d35cbc1b1ae70d3906753c566d9d022cfc8733bc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8df4c043504a3671210ea15bb0109f4a1f8dc9929e9e86665f227b82e8425d35196e0cd9143c1842549f9cea3efe2bd6248a8c6d14b98abc2fd0825983559e9
|
7
|
+
data.tar.gz: 235eeafdd090fe44cb78ad741e55797d19da15acdf853d9877f0b164fdc782f21e75e3f523cd4f5e1c6810e4b256185c087c5e22644843c8a0cb667fe8692c32
|
data/Gemfile
CHANGED
data/bin/chef-cli
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
-
# Copyright:: Copyright (c)
|
3
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -19,7 +19,7 @@
|
|
19
19
|
# Set a trap for ctrl-C right away so we don't surface interrupt exceptions inside of rubygems or whatever.
|
20
20
|
Kernel.trap(:INT) { print("\n"); exit 1 }
|
21
21
|
|
22
|
-
$:.unshift(File.expand_path(File.join(
|
22
|
+
$:.unshift(File.expand_path(File.join(__dir__, "..", "lib")))
|
23
23
|
require "chef-cli/cli"
|
24
24
|
|
25
25
|
ChefCLI::CLI.new(ARGV.clone).run(enforce_license: true)
|
data/chef-cli.gemspec
CHANGED
@@ -48,6 +48,6 @@ Gem::Specification.new do |gem|
|
|
48
48
|
gem.add_dependency "addressable", ">= 2.3.5", "< 2.8"
|
49
49
|
gem.add_dependency "cookbook-omnifetch", "~> 0.5"
|
50
50
|
gem.add_dependency "diff-lcs", ">= 1.0", "< 1.4" # 1.4 changes the output
|
51
|
-
gem.add_dependency "
|
52
|
-
gem.add_dependency "license-acceptance", "
|
51
|
+
gem.add_dependency "pastel", "~> 0.7" # used for policyfile differ
|
52
|
+
gem.add_dependency "license-acceptance", ">= 1.0.11", "< 3"
|
53
53
|
end
|
data/lib/chef-cli/cli.rb
CHANGED
@@ -33,6 +33,10 @@ module ChefCLI
|
|
33
33
|
include Chef::Mixin::ShellOut
|
34
34
|
|
35
35
|
banner(<<~BANNER)
|
36
|
+
#{ChefCLI::Dist::WORKSTATION_HEADER}
|
37
|
+
Docs: #{ChefCLI::Dist::WORKSTATION_DOCS}
|
38
|
+
Patents: #{ChefCLI::Dist::PATENTS}
|
39
|
+
|
36
40
|
Usage:
|
37
41
|
#{ChefCLI::Dist::EXEC} -h/--help
|
38
42
|
#{ChefCLI::Dist::EXEC} -v/--version
|
@@ -119,13 +123,13 @@ module ChefCLI
|
|
119
123
|
|
120
124
|
def show_help
|
121
125
|
msg(banner)
|
122
|
-
msg("
|
126
|
+
msg("Available Commands:")
|
123
127
|
|
124
128
|
justify_length = subcommands.map(&:length).max + 2
|
125
129
|
subcommand_specs.each do |name, spec|
|
126
130
|
next if spec.hidden
|
127
131
|
|
128
|
-
msg(" #{
|
132
|
+
msg(" #{name.to_s.ljust(justify_length)}#{spec.description}")
|
129
133
|
end
|
130
134
|
end
|
131
135
|
|
data/lib/chef-cli/command/env.rb
CHANGED
@@ -197,20 +197,7 @@ module ChefCLI
|
|
197
197
|
# .delivery/cli.toml starting from pwd:
|
198
198
|
# https://github.com/chef/delivery-cli/blob/22cbef3987ebd0aee98405b7e161a100edc87e49/src/delivery/config/mod.rs#L225-L247
|
199
199
|
|
200
|
-
Pathname.
|
201
|
-
return true if contains_delivery_cli_toml?(path)
|
202
|
-
end
|
203
|
-
|
204
|
-
false # nothing was found
|
205
|
-
end
|
206
|
-
|
207
|
-
#
|
208
|
-
# @param [Pathname] path a directory
|
209
|
-
#
|
210
|
-
# @return [Boolean] delivery cli.toml exists
|
211
|
-
#
|
212
|
-
def contains_delivery_cli_toml?(path)
|
213
|
-
path.join(".delivery/cli.toml").exist?
|
200
|
+
Pathname.pwd.ascend.any? { |path| path.join(".delivery/cli.toml").exist? }
|
214
201
|
end
|
215
202
|
|
216
203
|
def read_and_validate_params
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# TODO: Chef should require its dependency correctly.
|
19
19
|
require "singleton" unless defined?(Singleton)
|
20
20
|
require "chef/cookbook/cookbook_version_loader"
|
21
|
-
require "digest/sha1"
|
21
|
+
require "digest/sha1" unless defined?(Digest::SHA1)
|
22
22
|
|
23
23
|
require "chef/digester"
|
24
24
|
|
data/lib/chef-cli/dist.rb
CHANGED
@@ -27,7 +27,6 @@ module ChefCLI
|
|
27
27
|
|
28
28
|
# The name of the server product
|
29
29
|
SERVER_PRODUCT = "Chef Infra Server".freeze
|
30
|
-
|
31
30
|
WORKFLOW = "Chef Workflow (Delivery)".freeze
|
32
31
|
|
33
32
|
# The chef executable, as in `chef gem install` or `chef generate cookbook`
|
@@ -38,7 +37,13 @@ module ChefCLI
|
|
38
37
|
|
39
38
|
HAB_PRODUCT = "Chef Habitat".freeze
|
40
39
|
HAB_SOFTWARE_NAME = "habitat".freeze
|
41
|
-
|
42
40
|
HAB_CLI = "hab".freeze
|
41
|
+
|
42
|
+
# product patents page
|
43
|
+
PATENTS = "https://www.chef.io/patents".freeze
|
44
|
+
|
45
|
+
# Workstation banner/help text
|
46
|
+
WORKSTATION_DOCS = "https://docs.chef.io/workstation/".freeze
|
47
|
+
WORKSTATION_HEADER = "The Chef command line tool for managing your infrastructure from your workstation.".freeze
|
43
48
|
end
|
44
49
|
end
|
data/lib/chef-cli/generator.rb
CHANGED
@@ -154,7 +154,7 @@ module ChefCLI
|
|
154
154
|
end
|
155
155
|
if comment
|
156
156
|
# Ensure there's no trailing whitespace
|
157
|
-
result.gsub(/^(.+)$/, "#{comment} \\1").gsub(/^$/,
|
157
|
+
result.gsub(/^(.+)$/, "#{comment} \\1").gsub(/^$/, comment).strip
|
158
158
|
else
|
159
159
|
result
|
160
160
|
end
|
data/lib/chef-cli/helpers.rb
CHANGED
@@ -141,7 +141,7 @@ module ChefCLI
|
|
141
141
|
|
142
142
|
def default_package_home
|
143
143
|
if Chef::Platform.windows?
|
144
|
-
File.join(ENV["LOCALAPPDATA"],
|
144
|
+
File.join(ENV["LOCALAPPDATA"], ChefCLI::Dist::PRODUCT_PKG_HOME)
|
145
145
|
else
|
146
146
|
File.expand_path("~/.#{ChefCLI::Dist::PRODUCT_PKG_HOME}")
|
147
147
|
end
|
@@ -17,7 +17,7 @@
|
|
17
17
|
|
18
18
|
require "diff/lcs"
|
19
19
|
require "diff/lcs/hunk"
|
20
|
-
require "
|
20
|
+
require "pastel"
|
21
21
|
require "ffi_yajl" unless defined?(FFI_Yajl)
|
22
22
|
|
23
23
|
module ChefCLI
|
@@ -215,9 +215,15 @@ module ChefCLI
|
|
215
215
|
ui.print("\n")
|
216
216
|
end
|
217
217
|
|
218
|
+
def pastel
|
219
|
+
@pastel ||= Pastel.new
|
220
|
+
end
|
221
|
+
|
218
222
|
def print_color_diff(hunk)
|
219
223
|
hunk.to_s.each_line do |line|
|
220
|
-
|
224
|
+
line_color = color_for_line(line)
|
225
|
+
line = pastel.decorate(line, line_color) unless line_color.nil?
|
226
|
+
ui.print(line)
|
221
227
|
end
|
222
228
|
end
|
223
229
|
|
@@ -52,7 +52,7 @@ module ChefCLI
|
|
52
52
|
return use_policyfile_lock(policyfile_filename)
|
53
53
|
end
|
54
54
|
unless policyfile_filename.end_with?(".rb")
|
55
|
-
raise InvalidPolicyfileFilename, "Policyfile filenames must end with `.rb' extension (you gave: `#{policyfile_filename}')"
|
55
|
+
raise InvalidPolicyfileFilename, "Policyfile filenames must end with an `.rb' or `.lock.json' extension (you gave: `#{policyfile_filename}')"
|
56
56
|
end
|
57
57
|
|
58
58
|
@policyfile_filename = policyfile_filename
|
@@ -42,8 +42,8 @@ module ChefCLI
|
|
42
42
|
@overwrite = overwrite
|
43
43
|
@chef_config = config
|
44
44
|
|
45
|
-
policyfile_rel_path = policyfile || "Policyfile.rb"
|
46
|
-
policyfile_full_path = File.expand_path(policyfile_rel_path, root_dir)
|
45
|
+
@policyfile_rel_path = policyfile || "Policyfile.rb"
|
46
|
+
policyfile_full_path = File.expand_path(@policyfile_rel_path, root_dir)
|
47
47
|
@storage_config = Policyfile::StorageConfig.new.use_policyfile(policyfile_full_path)
|
48
48
|
|
49
49
|
@policyfile_content = nil
|
@@ -51,9 +51,11 @@ module ChefCLI
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def run(cookbooks_to_update = [], exclude_deps = false)
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
# TODO: suggest next step. Add a generator/init command? Specify path to Policyfile.rb?
|
55
|
+
# See card CC-232
|
56
|
+
if @policyfile_rel_path.end_with?(".lock.json") && !File.exist?(policyfile_lock_expanded_path)
|
57
|
+
raise PolicyfileNotFound, "Policyfile lock not found at path #{policyfile_lock_expanded_path}"
|
58
|
+
elsif @policyfile_rel_path.end_with?(".rb") && !File.exist?(policyfile_expanded_path)
|
57
59
|
raise PolicyfileNotFound, "Policyfile not found at path #{policyfile_expanded_path}"
|
58
60
|
end
|
59
61
|
|
data/lib/chef-cli/version.rb
CHANGED
data/spec/test_helpers.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright:: Copyright (c)
|
2
|
+
# Copyright:: Copyright (c) Chef Software Inc.
|
3
3
|
# License:: Apache License, Version 2.0
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -35,7 +35,7 @@ module TestHelpers
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def fixtures_path
|
38
|
-
File.expand_path(
|
38
|
+
File.expand_path(__dir__ + "/unit/fixtures/")
|
39
39
|
end
|
40
40
|
|
41
41
|
def project_root
|
data/spec/unit/cli_spec.rb
CHANGED
@@ -41,12 +41,15 @@ describe ChefCLI::CLI do
|
|
41
41
|
|
42
42
|
let(:base_help_message) do
|
43
43
|
<<~E
|
44
|
+
#{ChefCLI::Dist::WORKSTATION_HEADER}
|
45
|
+
Docs: #{ChefCLI::Dist::WORKSTATION_DOCS}
|
46
|
+
Patents: #{ChefCLI::Dist::PATENTS}
|
47
|
+
|
44
48
|
Usage:
|
45
49
|
chef -h/--help
|
46
50
|
chef -v/--version
|
47
51
|
chef command [arguments...] [options...]
|
48
52
|
|
49
|
-
|
50
53
|
Available Commands:
|
51
54
|
gem Runs the `gem` command in context of the embedded ruby
|
52
55
|
example Example subcommand for testing
|
@@ -127,7 +127,7 @@ describe ChefCLI::Command::Exec do
|
|
127
127
|
end
|
128
128
|
|
129
129
|
context "when running a exec with #{switch}" do
|
130
|
-
let(:command_options) { [
|
130
|
+
let(:command_options) { [switch] }
|
131
131
|
|
132
132
|
it "should call not call exec, but it should print the banner" do
|
133
133
|
allow(command_instance).to receive(:msg)
|
@@ -1,14 +1,11 @@
|
|
1
1
|
require "openssl"
|
2
|
-
require "net/
|
2
|
+
require "net/http" unless defined?(Net::HTTP)
|
3
3
|
require "json" unless defined?(JSON)
|
4
|
-
require "pp"
|
5
4
|
require "uri"
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
SMALL_UNIVERSE_JSON_PATH = File.join(THIS_DIR, "small_universe.json")
|
11
|
-
PRUNED_UNIVERSE_PATH = File.join(THIS_DIR, "pruned_small_universe.json")
|
6
|
+
UNIVERSE_JSON_PATH = File.join(__dir__, "universe.json")
|
7
|
+
SMALL_UNIVERSE_JSON_PATH = File.join(__dir__, "small_universe.json")
|
8
|
+
PRUNED_UNIVERSE_PATH = File.join(__dir__, "pruned_small_universe.json")
|
12
9
|
|
13
10
|
COOKBOOKS_IN_SMALL_UNIVERSE = %w{apache2 application apt database mysql nginx postgresql yum}.freeze
|
14
11
|
|
@@ -106,10 +106,10 @@ describe ChefCLI::Policyfile::StorageConfig do
|
|
106
106
|
|
107
107
|
end
|
108
108
|
|
109
|
-
context "when the policyfile file name doesn't have
|
109
|
+
context "when the policyfile file name doesn't have an .rb or .lock.json extension" do
|
110
110
|
|
111
111
|
it "raises an error" do
|
112
|
-
err_string = %q{Policyfile filenames must end with `.rb' extension (you gave: `Policyfile')}
|
112
|
+
err_string = %q{Policyfile filenames must end with an `.rb' or `.lock.json' extension (you gave: `Policyfile')}
|
113
113
|
expect { storage_config.use_policyfile("Policyfile") }.to raise_error(ChefCLI::InvalidPolicyfileFilename, err_string)
|
114
114
|
end
|
115
115
|
|
@@ -77,6 +77,26 @@ describe ChefCLI::PolicyfileServices::Install do
|
|
77
77
|
|
78
78
|
end
|
79
79
|
|
80
|
+
context "When an explicit Policfyfile lock name is given and does not exist" do
|
81
|
+
|
82
|
+
let(:policyfile_rb_explicit_name) { "i_do_not_exist.lock.json" }
|
83
|
+
|
84
|
+
it "errors out" do
|
85
|
+
expect { install_service.run }.to raise_error(ChefCLI::PolicyfileNotFound, "Policyfile lock not found at path #{policyfile_rb_path}")
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
context "When an explicit Policfyfile name is given and does not exist" do
|
91
|
+
|
92
|
+
let(:policyfile_rb_explicit_name) { "i_do_not_exist.rb" }
|
93
|
+
|
94
|
+
it "errors out" do
|
95
|
+
expect { install_service.run }.to raise_error(ChefCLI::PolicyfileNotFound, "Policyfile not found at path #{policyfile_rb_path}")
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
80
100
|
context "when a Policyfile exists" do
|
81
101
|
|
82
102
|
before do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-cli
|
@@ -173,45 +173,39 @@ dependencies:
|
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: '1.4'
|
175
175
|
- !ruby/object:Gem::Dependency
|
176
|
-
name:
|
176
|
+
name: pastel
|
177
177
|
requirement: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
|
-
- - "
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: '1'
|
182
|
-
- - "<"
|
179
|
+
- - "~>"
|
183
180
|
- !ruby/object:Gem::Version
|
184
|
-
version: '
|
181
|
+
version: '0.7'
|
185
182
|
type: :runtime
|
186
183
|
prerelease: false
|
187
184
|
version_requirements: !ruby/object:Gem::Requirement
|
188
185
|
requirements:
|
189
|
-
- - "
|
190
|
-
- !ruby/object:Gem::Version
|
191
|
-
version: '1'
|
192
|
-
- - "<"
|
186
|
+
- - "~>"
|
193
187
|
- !ruby/object:Gem::Version
|
194
|
-
version: '
|
188
|
+
version: '0.7'
|
195
189
|
- !ruby/object:Gem::Dependency
|
196
190
|
name: license-acceptance
|
197
191
|
requirement: !ruby/object:Gem::Requirement
|
198
192
|
requirements:
|
199
|
-
- - "~>"
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '1.0'
|
202
193
|
- - ">="
|
203
194
|
- !ruby/object:Gem::Version
|
204
195
|
version: 1.0.11
|
196
|
+
- - "<"
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '3'
|
205
199
|
type: :runtime
|
206
200
|
prerelease: false
|
207
201
|
version_requirements: !ruby/object:Gem::Requirement
|
208
202
|
requirements:
|
209
|
-
- - "~>"
|
210
|
-
- !ruby/object:Gem::Version
|
211
|
-
version: '1.0'
|
212
203
|
- - ">="
|
213
204
|
- !ruby/object:Gem::Version
|
214
205
|
version: 1.0.11
|
206
|
+
- - "<"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '3'
|
215
209
|
description: A streamlined development and deployment workflow for Chef platform.
|
216
210
|
email:
|
217
211
|
- info@chef.io
|