knife-cloud 3.0.3 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0727b41523637f5dd2d2eba4963a0e35964709897d278f3de8fd7a7ef2cb5f99
4
- data.tar.gz: 2397e2551796a94336e6550ca5b66cce165b76b237a49ecc2e27daf217c7b94b
3
+ metadata.gz: f8885e2b5c47349e28d6459c3b1c01b0a729e4bbfdd1aebf02136510dc46b9d2
4
+ data.tar.gz: 8a2f78c9ff97e9a3503e21355928721a6a7927760c5c31901861e9bd00af46eb
5
5
  SHA512:
6
- metadata.gz: 75f81bcca7dde70a03a9a452740a3996eea12d63075eb7cf859c247450a9bd5c9af7967ef917dcad3632742711dd609ccb2dd90b9601dce37dc5c896dccc11f4
7
- data.tar.gz: 30cfada30a71df2b06deda09ea5a465a61488e4a9055be2cfd5ddff5155fe60bb3995bb92a881d9998d7750e9cf6d4fc62b4d26a9dc2691bf1129834b915b5eb
6
+ metadata.gz: ee17a4dc208bdbf294d86309e58c1e9def8c8b696c337aff6ebc08ef43bbcda941a55ce1cac4b44f5fc852f09e66ac13ab95df0fb5adae98c224279aa117c72c
7
+ data.tar.gz: 7c88071c1869ab8efb8fcff1d7fdd3431c572a71e3079340b1fbf5e5af746543ce803bb1350b714a6b4e855e51ec7ef2539c3cc636f1d46914b8234ed0efe88b
@@ -17,7 +17,6 @@
17
17
  # limitations under the License.
18
18
 
19
19
  require "chef/knife/core/bootstrap_context"
20
- require "net/ssh/multi"
21
20
 
22
21
  class Chef
23
22
  class Knife
@@ -30,8 +29,9 @@ class Chef
30
29
 
31
30
  deps do
32
31
  require "chef/json_compat"
33
- require "tempfile"
34
- require "net/ssh"
32
+ require "tempfile" unless defined?(Tempfile)
33
+ require "net/ssh" unless defined?(Net::SSH)
34
+ require "net/ssh/multi"
35
35
  require "chef/knife/ssh"
36
36
  Chef::Knife::Ssh.load_deps
37
37
  end
@@ -1,7 +1,7 @@
1
1
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
2
2
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
3
3
  #
4
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -46,36 +46,36 @@ class Chef
46
46
 
47
47
  def init_bootstrap_options
48
48
  # set the command bootstrap options.
49
- bootstrap.name_args << locate_config_value(:bootstrap_ip_address)
50
- bootstrap.config[:chef_node_name] = locate_config_value(:chef_node_name)
51
- bootstrap.config[:run_list] = locate_config_value(:run_list)
52
- bootstrap.config[:prerelease] = locate_config_value(:prerelease)
53
- bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
54
- bootstrap.config[:bootstrap_proxy] = locate_config_value(:bootstrap_proxy)
55
- bootstrap.config[:environment] = locate_config_value(:environment)
49
+ bootstrap.name_args << config[:bootstrap_ip_address]
50
+ bootstrap.config[:chef_node_name] = config[:chef_node_name]
51
+ bootstrap.config[:run_list] = config[:run_list]
52
+ bootstrap.config[:prerelease] = config[:prerelease]
53
+ bootstrap.config[:bootstrap_version] = config[:bootstrap_version]
54
+ bootstrap.config[:bootstrap_proxy] = config[:bootstrap_proxy]
55
+ bootstrap.config[:environment] = config[:environment]
56
56
  # see chef/knife/bootstrap.rb #warn_chef_config_secret_key.
57
- bootstrap.config[:encrypted_data_bag_secret] = locate_config_value(:encrypted_data_bag_secret)
58
- bootstrap.config[:encrypted_data_bag_secret_file] = locate_config_value(:encrypted_data_bag_secret_file)
59
- bootstrap.config[:first_boot_attributes] = locate_config_value(:first_boot_attributes)
60
- bootstrap.config[:secret] = locate_config_value(:secret)
61
- bootstrap.config[:secret_file] = locate_config_value(:secret_file)
62
- bootstrap.config[:bootstrap_template] = locate_config_value(:bootstrap_template)
63
- bootstrap.config[:node_ssl_verify_mode] = locate_config_value(:node_ssl_verify_mode)
64
- bootstrap.config[:node_verify_api_cert] = locate_config_value(:node_verify_api_cert)
65
- bootstrap.config[:bootstrap_no_proxy] = locate_config_value(:bootstrap_no_proxy)
66
- bootstrap.config[:bootstrap_url] = locate_config_value(:bootstrap_url)
67
- bootstrap.config[:bootstrap_install_command] = locate_config_value(:bootstrap_install_command)
68
- bootstrap.config[:bootstrap_wget_options] = locate_config_value(:bootstrap_wget_options)
69
- bootstrap.config[:bootstrap_curl_options] = locate_config_value(:bootstrap_curl_options)
70
- bootstrap.config[:bootstrap_vault_file] = locate_config_value(:bootstrap_vault_file)
71
- bootstrap.config[:bootstrap_vault_json] = locate_config_value(:bootstrap_vault_json)
72
- bootstrap.config[:bootstrap_vault_item] = locate_config_value(:bootstrap_vault_item)
73
- bootstrap.config[:use_sudo_password] = locate_config_value(:use_sudo_password)
74
- bootstrap.config[:msi_url] = locate_config_value(:msi_url)
75
- bootstrap.config[:install_as_service] = locate_config_value(:install_as_service)
76
- bootstrap.config[:session_timeout] = locate_config_value(:session_timeout)
77
- bootstrap.config[:channel] = locate_config_value(:channel)
78
- bootstrap.config[:bootstrap_product] = locate_config_value(:bootstrap_product)
57
+ bootstrap.config[:encrypted_data_bag_secret] = config[:encrypted_data_bag_secret]
58
+ bootstrap.config[:encrypted_data_bag_secret_file] = config[:encrypted_data_bag_secret_file]
59
+ bootstrap.config[:first_boot_attributes] = config[:first_boot_attributes]
60
+ bootstrap.config[:secret] = config[:secret]
61
+ bootstrap.config[:secret_file] = config[:secret_file]
62
+ bootstrap.config[:bootstrap_template] = config[:bootstrap_template]
63
+ bootstrap.config[:node_ssl_verify_mode] = config[:node_ssl_verify_mode]
64
+ bootstrap.config[:node_verify_api_cert] = config[:node_verify_api_cert]
65
+ bootstrap.config[:bootstrap_no_proxy] = config[:bootstrap_no_proxy]
66
+ bootstrap.config[:bootstrap_url] = config[:bootstrap_url]
67
+ bootstrap.config[:bootstrap_install_command] = config[:bootstrap_install_command]
68
+ bootstrap.config[:bootstrap_wget_options] = config[:bootstrap_wget_options]
69
+ bootstrap.config[:bootstrap_curl_options] = config[:bootstrap_curl_options]
70
+ bootstrap.config[:bootstrap_vault_file] = config[:bootstrap_vault_file]
71
+ bootstrap.config[:bootstrap_vault_json] = config[:bootstrap_vault_json]
72
+ bootstrap.config[:bootstrap_vault_item] = config[:bootstrap_vault_item]
73
+ bootstrap.config[:use_sudo_password] = config[:use_sudo_password]
74
+ bootstrap.config[:msi_url] = config[:msi_url]
75
+ bootstrap.config[:install_as_service] = config[:install_as_service]
76
+ bootstrap.config[:session_timeout] = config[:session_timeout]
77
+ bootstrap.config[:channel] = config[:channel]
78
+ bootstrap.config[:bootstrap_product] = config[:bootstrap_product]
79
79
  end
80
80
 
81
81
  end
@@ -1,7 +1,7 @@
1
1
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
2
2
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
3
3
  #
4
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) Chef Software Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,33 +32,33 @@ class Chef
32
32
  end
33
33
 
34
34
  def init_bootstrap_options
35
- bootstrap.config[:connection_user] = @config[:connection_user]
36
- bootstrap.config[:connection_password] = @config[:connection_password]
37
- bootstrap.config[:connection_port] = locate_config_value(:connection_port)
38
- bootstrap.config[:ssh_identity_file] = @config[:ssh_identity_file]
39
- bootstrap.config[:ssh_verify_host_key] = @config[:ssh_verify_host_key]
40
- bootstrap.config[:use_sudo] = true unless @config[:connection_user] == "root"
41
- bootstrap.config[:ssh_gateway] = locate_config_value(:ssh_gateway)
42
- bootstrap.config[:forward_agent] = locate_config_value(:forward_agent)
43
- bootstrap.config[:use_sudo_password] = locate_config_value(:use_sudo_password)
35
+ bootstrap.config[:connection_user] = config[:connection_user]
36
+ bootstrap.config[:connection_password] = config[:connection_password]
37
+ bootstrap.config[:connection_port] = config[:connection_port]
38
+ bootstrap.config[:ssh_identity_file] = config[:ssh_identity_file]
39
+ bootstrap.config[:ssh_verify_host_key] = config[:ssh_verify_host_key]
40
+ bootstrap.config[:use_sudo] = true unless config[:connection_user] == "root"
41
+ bootstrap.config[:ssh_gateway] = config[:ssh_gateway]
42
+ bootstrap.config[:forward_agent] = config[:forward_agent]
43
+ bootstrap.config[:use_sudo_password] = config[:use_sudo_password]
44
44
  super
45
45
  end
46
46
 
47
47
  def wait_for_server_ready
48
- print "\n#{ui.color("Waiting for sshd to host (#{@config[:bootstrap_ip_address]})", :magenta)}"
48
+ print "\n#{ui.color("Waiting for sshd to host (#{config[:bootstrap_ip_address]})", :magenta)}"
49
49
 
50
- ssh_gateway = get_ssh_gateway_for(@config[:bootstrap_ip_address])
50
+ ssh_gateway = get_ssh_gateway_for(config[:bootstrap_ip_address])
51
51
 
52
52
  # The ssh_gateway & subnet_id are currently supported only in EC2.
53
53
  if ssh_gateway
54
- print(".") until tunnel_test_ssh(ssh_gateway, @config[:bootstrap_ip_address]) do
55
- @initial_sleep_delay = !!locate_config_value(:subnet_id) ? 40 : 10
54
+ print(".") until tunnel_test_ssh(ssh_gateway, config[:bootstrap_ip_address]) do
55
+ @initial_sleep_delay = !!config[:subnet_id] ? 40 : 10
56
56
  sleep @initial_sleep_delay
57
57
  puts("done")
58
58
  end
59
59
  else
60
- print(".") until tcp_test_ssh(@config[:bootstrap_ip_address], locate_config_value(:connection_port) || Chef::Config[:knife][:ssh_port] ) do
61
- @initial_sleep_delay = !!locate_config_value(:subnet_id) ? 40 : 10
60
+ print(".") until tcp_test_ssh(config[:bootstrap_ip_address], config[:connection_port] || config[:ssh_port] ) do
61
+ @initial_sleep_delay = !!config[:subnet_id] ? 40 : 10
62
62
  sleep @initial_sleep_delay
63
63
  puts("done")
64
64
  end
@@ -66,11 +66,11 @@ class Chef
66
66
  end
67
67
 
68
68
  def get_ssh_gateway_for(hostname)
69
- if locate_config_value(:ssh_gateway)
69
+ if config[:ssh_gateway]
70
70
  # The ssh_gateway specified in the knife config (if any) takes
71
71
  # precedence over anything in the SSH configuration
72
- Chef::Log.debug("Using ssh gateway #{locate_config_value(:ssh_gateway)} from knife config")
73
- locate_config_value(:ssh_gateway)
72
+ Chef::Log.debug("Using ssh gateway #{config[:ssh_gateway]} from knife config")
73
+ config[:ssh_gateway]
74
74
  else
75
75
  # Next, check if the SSH configuration has a ProxyCommand
76
76
  # directive for this host. If there is one, parse out the
@@ -130,7 +130,8 @@ class Chef
130
130
  def tunnel_test_ssh(ssh_gateway, hostname, &block)
131
131
  status = false
132
132
  gateway = configure_ssh_gateway(ssh_gateway)
133
- gateway.open(hostname, locate_config_value(:ssh_port)) do |local_tunnel_port|
133
+ remote_ssh_port = config[:connection_port] || config[:ssh_port] || 22
134
+ gateway.open(hostname, remote_ssh_port) do |local_tunnel_port|
134
135
  status = tcp_test_ssh("localhost", local_tunnel_port, &block)
135
136
  end
136
137
  status
@@ -157,8 +158,8 @@ class Chef
157
158
  gateway_keys = ssh_gateway_config[:keys]
158
159
 
159
160
  # Use the keys specificed on the command line if available (overrides SSH Config)
160
- if locate_config_value(:ssh_gateway_identity)
161
- gateway_keys = Array(locate_config_value(:ssh_gateway_identity))
161
+ if config[:ssh_gateway_identity]
162
+ gateway_keys = Array(config[:ssh_gateway_identity])
162
163
  end
163
164
 
164
165
  unless gateway_keys.nil?
@@ -31,7 +31,7 @@ class Chef
31
31
  end
32
32
 
33
33
  def load_winrm_deps
34
- require "winrm"
34
+ require "winrm" unless defined?(WinRM::Connection)
35
35
  require "chef/knife/core/windows_bootstrap_context"
36
36
  end
37
37
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
3
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
3
+ # Copyright:: Copyright (c) Chef Software Inc.
4
4
  #
5
5
 
6
6
  class Chef
@@ -13,13 +13,11 @@ class Chef
13
13
  option :fog_version,
14
14
  long: "--fog-version version",
15
15
  description: "Fog gem version to use. Use the ruby gem version strings",
16
- default: "",
17
- proc: Proc.new { |v| Chef::Config[:knife][:cloud_fog_version] = v }
16
+ default: ""
18
17
 
19
18
  option :api_endpoint,
20
19
  long: "--api-endpoint ENDPOINT",
21
- description: "Your API endpoint. Eg, for Eucalyptus it can be 'http://ecc.eucalyptus.com:8773/services/Eucalyptus'",
22
- proc: Proc.new { |endpoint| Chef::Config[:knife][:api_endpoint] = endpoint }
20
+ description: "Your API endpoint. Eg, for Eucalyptus it can be 'http://ecc.eucalyptus.com:8773/services/Eucalyptus'"
23
21
 
24
22
  end
25
23
  end
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
3
3
  # Author:: Prabhu Das (<prabhu.das@clogeny.com>)
4
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
4
+ # Copyright:: Copyright (c) Chef Software Inc.
5
5
  #
6
6
 
7
7
  require_relative "../service"
@@ -12,18 +12,18 @@ class Chef
12
12
  class Cloud
13
13
  class FogService < Service
14
14
 
15
- def initialize(options = {})
16
- load_fog_gem
15
+ def initialize(**kwargs)
17
16
  super
17
+ load_fog_gem
18
18
  end
19
19
 
20
20
  def load_fog_gem
21
21
  # Load specific version of fog-core. Any other classes/modules using fog-core are loaded after this.
22
- gem "fog-core", Chef::Config[:knife][:cloud_fog_version]
22
+ gem "fog-core", config[:cloud_fog_version]
23
23
  require "fog/core"
24
24
  Chef::Log.debug("Using fog-core version: #{Gem.loaded_specs["fog-core"].version}")
25
- rescue Exception
26
- Chef::Log.error "Error loading fog-core gem."
25
+ rescue Exception => ex
26
+ Chef::Log.error "Error loading fog-core gem: #{ex}"
27
27
  exit 1
28
28
  end
29
29
 
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
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");
@@ -27,11 +27,6 @@ class Chef
27
27
  end
28
28
  end
29
29
 
30
- def locate_config_value(key)
31
- key = key.to_sym
32
- config[key] || Chef::Config[:knife][key]
33
- end
34
-
35
30
  def create_service_instance
36
31
  raise Chef::Exceptions::Override, "You must override create_service_instance in #{self} to create cloud specific service"
37
32
  end
@@ -52,7 +47,7 @@ class Chef
52
47
  # subclasses to implement this.
53
48
  errors = []
54
49
  keys.each do |k|
55
- errors << "You did not provide a valid '#{pretty_key(k)}' value." if locate_config_value(k).nil?
50
+ errors << "You did not provide a valid '#{pretty_key(k)}' value." if config[k].nil?
56
51
  end
57
52
  error_message = ""
58
53
  raise CloudExceptions::ValidationError, error_message if errors.each { |e| ui.error(e); error_message = "#{error_message} #{e}." }.any?
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
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");
@@ -33,16 +33,16 @@ class Chef
33
33
 
34
34
  def validate_params!
35
35
  # set param vm_name to a random value if the name is not set by the user (plugin)
36
- config[:chef_node_name] = get_node_name(locate_config_value(:chef_node_name), locate_config_value(:chef_node_name_prefix))
36
+ config[:chef_node_name] = get_node_name(config[:chef_node_name], config[:chef_node_name_prefix])
37
37
 
38
38
  # validate ssh_identity_file for connection protocol and connection_user, connection_password for both ssh bootstrap protocol and winrm bootstrap protocol
39
39
  errors = []
40
- if locate_config_value(:connection_protocol) == "ssh"
41
- if locate_config_value(:ssh_identity_file).nil? && locate_config_value(:connection_password).nil?
40
+ if config[:connection_protocol] == "ssh"
41
+ if config[:ssh_identity_file].nil? && config[:connection_password].nil?
42
42
  errors << "You must provide either SSH Identity file or Connection Password."
43
43
  end
44
- elsif locate_config_value(:connection_protocol) == "winrm"
45
- if locate_config_value(:connection_password).nil?
44
+ elsif config[:connection_protocol] == "winrm"
45
+ if config[:connection_password].nil?
46
46
  errors << "You must provide Connection Password."
47
47
  end
48
48
  else
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
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");
@@ -30,20 +30,17 @@ class Chef
30
30
  option :image,
31
31
  short: "-I IMAGE",
32
32
  long: "--image IMAGE",
33
- description: "A regexp matching an image name or an image ID for the server",
34
- proc: Proc.new { |i| Chef::Config[:knife][:image] = i }
33
+ description: "A regexp matching an image name or an image ID for the server"
35
34
 
36
35
  option :image_os_type,
37
36
  short: "-T IMAGE_OS_TYPE",
38
37
  long: "--image-os-type IMAGE_OS_TYPE",
39
- description: "The image os type. options [windows/linux]. Only required when cloud does not provide a way to identify image os",
40
- proc: Proc.new { |i| Chef::Config[:knife][:image_os_type] = i }
38
+ description: "The image os type. options [windows/linux]. Only required when cloud does not provide a way to identify image os"
41
39
 
42
40
  option :flavor,
43
41
  short: "-f FLAVOR_ID",
44
42
  long: "--flavor FLAVOR_ID",
45
- description: "The flavor name or ID of server",
46
- proc: Proc.new { |f| Chef::Config[:knife][:flavor] = f }
43
+ description: "The flavor name or ID of server"
47
44
 
48
45
  deprecated_option :bootstrap_protocol,
49
46
  replacement: :connection_protocol,
@@ -52,8 +49,7 @@ class Chef
52
49
  option :server_create_timeout,
53
50
  long: "--server-create-timeout timeout",
54
51
  description: "How long to wait until the server is ready; default is 600 seconds",
55
- default: 600,
56
- proc: Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v }
52
+ default: 600
57
53
 
58
54
  option :delete_server_on_failure,
59
55
  long: "--delete-server-on-failure",
@@ -64,8 +60,7 @@ class Chef
64
60
  option :chef_node_name_prefix,
65
61
  long: "--chef-node-name-prefix PREFIX_FOR_NODE_NAME",
66
62
  description: "The prefix for chef node name",
67
- default: includer.snake_case_name.split("_").first,
68
- proc: Proc.new { |key| Chef::Config[:knife][:chef_node_name_prefix] = key }
63
+ default: includer.snake_case_name.split("_").first
69
64
  end
70
65
  end
71
66
 
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Siddheshwar More (<siddheshwar.more@clogeny.com>)
3
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
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");
@@ -31,8 +31,7 @@ class Chef
31
31
 
32
32
  option :chef_node_attribute,
33
33
  long: "--chef-node-attribute CHEF_NODE_ATTRIBUTE_NAME",
34
- description: "Used with --chef-data option. It display node attributes details by adding new column in server list display.",
35
- proc: Proc.new { |i| Chef::Config[:knife][:chef_node_attribute] = i }
34
+ description: "Used with --chef-data option. It display node attributes details by adding new column in server list display."
36
35
 
37
36
  end
38
37
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
3
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
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");
@@ -30,7 +30,7 @@ class Chef
30
30
  option :custom_attributes,
31
31
  long: "--custom-attributes CUSTOM_ATTRIBUTES",
32
32
  description: "Custom attributes to be passed to Fog.",
33
- proc: Proc.new { |args| Chef::Config[:knife][:custom_attributes] = args.split(";").map { |keys| keys.split("=") }.map { |j| Hash[*j.map(&:strip)] } }
33
+ proc: Proc.new { |args| args.split(";").map { |keys| keys.split("=") }.map { |j| Hash[*j.map(&:strip)] } }
34
34
  end
35
35
  end
36
36
  end
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
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");
@@ -32,7 +32,7 @@ class Chef
32
32
  def validate_params!
33
33
  errors = []
34
34
  config[:instance_id] = @name_args.first
35
- if locate_config_value(:instance_id).nil?
35
+ if config[:instance_id].nil?
36
36
  errors << "You must provide a valid Instance Id"
37
37
  end
38
38
  error_message = ""
@@ -40,9 +40,9 @@ class Chef
40
40
  end
41
41
 
42
42
  def execute_command
43
- server = service.get_server(locate_config_value(:instance_id))
43
+ server = service.get_server(config[:instance_id])
44
44
  if server.nil?
45
- error_message = "Server doesn't exists for this #{locate_config_value(:instance_id)} instance id."
45
+ error_message = "Server doesn't exists for this #{config[:instance_id]} instance id."
46
46
  ui.error(error_message)
47
47
  raise CloudExceptions::ServerShowError, error_message
48
48
  else
@@ -1,5 +1,5 @@
1
1
  #
2
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
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");
@@ -24,8 +24,7 @@ class Chef
24
24
 
25
25
  option :instance_id,
26
26
  long: "--instance-id INSTANCE_ID",
27
- description: "Required. Instance Id of Server",
28
- proc: Proc.new { |i| Chef::Config[:knife][:instance_id] = i }
27
+ description: "Required. Instance Id of Server"
29
28
 
30
29
  end
31
30
  end
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Kaustubh Deorukhkar (<kaustubh@clogeny.com>)
3
- # Copyright:: Copyright (c) 2013-2016 Chef Software, Inc.
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");
@@ -25,9 +25,12 @@ class Chef
25
25
  class Service
26
26
  include Cloud::Helpers
27
27
  attr_accessor :ui
28
+ attr_accessor :config
29
+ attr_reader :auth_params
28
30
 
29
- def initialize(options = {})
30
- @auth_params = options[:auth_params]
31
+ def initialize(config:, auth_params: nil)
32
+ @config = config
33
+ @auth_params = auth_params
31
34
  end
32
35
 
33
36
  def connection
@@ -78,7 +81,7 @@ class Chef
78
81
  end
79
82
 
80
83
  def add_custom_attributes(server_def)
81
- Chef::Config[:knife][:custom_attributes].map { |args| args.map { |k, v| server_def.merge!(k.to_sym => v) } } unless Chef::Config[:knife][:custom_attributes].nil?
84
+ config[:custom_attributes].map { |args| args.map { |k, v| server_def.merge!(k.to_sym => v) } } unless config[:custom_attributes].nil?
82
85
  end
83
86
 
84
87
  end # class service
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Cloud
3
- VERSION = "3.0.3".freeze
3
+ VERSION = "4.0.6".freeze
4
4
  MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end
@@ -1,6 +1,6 @@
1
- require "securerandom"
2
- require "tmpdir"
3
- require "fileutils"
1
+ require "securerandom" unless defined?(SecureRandom)
2
+ require "tmpdir" unless defined?(Dir.mktmpdir)
3
+ require "fileutils" unless defined?(FileUtils)
4
4
  require File.expand_path(File.dirname(__FILE__) + "/knife_test_utils")
5
5
  require File.expand_path(File.dirname(__FILE__) + "/matchers")
6
6
 
@@ -1,4 +1,4 @@
1
- require "mixlib/shellout"
1
+ require "mixlib/shellout" unless defined?(Mixlib::ShellOut)
2
2
 
3
3
  module RSpec
4
4
  module KnifeTestUtils
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 4.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaustubh Deorukhkar
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-05-21 00:00:00.000000000 Z
12
+ date: 2020-09-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: '15.0'
20
+ version: '15.11'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: '15.0'
27
+ version: '15.11'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: mixlib-shellout
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -102,12 +102,11 @@ post_install_message:
102
102
  rdoc_options: []
103
103
  require_paths:
104
104
  - lib
105
- - spec
106
105
  required_ruby_version: !ruby/object:Gem::Requirement
107
106
  requirements:
108
107
  - - ">="
109
108
  - !ruby/object:Gem::Version
110
- version: 2.2.5
109
+ version: '2.6'
111
110
  required_rubygems_version: !ruby/object:Gem::Requirement
112
111
  requirements:
113
112
  - - ">="