diff --git a/.expeditor/verify.pipeline.yml b/.expeditor/verify.pipeline.yml index 6cbf037..ff4b968 100644 --- a/.expeditor/verify.pipeline.yml +++ b/.expeditor/verify.pipeline.yml @@ -10,13 +10,6 @@ expeditor: timeout_in_minutes: 30 steps: -- label: run-specs-ruby-2.5 - command: - - .expeditor/run_linux_tests.sh rake - expeditor: - executor: - docker: - image: ruby:2.5-buster - label: run-specs-ruby-2.6 command: - .expeditor/run_linux_tests.sh rake diff --git a/Gemfile b/Gemfile index 01f3194..295ca52 100644 --- a/Gemfile +++ b/Gemfile @@ -10,8 +10,8 @@ end group :test do gem "chef" - if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.6") - gem "chef-zero", "~> 14" + if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("2.7") + gem "chef-zero", "~> 15" end gem "chefstyle", "~> 1.0" gem "rake", ">= 10.0" diff --git a/knife-vrealize.gemspec b/knife-vrealize.gemspec index 2705e32..ace8174 100644 --- a/knife-vrealize.gemspec +++ b/knife-vrealize.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |spec| spec.files = Dir["lib/**/*"] + %w{LICENSE} spec.require_paths = ["lib"] - spec.required_ruby_version = ">= 2.5" + spec.required_ruby_version = ">= 2.6" spec.add_dependency "knife-cloud", ">= 1.2.0", "< 5.0" spec.add_dependency "vmware-vra", "~> 2" diff --git a/lib/chef/knife/cloud/vra_service.rb b/lib/chef/knife/cloud/vra_service.rb index ab843c5..de4f52f 100644 --- a/lib/chef/knife/cloud/vra_service.rb +++ b/lib/chef/knife/cloud/vra_service.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +30,7 @@ class Cloud class VraService < Service include VraServiceHelpers def initialize(options = {}) - super(options) + super(config: options) @username = options[:username] @password = options[:password] diff --git a/lib/chef/knife/cloud/vra_service_helpers.rb b/lib/chef/knife/cloud/vra_service_helpers.rb index 3c0b5f4..a7be993 100644 --- a/lib/chef/knife/cloud/vra_service_helpers.rb +++ b/lib/chef/knife/cloud/vra_service_helpers.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,16 +27,16 @@ module VraServiceHelpers include Chef::Knife::Cloud::Helpers def create_service_instance - Chef::Knife::Cloud::VraService.new(username: locate_config_value(:vra_username), - password: locate_config_value(:vra_password), - base_url: locate_config_value(:vra_base_url), - tenant: locate_config_value(:vra_tenant), - page_size: locate_config_value(:vra_page_size), + Chef::Knife::Cloud::VraService.new(username: config[:vra_username], + password: config[:vra_password], + base_url: config[:vra_base_url], + tenant: config[:vra_tenant], + page_size: config[:vra_page_size], verify_ssl: verify_ssl?) end def verify_ssl? - !locate_config_value(:vra_disable_ssl_verify) + !config[:vra_disable_ssl_verify] end def wait_for_request(request, wait_time = 600, refresh_rate = 2) @@ -78,7 +78,7 @@ def validate! # rubocop:disable Style/GuardClause def check_for_missing_config_values!(*keys) - missing = keys.select { |x| locate_config_value(x).nil? } + missing = keys.select { |x| config[x].nil? } unless missing.empty? ui.error("The following required parameters are missing: #{missing.join(", ")}") diff --git a/lib/chef/knife/cloud/vra_service_options.rb b/lib/chef/knife/cloud/vra_service_options.rb index 3e3f8ba..df9ff84 100644 --- a/lib/chef/knife/cloud/vra_service_options.rb +++ b/lib/chef/knife/cloud/vra_service_options.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/knife/vra_catalog_list.rb b/lib/chef/knife/vra_catalog_list.rb index f10ad9e..39d1edd 100644 --- a/lib/chef/knife/vra_catalog_list.rb +++ b/lib/chef/knife/vra_catalog_list.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,19 +20,22 @@ require "chef/knife" require "chef/knife/cloud/list_resource_command" -require_relative "cloud/vra_service" -require_relative "cloud/vra_service_helpers" require_relative "cloud/vra_service_options" class Chef class Knife class Cloud class VraCatalogList < ResourceListCommand - include VraServiceHelpers include VraServiceOptions banner "knife vra catalog list" + deps do + require_relative "cloud/vra_service" + require_relative "cloud/vra_service_helpers" + include VraServiceHelpers + end + option :entitled, long: "--entitled-only", description: "only list entitled vRA catalog entries", @@ -52,7 +55,7 @@ def before_exec_command end def query_resource - @service.list_catalog_items(locate_config_value(:entitled)) + @service.list_catalog_items(config[:entitled]) end def format_status_value(status) diff --git a/lib/chef/knife/vra_server_create.rb b/lib/chef/knife/vra_server_create.rb index 281668a..6b5baa4 100644 --- a/lib/chef/knife/vra_server_create.rb +++ b/lib/chef/knife/vra_server_create.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,6 @@ require "chef/knife" require "chef/knife/cloud/server/create_command" require "chef/knife/cloud/server/create_options" -require_relative "cloud/vra_service" -require_relative "cloud/vra_service_helpers" require_relative "cloud/vra_service_options" class Chef @@ -35,6 +33,11 @@ class VraServerCreate < ServerCreateCommand banner "knife vra server create CATALOG_ID (options)" + deps do + require_relative "cloud/vra_service" + require_relative "cloud/vra_service_helpers" + end + option :cpus, long: "--cpus NUM_CPUS", description: "Number of CPUs the server should have" @@ -97,22 +100,22 @@ def before_exec_command @create_options = { catalog_id: @name_args.first, - cpus: locate_config_value(:cpus), - memory: locate_config_value(:memory), - requested_for: locate_config_value(:requested_for), - subtenant_id: locate_config_value(:subtenant_id), - lease_days: locate_config_value(:lease_days), - notes: locate_config_value(:notes), + cpus: config[:cpus], + memory: config[:memory], + requested_for: config[:requested_for], + subtenant_id: config[:subtenant_id], + lease_days: config[:lease_days], + notes: config[:notes], extra_params: extra_params, - wait_time: locate_config_value(:server_create_timeout), - refresh_rate: locate_config_value(:request_refresh_rate), + wait_time: config[:server_create_timeout], + refresh_rate: config[:request_refresh_rate], } end def before_bootstrap super - config[:chef_node_name] = locate_config_value(:chef_node_name) ? locate_config_value(:chef_node_name) : server.name + config[:chef_node_name] = config[:chef_node_name] ? config[:chef_node_name] : server.name config[:bootstrap_ip_address] = hostname_for_server end diff --git a/lib/chef/knife/vra_server_delete.rb b/lib/chef/knife/vra_server_delete.rb index ca40fc5..468cb6f 100644 --- a/lib/chef/knife/vra_server_delete.rb +++ b/lib/chef/knife/vra_server_delete.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,6 @@ require "chef/knife" require "chef/knife/cloud/server/delete_options" require "chef/knife/cloud/server/delete_command" -require_relative "cloud/vra_service" -require_relative "cloud/vra_service_helpers" require_relative "cloud/vra_service_options" class Chef @@ -30,11 +28,16 @@ class Knife class Cloud class VraServerDelete < ServerDeleteCommand include ServerDeleteOptions - include VraServiceHelpers include VraServiceOptions banner "knife vra server delete RESOURCE_ID [RESOURCE_ID] (options)" + deps do + require_relative "cloud/vra_service" + require_relative "cloud/vra_service_helpers" + include VraServiceHelpers + end + # rubocop:disable Style/GuardClause def validate_params! if @name_args.empty? diff --git a/lib/chef/knife/vra_server_list.rb b/lib/chef/knife/vra_server_list.rb index fb1e318..f304f84 100644 --- a/lib/chef/knife/vra_server_list.rb +++ b/lib/chef/knife/vra_server_list.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,19 +21,22 @@ require "chef/knife" require "chef/knife/cloud/server/list_command" require "chef/knife/cloud/server/list_options" -require_relative "cloud/vra_service" -require_relative "cloud/vra_service_helpers" require_relative "cloud/vra_service_options" class Chef class Knife class Cloud class VraServerList < ServerListCommand - include VraServiceHelpers include VraServiceOptions banner "knife vra server list" + deps do + require_relative "cloud/vra_service" + require_relative "cloud/vra_service_helpers" + include VraServiceHelpers + end + def before_exec_command @columns_with_info = [ { label: "Resource ID", key: "id" }, diff --git a/lib/chef/knife/vra_server_show.rb b/lib/chef/knife/vra_server_show.rb index 2df089f..0bacbf8 100644 --- a/lib/chef/knife/vra_server_show.rb +++ b/lib/chef/knife/vra_server_show.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,6 @@ require "chef/knife" require "chef/knife/cloud/server/show_options" require "chef/knife/cloud/server/show_command" -require_relative "cloud/vra_service" -require_relative "cloud/vra_service_helpers" require_relative "cloud/vra_service_options" class Chef @@ -30,11 +28,16 @@ class Knife class Cloud class VraServerShow < ServerShowCommand include ServerShowOptions - include VraServiceHelpers include VraServiceOptions banner "knife vra server show RESOURCE_ID (options)" + deps do + require_relative "cloud/vra_service" + require_relative "cloud/vra_service_helpers" + include VraServiceHelpers + end + def validate_params! if @name_args.empty? ui.error("You must supply a Resource ID for a server to display.") diff --git a/lib/chef/knife/vro_workflow_execute.rb b/lib/chef/knife/vro_workflow_execute.rb index e4a9638..af021d8 100644 --- a/lib/chef/knife/vro_workflow_execute.rb +++ b/lib/chef/knife/vro_workflow_execute.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -60,14 +60,14 @@ class VroWorkflowExecute < Chef::Knife default: 300 def verify_ssl? - !locate_config_value(:vro_disable_ssl_verify) + !config[:vro_disable_ssl_verify] end def vro_config @vro_config ||= VcoWorkflows::Config.new( - url: locate_config_value(:vro_base_url), - username: locate_config_value(:vro_username), - password: locate_config_value(:vro_password), + url: config[:vro_base_url], + username: config[:vro_username], + password: config[:vro_password], verify_ssl: verify_ssl? ) end @@ -105,7 +105,7 @@ def execute_workflow end def wait_for_workflow - wait_time = locate_config_value(:request_timeout) + wait_time = config[:request_timeout] Timeout.timeout(wait_time) do loop do token = vro_client.token @@ -120,7 +120,7 @@ def wait_for_workflow def missing_config_parameters %i{vro_username vro_password vro_base_url}.each_with_object([]) do |param, memo| - memo << param if locate_config_value(param).nil? + memo << param if config[param].nil? end end @@ -129,7 +129,6 @@ def validate! print_error_and_exit("The following parameters are missing but required:" \ "#{missing_config_parameters.join(", ")}") end - print_error_and_exit("You must supply a workflow name.") if @name_args.empty? end @@ -165,7 +164,7 @@ def print_execution_log def set_parameters self.workflow_name = @name_args.shift - self.workflow_id = locate_config_value(:vro_workflow_id) + self.workflow_id = config[:vro_workflow_id] self.parameters = parse_and_validate_params!(@name_args) end diff --git a/lib/knife-vrealize/version.rb b/lib/knife-vrealize/version.rb index 0538a03..2e68e7e 100644 --- a/lib/knife-vrealize/version.rb +++ b/lib/knife-vrealize/version.rb @@ -2,7 +2,7 @@ # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 01d9122..5c33cf3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: Copyright (c) 2015 Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/support/shared_examples_for_command.rb b/spec/support/shared_examples_for_command.rb index e8441b7..bf1905f 100644 --- a/spec/support/shared_examples_for_command.rb +++ b/spec/support/shared_examples_for_command.rb @@ -1,7 +1,7 @@ # # Author:: Mukta Aphale () # Author:: Siddheshwar More () -# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,7 @@ shared_examples_for Chef::Knife::Cloud::Command do |instance| it "runs with correct method calls" do allow(instance).to receive(:execute_command) - allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new) + allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new(config: instance.config)) expect(instance).to receive(:set_default_config).ordered expect(instance).to receive(:validate!).ordered expect(instance).to receive(:validate_params!).ordered diff --git a/spec/support/shared_examples_for_command_bootstrap.rb b/spec/support/shared_examples_for_command_bootstrap.rb index 43d0627..1aa06c2 100644 --- a/spec/support/shared_examples_for_command_bootstrap.rb +++ b/spec/support/shared_examples_for_command_bootstrap.rb @@ -1,7 +1,7 @@ # # Author:: Ashwini Nehate() # Author:: Kapil Chouhan () -# Copyright:: Copyright (c) 2008-2019 Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +22,7 @@ shared_examples_for Chef::Knife::Cloud::BootstrapCommand do |instance| it "runs with correct method calls" do allow(instance).to receive(:execute_command) - allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new) + allow(instance).to receive(:create_service_instance).and_return(Chef::Knife::Cloud::Service.new(config: instance.config)) expect(instance).to receive(:set_default_config).ordered expect(instance).to receive(:validate!).ordered expect(instance).to receive(:validate_params!).ordered diff --git a/spec/support/shared_examples_for_servercreatecommand.rb b/spec/support/shared_examples_for_servercreatecommand.rb index ed25ad3..028af0d 100644 --- a/spec/support/shared_examples_for_servercreatecommand.rb +++ b/spec/support/shared_examples_for_servercreatecommand.rb @@ -1,7 +1,7 @@ # # Author:: Mukta Aphale () # Author:: Siddheshwar More () -# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,7 +45,7 @@ def get_mock_resource(id) allow(instance).to receive(:after_exec_command) allow(instance).to receive(:validate!) allow(instance).to receive(:validate_params!) - instance.service = Chef::Knife::Cloud::Service.new + instance.service = Chef::Knife::Cloud::Service.new(config: instance.config) allow(instance).to receive(:create_service_instance).and_return(instance.service) allow(instance.service).to receive(:get_image).and_return(get_mock_resource("image_id")) allow(instance.service).to receive(:get_flavor).and_return(get_mock_resource("flavor_id")) @@ -69,7 +69,7 @@ def get_mock_resource(id) allow(instance).to receive(:after_exec_command) allow(instance).to receive(:validate!) allow(instance).to receive(:validate_params!) - instance.service = Chef::Knife::Cloud::Service.new + instance.service = Chef::Knife::Cloud::Service.new(config: instance.config) allow(instance).to receive(:create_service_instance).and_return(instance.service) allow(instance.service).to receive(:create_server).and_raise(Chef::Knife::Cloud::CloudExceptions::ServerCreateError) expect(instance.service).to receive(:delete_server_dependencies) @@ -127,7 +127,7 @@ def get_mock_resource(id) describe "#cleanup_on_failure" do it "delete server dependencies on delete_server_on_failure set" do instance.config[:delete_server_on_failure] = true - instance.service = Chef::Knife::Cloud::Service.new + instance.service = Chef::Knife::Cloud::Service.new(config: instance.config) expect(instance.service).to receive(:delete_server_dependencies) expect(instance.service).to receive(:delete_server_on_failure) instance.cleanup_on_failure diff --git a/spec/support/shared_examples_for_serverdeletecommand.rb b/spec/support/shared_examples_for_serverdeletecommand.rb index dc69626..426cfcc 100644 --- a/spec/support/shared_examples_for_serverdeletecommand.rb +++ b/spec/support/shared_examples_for_serverdeletecommand.rb @@ -1,7 +1,7 @@ # # Author:: Mukta Aphale () # Author:: Siddheshwar More () -# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/support/shared_examples_for_service.rb b/spec/support/shared_examples_for_service.rb index f00b9ed..c07ac2c 100644 --- a/spec/support/shared_examples_for_service.rb +++ b/spec/support/shared_examples_for_service.rb @@ -1,7 +1,7 @@ # # Author:: Mukta Aphale () # Author:: Siddheshwar More () -# Copyright:: Copyright (c) 2013-2014 Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/cloud/vra_service_helpers_spec.rb b/spec/unit/cloud/vra_service_helpers_spec.rb index 01a1531..c96d3da 100644 --- a/spec/unit/cloud/vra_service_helpers_spec.rb +++ b/spec/unit/cloud/vra_service_helpers_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,6 +23,10 @@ require "chef/knife/cloud/vra_service_helpers" class HelpersTester + def config + @config ||= {} + end + include Chef::Knife::Cloud::VraServiceHelpers attr_accessor :ui end @@ -36,12 +40,12 @@ class HelpersTester describe "#create_service_instance" do it "creates a service instance" do - allow(subject).to receive(:locate_config_value).with(:vra_username).and_return("myuser") - allow(subject).to receive(:locate_config_value).with(:vra_password).and_return("mypassword") - allow(subject).to receive(:locate_config_value).with(:vra_base_url).and_return("https://vra.corp.local") - allow(subject).to receive(:locate_config_value).with(:vra_tenant).and_return("mytenant") - allow(subject).to receive(:locate_config_value).with(:vra_page_size).and_return(50) - allow(subject).to receive(:locate_config_value).with(:vra_disable_ssl_verify).and_return(false) + subject.config[:vra_username] = "myuser" + subject.config[:vra_password] = "mypassword" + subject.config[:vra_base_url] = "https://vra.corp.local" + subject.config[:vra_tenant] = "mytenant" + subject.config[:vra_page_size] = 50 + subject.config[:vra_disable_ssl_verify] = false expect(Chef::Knife::Cloud::VraService).to receive(:new) .with(username: "myuser", @@ -58,14 +62,14 @@ class HelpersTester describe "#verify_ssl?" do context "when vra_disable_ssl_verify is true" do it "returns false" do - allow(subject).to receive(:locate_config_value).with(:vra_disable_ssl_verify).and_return(true) + subject.config[:vra_disable_ssl_verify] = true expect(subject.verify_ssl?).to be false end end context "when vra_disable_ssl_verify is false" do it "returns true" do - allow(subject).to receive(:locate_config_value).with(:vra_disable_ssl_verify).and_return(false) + subject.config[:vra_disable_ssl_verify] = false expect(subject.verify_ssl?).to be true end end @@ -134,8 +138,8 @@ class HelpersTester describe "#check_for_missing_config_values!" do context "when all values exist" do it "does not raise an error" do - allow(subject).to receive(:locate_config_value).with(:key1).and_return("value") - allow(subject).to receive(:locate_config_value).with(:key2).and_return("value") + subject.config[:key1] = "value" + subject.config[:key2] = "value" expect(subject.ui).not_to receive(:error) expect { subject.check_for_missing_config_values!(:key1, :key2) }.not_to raise_error end diff --git a/spec/unit/cloud/vra_service_spec.rb b/spec/unit/cloud/vra_service_spec.rb index 5ec8c9e..9a53465 100644 --- a/spec/unit/cloud/vra_service_spec.rb +++ b/spec/unit/cloud/vra_service_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/vra_catalog_list_spec.rb b/spec/unit/vra_catalog_list_spec.rb index 295f82a..ea8c74c 100644 --- a/spec/unit/vra_catalog_list_spec.rb +++ b/spec/unit/vra_catalog_list_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/vra_server_create_spec.rb b/spec/unit/vra_server_create_spec.rb index d44c973..9af1e42 100644 --- a/spec/unit/vra_server_create_spec.rb +++ b/spec/unit/vra_server_create_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,8 +31,8 @@ argv += %w{--cpus 1} argv += %w{--memory 512} argv += %w{--requested-for myuser@corp.local} - argv += %w{--bootstrap-protocol ssh} - argv += %w{--ssh-password password} + argv += %w{--connection-protocol ssh} + argv += %w{--connection-password password} argv += %w{--extra-param key1=string:value1} argv += %w{--extra-param key2=integer:2} argv += %w{d5ba201a-449f-47a4-9d02-39196224bf01} @@ -49,8 +49,8 @@ argv += %w{--cpus 1} argv += %w{--memory 512} argv += %w{--requested-for myuser@corp.local} - argv += %w{--bootstrap-protocol ssh} - argv += %w{--ssh-password password} + argv += %w{--connection-protocol ssh} + argv += %w{--connection-password password} command = Chef::Knife::Cloud::VraServerCreate.new(argv) expect(command.ui).to receive(:error) @@ -102,8 +102,8 @@ argv += %w{--cpus 1} argv += %w{--memory 512} argv += %w{--requested-for myuser@corp.local} - argv += %w{--bootstrap-protocol ssh} - argv += %w{--ssh-password password} + argv += %w{--connection-protocol ssh} + argv += %w{--connection-password password} command = Chef::Knife::Cloud::VraServerCreate.new(argv) expect { command.validate_extra_params! }.not_to raise_error @@ -122,8 +122,8 @@ argv += %w{--cpus 1} argv += %w{--memory 512} argv += %w{--requested-for myuser@corp.local} - argv += %w{--bootstrap-protocol ssh} - argv += %w{--ssh-password password} + argv += %w{--connection-protocol ssh} + argv += %w{--connection-password password} argv += %w{d5ba201a-449f-47a4-9d02-39196224bf01} argv += %w{--extra-param key1=value1} command = Chef::Knife::Cloud::VraServerCreate.new(argv) @@ -138,8 +138,8 @@ argv += %w{--cpus 1} argv += %w{--memory 512} argv += %w{--requested-for myuser@corp.local} - argv += %w{--bootstrap-protocol ssh} - argv += %w{--ssh-password password} + argv += %w{--connection-protocol ssh} + argv += %w{--connection-password password} argv += %w{d5ba201a-449f-47a4-9d02-39196224bf01} argv += %w{--extra-param key1=faketype:value1} command = Chef::Knife::Cloud::VraServerCreate.new(argv) diff --git a/spec/unit/vra_server_delete_spec.rb b/spec/unit/vra_server_delete_spec.rb index 5db3772..2d072ed 100644 --- a/spec/unit/vra_server_delete_spec.rb +++ b/spec/unit/vra_server_delete_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/vra_server_list_spec.rb b/spec/unit/vra_server_list_spec.rb index c4d0e3c..5af2da1 100644 --- a/spec/unit/vra_server_list_spec.rb +++ b/spec/unit/vra_server_list_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/vra_server_show_spec.rb b/spec/unit/vra_server_show_spec.rb index 3408ab1..438e092 100644 --- a/spec/unit/vra_server_show_spec.rb +++ b/spec/unit/vra_server_show_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/spec/unit/vro_workflow_execute_spec.rb b/spec/unit/vro_workflow_execute_spec.rb index 931a131..29a312a 100644 --- a/spec/unit/vro_workflow_execute_spec.rb +++ b/spec/unit/vro_workflow_execute_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true # # Author:: Chef Partner Engineering () -# Copyright:: 2015-2019, Chef Software, Inc. +# Copyright:: Copyright (c) Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -40,10 +40,10 @@ subject { described_class.new(argv) } before(:each) do - Chef::Config[:knife][:vro_username] = vro_username - Chef::Config[:knife][:vro_password] = vro_password - Chef::Config[:knife][:vro_base_url] = vro_base_url - Chef::Config[:knife][:vro_disable_ssl_verify] = vro_disable_ssl_verify + subject.config[:vro_username] = vro_username + subject.config[:vro_password] = vro_password + subject.config[:vro_base_url] = vro_base_url + subject.config[:vro_disable_ssl_verify] = vro_disable_ssl_verify end describe "#verify_ssl?" do @@ -179,7 +179,7 @@ context "when the timeout is exceeded" do before do - Chef::Config[:knife][:request_timeout] = 600 + subject.config[:request_timeout] = 600 end it "raises a Timeout exception" do allow(Timeout).to receive(:timeout).and_raise(Timeout::Error) @@ -209,7 +209,7 @@ context "when a parameter is missing" do before do - Chef::Config[:knife][:vro_username] = nil + subject.config[:vro_username] = nil end it "returns an array with that parameter" do expect(subject.missing_config_parameters).to eq([ :vro_username ]) @@ -230,6 +230,7 @@ context "when no workflow name is provided" do let(:knife) { Chef::Knife::VroWorkflowExecute.new } it "calls #print_error_and_exit" do + allow(knife).to receive(:missing_config_parameters).and_return([]) expect(knife).to receive(:print_error_and_exit) knife.validate!