knife 17.5.22 → 17.9.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/knife.gemspec +0 -1
- data/lib/chef/knife/acl_base.rb +1 -1
- data/lib/chef/knife/acl_bulk_add.rb +1 -1
- data/lib/chef/knife/acl_bulk_remove.rb +1 -1
- data/lib/chef/knife/bootstrap.rb +3 -4
- data/lib/chef/knife/core/gem_glob_loader.rb +1 -1
- data/lib/chef/knife/core/generic_presenter.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +2 -2
- data/lib/chef/knife/org_user_add.rb +1 -1
- data/lib/chef/knife/org_user_remove.rb +2 -2
- data/lib/chef/knife/version.rb +1 -1
- data/spec/integration/delete_spec.rb +1 -1
- data/spec/integration/download_spec.rb +2 -2
- data/spec/integration/upload_spec.rb +5 -6
- data/spec/knife_spec_helper.rb +2 -2
- data/spec/support/platform_helpers.rb +1 -1
- data/spec/unit/knife/bootstrap_spec.rb +10 -10
- data/spec/unit/knife/environment_list_spec.rb +1 -1
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38b44d2b8c6f86ac93d2803ec55b87fc55d63e5de3c3cd167f4495fe54dd1fb0
|
4
|
+
data.tar.gz: aaf3fc0aba59a4d1e38d6df2098053c4b3c12d4f4aca84e62ca1d338717c5fc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc6634edc2cd46990071712a5660883babe15c70d96426b4c32e2a66a885026c5a0fc9a087cd0336944d63f1b3919e5755e903ed83cbd5f0d97c456d6eb35a78
|
7
|
+
data.tar.gz: 935ff218ca8290c8cf384faea1dfc42c19704b993922ad40755067fca5798a7199e8c57fab84ceebd8f7f0645a2c040cb211dc0d36334f5027162233add2877d
|
data/knife.gemspec
CHANGED
@@ -28,7 +28,6 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_dependency "ffi-yajl", "~> 2.2"
|
29
29
|
s.add_dependency "net-ssh", ">= 5.1", "< 7"
|
30
30
|
s.add_dependency "net-ssh-multi", "~> 1.2", ">= 1.2.1"
|
31
|
-
s.add_dependency "ed25519", "~> 1.2" # ed25519 ssh key support
|
32
31
|
s.add_dependency "bcrypt_pbkdf", "~> 1.1" # ed25519 ssh key support
|
33
32
|
# disabling this until we get get it to compile on RHEL 7
|
34
33
|
# s.add_dependency "x25519", ">= 1.0.9" # ed25519 KEX module. 1.0.9+ required to resolve sigill failures
|
data/lib/chef/knife/acl_base.rb
CHANGED
@@ -25,7 +25,7 @@ class Chef
|
|
25
25
|
|
26
26
|
PERM_TYPES = %w{create read update delete grant}.freeze unless defined? PERM_TYPES
|
27
27
|
MEMBER_TYPES = %w{client group user}.freeze unless defined? MEMBER_TYPES
|
28
|
-
OBJECT_TYPES = %w{clients containers cookbooks data environments groups nodes roles policies policy_groups}.freeze unless defined? OBJECT_TYPES
|
28
|
+
OBJECT_TYPES = %w{clients containers cookbook_artifacts cookbooks data environments groups nodes roles policies policy_groups}.freeze unless defined? OBJECT_TYPES
|
29
29
|
OBJECT_NAME_SPEC = /^[\-[:alnum:]_\.]+$/.freeze unless defined? OBJECT_NAME_SPEC
|
30
30
|
|
31
31
|
def validate_object_type!(type)
|
@@ -56,7 +56,7 @@ class Chef
|
|
56
56
|
|
57
57
|
objects_to_modify = []
|
58
58
|
all_objects = rest.get_rest(object_type)
|
59
|
-
objects_to_modify = all_objects.keys.
|
59
|
+
objects_to_modify = all_objects.keys.grep(object_name_matcher)
|
60
60
|
|
61
61
|
if objects_to_modify.empty?
|
62
62
|
ui.info "No #{object_type} match the expression /#{regex}/"
|
@@ -61,7 +61,7 @@ class Chef
|
|
61
61
|
|
62
62
|
objects_to_modify = []
|
63
63
|
all_objects = rest.get_rest(object_type)
|
64
|
-
objects_to_modify = all_objects.keys.
|
64
|
+
objects_to_modify = all_objects.keys.grep(object_name_matcher)
|
65
65
|
|
66
66
|
if objects_to_modify.empty?
|
67
67
|
ui.info "No #{object_type} match the expression /#{regex}/"
|
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -20,6 +20,7 @@ require_relative "../knife"
|
|
20
20
|
require_relative "data_bag_secret_options"
|
21
21
|
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
|
22
22
|
require "license_acceptance/cli_flags/mixlib_cli"
|
23
|
+
require "chef/json_compat" unless defined?(Chef::JSONCompat) # can't be lazy loaded since it's used in options
|
23
24
|
|
24
25
|
module LicenseAcceptance
|
25
26
|
autoload :Acceptor, "license_acceptance/acceptor"
|
@@ -416,9 +417,6 @@ class Chef
|
|
416
417
|
attr_reader :connection
|
417
418
|
|
418
419
|
deps do
|
419
|
-
require "erubis" unless defined?(Erubis)
|
420
|
-
require "net/ssh" unless defined?(Net::SSH)
|
421
|
-
require "chef/json_compat" unless defined?(Chef::JSONCompat)
|
422
420
|
require "chef-config/path_helper" unless defined?(ChefConfig::PathHelper)
|
423
421
|
require_relative "bootstrap/chef_vault_handler"
|
424
422
|
require_relative "bootstrap/client_builder"
|
@@ -544,6 +542,7 @@ class Chef
|
|
544
542
|
end
|
545
543
|
|
546
544
|
def render_template
|
545
|
+
require "erubis" unless defined?(Erubis)
|
547
546
|
@config[:first_boot_attributes] = first_boot_attributes
|
548
547
|
template_file = find_template
|
549
548
|
template = IO.read(template_file).chomp
|
@@ -930,7 +929,7 @@ class Chef
|
|
930
929
|
opts[:logger] = Chef::Log
|
931
930
|
opts[:password] = config[:connection_password] if config.key?(:connection_password)
|
932
931
|
opts[:user] = user if user
|
933
|
-
opts[:max_wait_until_ready] = config[:max_wait].
|
932
|
+
opts[:max_wait_until_ready] = config[:max_wait].to_i unless config[:max_wait].nil?
|
934
933
|
# TODO - when would we need to provide rdp_port vs port? Or are they not mutually exclusive?
|
935
934
|
opts[:port] = port if port
|
936
935
|
end
|
@@ -62,7 +62,7 @@ class Chef
|
|
62
62
|
|
63
63
|
# Exclude knife/chef/version. It's not a knife command, and force-loading
|
64
64
|
# when we load all of these files will emit constant-already-defined warnings
|
65
|
-
next if rel_path
|
65
|
+
next if rel_path&.match?(version_file_match)
|
66
66
|
|
67
67
|
subcommand_files[rel_path] = file
|
68
68
|
end
|
@@ -151,7 +151,7 @@ class Chef
|
|
151
151
|
rel_path = knife_file[/#{KNIFE_ROOT}#{Regexp.escape(File::SEPARATOR)}(.*)\.rb/, 1]
|
152
152
|
# Exclude version.rb file for the gem. It's not a knife command, and force-loading it later
|
153
153
|
# because loaded via in subcommand files generates CLI warnings about its consts already having been defined
|
154
|
-
next if knife_file
|
154
|
+
next if knife_file&.match?(version_file_match)
|
155
155
|
|
156
156
|
subcommand_files[rel_path] = knife_file
|
157
157
|
end
|
@@ -184,7 +184,7 @@ class Chef
|
|
184
184
|
# @return [Array<String>]
|
185
185
|
#
|
186
186
|
def positional_arguments(args)
|
187
|
-
args.
|
187
|
+
args.grep(/^(([[:alnum:]])[[:alnum:]\_\-]+)$/)
|
188
188
|
end
|
189
189
|
|
190
190
|
# Returns an Array of paths to knife commands located in
|
@@ -44,7 +44,7 @@ class Chef
|
|
44
44
|
org = Chef::Org.new(@org_name)
|
45
45
|
begin
|
46
46
|
org.associate_user(@username)
|
47
|
-
rescue Net::
|
47
|
+
rescue Net::HTTPClientException => e
|
48
48
|
if e.response.code == "409"
|
49
49
|
ui.msg "User #{username} already associated with organization #{org_name}"
|
50
50
|
else
|
@@ -60,7 +60,7 @@ class Chef
|
|
60
60
|
|
61
61
|
begin
|
62
62
|
org.dissociate_user(@username)
|
63
|
-
rescue Net::
|
63
|
+
rescue Net::HTTPClientException => e
|
64
64
|
if e.response.code == "404"
|
65
65
|
ui.msg "User #{username} is not associated with organization #{org_name}"
|
66
66
|
exit 1
|
@@ -88,7 +88,7 @@ class Chef
|
|
88
88
|
|
89
89
|
def remove_user_from_admin_group(org, org_name, username, admin_group_string)
|
90
90
|
org.remove_user_from_group(admin_group_string, username)
|
91
|
-
rescue Net::
|
91
|
+
rescue Net::HTTPClientException => e
|
92
92
|
if e.response.code == "404"
|
93
93
|
ui.warn <<~EOF
|
94
94
|
User #{username} is not in the #{admin_group_string} group for organization #{org_name}.
|
data/lib/chef/knife/version.rb
CHANGED
@@ -992,7 +992,7 @@ describe "knife delete", :workstation do
|
|
992
992
|
end
|
993
993
|
|
994
994
|
it "knife delete /policies/x-1.2.3.json succeeds" do
|
995
|
-
knife("raw /policies/x/revisions/1.2.3").should_succeed "{\n \"name\": \"x\",\n \"revision_id\": \"1.2.3\",\n \"run_list\": [\n\n ],\n \"cookbook_locks\": {\n\n }\n}\n"
|
995
|
+
knife("raw /policies/x/revisions/1.2.3").should_succeed "{\n \"policy_group_list\": [\n \"x\"\n ],\n \"name\": \"x\",\n \"revision_id\": \"1.2.3\",\n \"run_list\": [\n\n ],\n \"cookbook_locks\": {\n\n }\n}\n"
|
996
996
|
knife("delete /policies/x-1.2.3.json").should_succeed "Deleted /policies/x-1.2.3.json\n"
|
997
997
|
knife("raw /policies/x/revisions/1.2.3").should_fail(/404/)
|
998
998
|
end
|
@@ -1276,8 +1276,8 @@ describe "knife download", :workstation do
|
|
1276
1276
|
file "members.json", [ "bar" ]
|
1277
1277
|
file "nodes/x.json", { "normal" => { "tags" => [] } }
|
1278
1278
|
file "org.json", { "full_name" => "Something" }
|
1279
|
-
file "policies/x-1.0.0.json", {}
|
1280
|
-
file "policies/blah-1.0.0.json", {}
|
1279
|
+
file "policies/x-1.0.0.json", { "policy_group_list" => [ "x" ] }
|
1280
|
+
file "policies/blah-1.0.0.json", { "policy_group_list" => [ "x" ] }
|
1281
1281
|
file "policy_groups/x.json", { "policies" => { "x" => { "revision_id" => "1.0.0" }, "blah" => { "revision_id" => "1.0.0" } } }
|
1282
1282
|
file "roles/x.json", {}
|
1283
1283
|
end
|
@@ -1383,8 +1383,8 @@ describe "knife upload", :workstation do
|
|
1383
1383
|
file "members.json", [ "bar" ]
|
1384
1384
|
file "org.json", { "full_name" => "wootles" }
|
1385
1385
|
file "nodes/x.json", { "normal" => { "tags" => [] } }
|
1386
|
-
file "policies/x-1.0.0.json", {}
|
1387
|
-
file "policies/blah-1.0.0.json", {}
|
1386
|
+
file "policies/x-1.0.0.json", { "policy_group_list" => [ "x" ] }
|
1387
|
+
file "policies/blah-1.0.0.json", { "policy_group_list" => [ "x" ] }
|
1388
1388
|
file "policy_groups/x.json", { "policies" => { "x" => { "revision_id" => "1.0.0" }, "blah" => { "revision_id" => "1.0.0" } } }
|
1389
1389
|
file "roles/x.json", {}
|
1390
1390
|
end
|
@@ -1484,12 +1484,11 @@ describe "knife upload", :workstation do
|
|
1484
1484
|
environment "x", { "description" => "foo" }
|
1485
1485
|
group "x", { "groups" => [ "admin" ] }
|
1486
1486
|
node "x", { "run_list" => [ "blah" ] }
|
1487
|
-
policy "x", "1.0.0", {}
|
1488
|
-
policy "
|
1489
|
-
policy "y", "1.0.0", {}
|
1487
|
+
policy "x", "1.0.0", { "policy_group_list" => [ "x" ] }
|
1488
|
+
policy "y", "1.0.0", { "policy_group_list" => [ "x" ] }
|
1490
1489
|
policy_group "x", {
|
1491
1490
|
"policies" => {
|
1492
|
-
"x" => { "revision_id" => "1.0.
|
1491
|
+
"x" => { "revision_id" => "1.0.0" },
|
1493
1492
|
"y" => { "revision_id" => "1.0.0" },
|
1494
1493
|
},
|
1495
1494
|
}
|
data/spec/knife_spec_helper.rb
CHANGED
@@ -78,8 +78,8 @@ require "spec/support/shared/matchers/match_environment_variable"
|
|
78
78
|
# Excludes support/platforms by default
|
79
79
|
# Do not change the gsub.
|
80
80
|
Dir["spec/support/**/*.rb"]
|
81
|
-
.
|
82
|
-
.
|
81
|
+
.grep_v(%r{^spec/support/platforms})
|
82
|
+
.grep_v(%r{^spec/support/pedant})
|
83
83
|
.map { |f| f.gsub(/.rb$/, "") }
|
84
84
|
.map { |f| f.gsub(%r{spec/}, "") }
|
85
85
|
.each { |f| require f }
|
@@ -817,7 +817,7 @@ describe Chef::Knife::Bootstrap do
|
|
817
817
|
# Set everything to easily identifiable and obviously fake values
|
818
818
|
# to verify that Chef::Config is being sourced instead of knife.config
|
819
819
|
knife.config = {}
|
820
|
-
Chef::Config[:knife][:max_wait] = 9999
|
820
|
+
Chef::Config[:knife][:max_wait] = 9999.0
|
821
821
|
Chef::Config[:knife][:winrm_user] = "winbob"
|
822
822
|
Chef::Config[:knife][:winrm_port] = 9999
|
823
823
|
Chef::Config[:knife][:ca_trust_file] = "trust.me"
|
@@ -836,7 +836,7 @@ describe Chef::Knife::Bootstrap do
|
|
836
836
|
{
|
837
837
|
logger: Chef::Log, # not configurable
|
838
838
|
ca_trust_path: "trust.me",
|
839
|
-
max_wait_until_ready: 9999,
|
839
|
+
max_wait_until_ready: 9999, # converted to int
|
840
840
|
operation_timeout: 9999,
|
841
841
|
ssl_peer_fingerprint: "ABCDEF",
|
842
842
|
winrm_transport: "kerberos",
|
@@ -899,7 +899,7 @@ describe Chef::Knife::Bootstrap do
|
|
899
899
|
# pull in the Chef::Config value
|
900
900
|
Chef::Config[:knife][:winrm_auth_method] = "negotiate"
|
901
901
|
knife.config[:connection_password] = "blue"
|
902
|
-
knife.config[:max_wait] = 1000
|
902
|
+
knife.config[:max_wait] = 1000.0
|
903
903
|
knife.config[:connection_user] = "clippy"
|
904
904
|
knife.config[:connection_port] = 1000
|
905
905
|
knife.config[:winrm_port] = 1001 # We should not see this value get used
|
@@ -918,7 +918,7 @@ describe Chef::Knife::Bootstrap do
|
|
918
918
|
{
|
919
919
|
logger: Chef::Log, # not configurable
|
920
920
|
ca_trust_path: "trust.the.internet",
|
921
|
-
max_wait_until_ready: 1000,
|
921
|
+
max_wait_until_ready: 1000, # converted to int
|
922
922
|
operation_timeout: 1000,
|
923
923
|
ssl_peer_fingerprint: "FEDCBA",
|
924
924
|
winrm_transport: "kerberos",
|
@@ -971,7 +971,7 @@ describe Chef::Knife::Bootstrap do
|
|
971
971
|
# Set everything to easily identifiable and obviously fake values
|
972
972
|
# to verify that Chef::Config is being sourced instead of knife.config
|
973
973
|
knife.config = {}
|
974
|
-
Chef::Config[:knife][:max_wait] = 9999
|
974
|
+
Chef::Config[:knife][:max_wait] = 9999.0
|
975
975
|
Chef::Config[:knife][:session_timeout] = 9999
|
976
976
|
Chef::Config[:knife][:ssh_user] = "sshbob"
|
977
977
|
Chef::Config[:knife][:ssh_port] = 9999
|
@@ -986,7 +986,7 @@ describe Chef::Knife::Bootstrap do
|
|
986
986
|
let(:expected_result) do
|
987
987
|
{
|
988
988
|
logger: Chef::Log, # not configurable
|
989
|
-
max_wait_until_ready: 9999
|
989
|
+
max_wait_until_ready: 9999, # converted to int
|
990
990
|
connection_timeout: 9999,
|
991
991
|
user: "sshbob",
|
992
992
|
bastion_host: "mygateway.local",
|
@@ -1032,7 +1032,7 @@ describe Chef::Knife::Bootstrap do
|
|
1032
1032
|
knife.config[:connection_port] = 12
|
1033
1033
|
knife.config[:ssh_port] = "13" # canary to indirectly verify we're not looking for the wrong CLI flag
|
1034
1034
|
knife.config[:connection_password] = "feta cheese"
|
1035
|
-
knife.config[:max_wait] = 150
|
1035
|
+
knife.config[:max_wait] = 150.0
|
1036
1036
|
knife.config[:session_timeout] = 120
|
1037
1037
|
knife.config[:use_sudo] = true
|
1038
1038
|
knife.config[:use_sudo_pasword] = true
|
@@ -1042,7 +1042,7 @@ describe Chef::Knife::Bootstrap do
|
|
1042
1042
|
let(:expected_result) do
|
1043
1043
|
{
|
1044
1044
|
logger: Chef::Log, # not configurable
|
1045
|
-
max_wait_until_ready: 150
|
1045
|
+
max_wait_until_ready: 150, # cli (converted to int)
|
1046
1046
|
connection_timeout: 120, # cli
|
1047
1047
|
user: "sshalice", # cli
|
1048
1048
|
password: "feta cheese", # cli
|
@@ -1068,7 +1068,7 @@ describe Chef::Knife::Bootstrap do
|
|
1068
1068
|
context "and all CLI options have been given" do
|
1069
1069
|
before do
|
1070
1070
|
knife.config = {}
|
1071
|
-
knife.config[:max_wait] = 150
|
1071
|
+
knife.config[:max_wait] = 150.0
|
1072
1072
|
knife.config[:session_timeout] = 120
|
1073
1073
|
knife.config[:connection_user] = "sshroot"
|
1074
1074
|
knife.config[:connection_port] = 1000
|
@@ -1093,7 +1093,7 @@ describe Chef::Knife::Bootstrap do
|
|
1093
1093
|
let(:expected_result) do
|
1094
1094
|
{
|
1095
1095
|
logger: Chef::Log, # not configurable
|
1096
|
-
max_wait_until_ready: 150,
|
1096
|
+
max_wait_until_ready: 150, # converted to int
|
1097
1097
|
connection_timeout: 120,
|
1098
1098
|
user: "sshroot",
|
1099
1099
|
password: "blah",
|
@@ -39,7 +39,7 @@ describe Chef::Knife::EnvironmentList do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should print the environment names in a sorted list" do
|
42
|
-
names = @environments.keys.sort
|
42
|
+
names = @environments.keys.sort
|
43
43
|
expect(@knife).to receive(:output).with(names)
|
44
44
|
@knife.run
|
45
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 17.
|
4
|
+
version: 17.9.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Jacob
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef-config
|
@@ -228,20 +228,6 @@ dependencies:
|
|
228
228
|
- - ">="
|
229
229
|
- !ruby/object:Gem::Version
|
230
230
|
version: 1.2.1
|
231
|
-
- !ruby/object:Gem::Dependency
|
232
|
-
name: ed25519
|
233
|
-
requirement: !ruby/object:Gem::Requirement
|
234
|
-
requirements:
|
235
|
-
- - "~>"
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
version: '1.2'
|
238
|
-
type: :runtime
|
239
|
-
prerelease: false
|
240
|
-
version_requirements: !ruby/object:Gem::Requirement
|
241
|
-
requirements:
|
242
|
-
- - "~>"
|
243
|
-
- !ruby/object:Gem::Version
|
244
|
-
version: '1.2'
|
245
231
|
- !ruby/object:Gem::Dependency
|
246
232
|
name: bcrypt_pbkdf
|
247
233
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1150,7 +1136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1150
1136
|
- !ruby/object:Gem::Version
|
1151
1137
|
version: '0'
|
1152
1138
|
requirements: []
|
1153
|
-
rubygems_version: 3.2.
|
1139
|
+
rubygems_version: 3.2.32
|
1154
1140
|
signing_key:
|
1155
1141
|
specification_version: 4
|
1156
1142
|
summary: The knife CLI for Chef Infra.
|