Skip to content

Commit

Permalink
Merge pull request #488 from AlexanderZagaynov/aws_sdk_v3
Browse files Browse the repository at this point in the history
update aws-sdk gem to v3
  • Loading branch information
agrare authored Oct 21, 2019
2 parents 29d66e5 + 8be7e04 commit 9e84410
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 124 deletions.
4 changes: 2 additions & 2 deletions app/models/authenticator/amazon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ def aws_connect(access_key_id, secret_access_key, service = :IAM, proxy_uri = ni
service ||= :EC2
proxy_uri ||= VMDB::Util.http_proxy_uri

require 'aws-sdk'
require 'patches/aws-sdk-core/seahorse_client_net_http_pool_patch'
require "aws-sdk-#{service.to_s.downcase}"

Aws.const_get(service)::Resource.new(
:access_key_id => access_key_id,
:secret_access_key => secret_access_key,
Expand Down
7 changes: 2 additions & 5 deletions app/models/manageiq/providers/amazon/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ def verify_credentials(args)

def raw_connect(access_key_id, secret_access_key, service, region,
proxy_uri = nil, validate = false, uri = nil, assume_role: nil)

require 'aws-sdk'
require 'patches/aws-sdk-core/seahorse_client_net_http_pool_patch'
require "aws-sdk-#{service.to_s.downcase}"

log_formatter_pattern = Aws::Log::Formatter.default.pattern.chomp
secret_access_key = ManageIQ::Password.try_decrypt(secret_access_key)
Expand Down Expand Up @@ -128,8 +126,7 @@ def connection_rescue_block
end

def translate_exception(err)
require 'aws-sdk'
require 'patches/aws-sdk-core/seahorse_client_net_http_pool_patch'
require 'aws-sdk-ec2'
case err
when Aws::EC2::Errors::SignatureDoesNotMatch
MiqException::MiqHostError.new "SignatureMismatch - check your AWS Secret Access Key and signing method"
Expand Down
46 changes: 0 additions & 46 deletions lib/patches/aws-sdk-core/seahorse_client_net_http_pool_patch.rb

This file was deleted.

2 changes: 1 addition & 1 deletion manageiq-providers-amazon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|

s.files = Dir["{app,config,lib}/**/*"]

s.add_dependency("aws-sdk", ["~>2.9.7"])
s.add_dependency "aws-sdk", "~> 3.0.1"

s.add_development_dependency "codeclimate-test-reporter", "~> 1.0.0"
s.add_development_dependency "simplecov"
Expand Down

This file was deleted.

3 changes: 2 additions & 1 deletion spec/models/authenticator/amazon_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'aws-sdk'
require 'aws-sdk-iam'
require 'aws-sdk-ec2'

describe Authenticator::Amazon do
AWS_ROOT_USER_KEY = 'aws_root_key'.freeze
Expand Down
11 changes: 6 additions & 5 deletions spec/models/manageiq/providers/amazon/aws_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
require 'aws-sdk'

def with_aws_stubbed(stub_responses_per_service)
stub_responses_per_service.each do |service, stub_responses|
raise "Aws.config[#{service}][:stub_responses] already set" if Aws.config.fetch(service, {})[:stub_responses]
Aws.config[service] ||= {}
Aws.config[service][:stub_responses] = stub_responses
if Aws.config.dig(service, :stub_responses).present?
raise "Aws.config[#{service}][:stub_responses] already set"
else
require "aws-sdk-#{service.to_s.downcase}"
(Aws.config[service] ||= {})[:stub_responses] = stub_responses
end
end
yield
ensure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require_relative "../../aws_helper"

require 'aws-sdk-sns'

describe ManageIQ::Providers::Amazon::CloudManager::EventCatcher::Stream do
subject do
ems = FactoryBot.create(:ems_amazon_with_authentication)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

context "OrchestrationStack refresh" do
context "with all empty relations" do
let(:mocked_stack_parameters) { nil }
let(:mocked_stack_resources) { nil }
let(:mocked_stack_outputs) { nil }
let(:mocked_stack_parameters) { [] }
let(:mocked_stack_resources) { [] }
let(:mocked_stack_outputs) { [] }

it "tests refresh passes" do
with_aws_stubbed(stub_responses) do
Expand All @@ -47,7 +47,7 @@
end

context "with empty parameters relation" do
let(:mocked_stack_parameters) { nil }
let(:mocked_stack_parameters) { [] }

it "tests refresh passes" do
with_aws_stubbed(stub_responses) do
Expand All @@ -62,7 +62,7 @@
end

context "with empty outputs relation" do
let(:mocked_stack_outputs) { nil }
let(:mocked_stack_outputs) { [] }

it "tests refresh passes" do
with_aws_stubbed(stub_responses) do
Expand All @@ -77,7 +77,7 @@
end

context "with empty resources relation" do
let(:mocked_stack_resources) { nil }
let(:mocked_stack_resources) { [] }

it "tests refresh passes" do
with_aws_stubbed(stub_responses) do
Expand Down

0 comments on commit 9e84410

Please sign in to comment.