knife 17.7.29 → 17.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be4b06276e35e8607fd42ccf9adab45beb709e3de9812b9f7d9bd026b83d2395
4
- data.tar.gz: ddc9acce8bde6e250514a4850507c80c1e1b1c2934206c421a9e43d9d1a04e15
3
+ metadata.gz: 555723f352d005f6f3433b771c6804d8cf70b83b983baa9d626d9c2438609443
4
+ data.tar.gz: d310fe22078eecdf79bf322a0256dc3197cfe638471983429383a08f05946986
5
5
  SHA512:
6
- metadata.gz: 529677a2f81ba1fe3b9288c56175459108673497ee744e1a2697f6734949d927ff030ad37272ebb7d3a113e62c50e796ba8ed36ed8781a1b90c199e551654334
7
- data.tar.gz: 06fc0ab9696defb918483b5d6e4d0aa2ca57229a0847d3c457d5b140e715c22ce823e80dd7da08db0b7e65722699d7181df89958c89b02459fff4ef504656a8a
6
+ metadata.gz: 68ab4a40999b28c80de1376cc0a1211d0150a7cac5d55257821d38da7faad43329b46cb7ce725ac19087bff494e007b311e9ebe3ac17f524533c5774118f85eb
7
+ data.tar.gz: bee5256b0e182287ad22ac9bc7fdd664d917e7236d187e384e6673d388a42b28bc4a46f9887e7d80673c6783c87b52a99aa9c823a097e43a1c0993b8b7f20f25
data/Gemfile CHANGED
@@ -20,7 +20,7 @@ group(:chefstyle) do
20
20
  gem "chefstyle", git: "https://github.com/chef/chefstyle.git", branch: "main"
21
21
  end
22
22
 
23
- gem "ohai", git: "https://github.com/chef/ohai.git", branch: "main"
23
+ gem "ohai", git: "https://github.com/chef/ohai.git", branch: "17-stable"
24
24
  gem "chef", path: ".."
25
25
  gem "chef-utils", path: File.expand_path("../chef-utils", __dir__) if File.exist?(File.expand_path("../chef-utils", __dir__))
26
26
  gem "chef-config", path: File.expand_path("../chef-config", __dir__) if File.exist?(File.expand_path("../chef-config", __dir__))
@@ -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.select { |object_name| object_name =~ object_name_matcher }
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.select { |object_name| object_name =~ object_name_matcher }
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}/"
@@ -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].to_f unless config[:max_wait].nil?
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 =~ version_file_match
65
+ next if rel_path&.match?(version_file_match)
66
66
 
67
67
  subcommand_files[rel_path] = file
68
68
  end
@@ -140,7 +140,7 @@ class Chef
140
140
  end
141
141
 
142
142
  def format_list_for_display(list)
143
- config[:with_uri] ? list : list.keys.sort { |a, b| a <=> b }
143
+ config[:with_uri] ? list : list.keys.sort
144
144
  end
145
145
 
146
146
  def format_for_display(data)
@@ -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 =~ version_file_match
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.select { |arg| arg =~ /^(([[:alnum:]])[[:alnum:]\_\-]+)$/ }
187
+ args.grep(/^(([[:alnum:]])[[:alnum:]\_\-]+)$/)
188
188
  end
189
189
 
190
190
  # Returns an Array of paths to knife commands located in
@@ -17,7 +17,7 @@
17
17
  class Chef
18
18
  class Knife
19
19
  KNIFE_ROOT = File.expand_path("../..", __dir__)
20
- VERSION = "17.7.29".freeze
20
+ VERSION = "17.10.0".freeze
21
21
  end
22
22
  end
23
23
 
@@ -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
- .reject { |f| f =~ %r{^spec/support/platforms} }
82
- .reject { |f| f =~ %r{^spec/support/pedant} }
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 }
@@ -168,7 +168,7 @@ def wpar?
168
168
  end
169
169
 
170
170
  def supports_cloexec?
171
- Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC")
171
+ Fcntl.const_defined?(:F_SETFD) && Fcntl.const_defined?(:FD_CLOEXEC)
172
172
  end
173
173
 
174
174
  def selinux_enabled?
@@ -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.0,
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.0, # cli
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 { |a, b| a <=> b }
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.7.29
4
+ version: 17.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2022-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-config