Skip to content

Commit

Permalink
Merge pull request #36 from scalefactory/20180614_forward_fixes
Browse files Browse the repository at this point in the history
Support new dry-* gems
  • Loading branch information
MrPrimate committed Jun 20, 2018
2 parents 4416405 + 957bdd9 commit eed636b
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 26 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Expand Up @@ -3,13 +3,12 @@ sudo: false
script: bundle exec rake
jobs:
include:
- stage: test
rvm: 2.2
script: bundle exec rake
- rvm: 2.3
script: bundle exec rake
- rvm: 2.5
script: bundle exec rake
- stage: deploy
rvm: 2.3
rvm: 2.5
script: bundle exec rake setup_credentials && chmod 0600 /home/travis/.gem/credentials && bundle exec rake publish
stages:
- name: test
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,10 @@
## 1.2.0
* Support latest version of `dry-*` gems
* Requires ruby 2.3

## 1.1.2
* Pin breaking upstream `dry-*` gems until code is fixed in aws_assume_role

## 1.1.1
* Allow aws-assume-role to retrieve all Yubikey stored OATH tokens (@alanthing)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -25,7 +25,7 @@ For more information on role assumption, see the [AWS documentation](https://doc

Requirements
------------
* Ruby ≥ 2.2
* Ruby ≥ 2.3
* macOS Keychain / GNOME Keyring
* At least one account with Amazon Web Services
* An IAM role configured in the target account
Expand Down
8 changes: 4 additions & 4 deletions aws_assume_role.gemspec
Expand Up @@ -30,9 +30,9 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "activesupport", "~> 4.2"
spec.add_runtime_dependency "aws-sdk", "~> 2.7"
spec.add_runtime_dependency "dry-configurable", "~> 0.5"
spec.add_runtime_dependency "dry-struct", "~> 0.1"
spec.add_runtime_dependency "dry-types", "~> 0.12"
spec.add_runtime_dependency "dry-validation", "~> 0.10"
spec.add_runtime_dependency "dry-struct", "~> 0.5"
spec.add_runtime_dependency "dry-types", "~> 0.13"
spec.add_runtime_dependency "dry-validation", "~> 0.11"
spec.add_runtime_dependency "gli", "~> 2.15"
spec.add_runtime_dependency "highline", "~> 1.6"
spec.add_runtime_dependency "i18n", "~> 0.7"
Expand All @@ -50,7 +50,7 @@ Gem::Specification.new do |spec|

case PLATFORM
when /linux|bsd/
spec.add_dependency "gir_ffi-gnome_keyring", "~> 0.0", ">= 0.0.3"
spec.add_dependency "gir_ffi-gnome_keyring", "~> 0.0", ">= 0.0.9"
when /darwin/
spec.add_dependency "ruby-keychain", "~> 0.3", ">= 0.3.2"
end
Expand Down
Expand Up @@ -9,7 +9,7 @@ class AwsAssumeRole::Credentials::Factories::AbstractFactory
include AwsAssumeRole::Credentials::Factories
include AwsAssumeRole::Logging

Dry::Types.register_class(Aws::SharedCredentials)
Dry::Types.register("aws.sharedcredentials", Aws::SharedCredentials)
attr_reader :credentials, :region, :profile, :role_arn

def initialize(_options)
Expand Down
Expand Up @@ -12,10 +12,11 @@
require_relative "static"

class AwsAssumeRole::Credentials::Factories::DefaultChainProvider < Dry::Struct
constructor_type :schema
include AwsAssumeRole::Credentials::Factories
include AwsAssumeRole::Logging

transform_types { |t| t.meta(omittable: true) }

attribute :access_key_id, Dry::Types["strict.string"].optional
attribute :credentials, Dry::Types["object"].optional
attribute :duration_seconds, Dry::Types["coercible.int"].optional
Expand Down
4 changes: 3 additions & 1 deletion lib/aws_assume_role/credentials/factories/repository.rb
Expand Up @@ -6,7 +6,9 @@
class AwsAssumeRole::Credentials::Factories::Repository
include AwsAssumeRole::Credentials::Factories

SubFactoryRepositoryType = Types::Hash.schema(Types::Coercible::Int => Types::Strict::Array)
SubFactoryRepositoryType = Types::Hash.schema(
Types::Coercible::Int => Types::Strict::Array.meta(omittable: true),
)

FactoryRepositoryType = Types::Hash.schema(
credential_provider: SubFactoryRepositoryType,
Expand Down
Expand Up @@ -12,27 +12,38 @@
end

class AwsAssumeRole::Credentials::Providers::MfaSessionCredentials < Dry::Struct
constructor_type :schema
include AwsAssumeRole::Vendored::Aws::CredentialProvider
include AwsAssumeRole::Vendored::Aws::RefreshingCredentials
include AwsAssumeRole::Ui
include AwsAssumeRole::Logging

attribute :permanent_credentials, Dry::Types["object"].optional
attribute :credentials, Dry::Types["object"].optional
attribute :expiration, Dry::Types["strict.time"].default(Time.now)
attribute :first_time, Dry::Types["strict.bool"].default(true)
attribute :persist_session, Dry::Types["strict.bool"].default(true)
attribute :duration_seconds, Dry::Types["coercible.int"].default(3600)
attribute :region, AwsAssumeRole::Types::Region.optional
attribute :serial_number, AwsAssumeRole::Types::MfaSerial.optional.default("automatic")
transform_types { |t| t.meta(omittable: true) }

attribute :permanent_credentials, Dry::Types["object"]
attribute :credentials, Dry::Types["object"]
attribute :expiration, (Dry::Types["strict.time"]
.default(Time.now)
.constructor { |v| v.nil? ? Dry::Types::Undefined : v })
attribute :first_time, (Dry::Types["strict.bool"]
.default(true)
.constructor { |v| v.nil? ? Dry::Types::Undefined : v })
attribute :persist_session, (Dry::Types["strict.bool"]
.default(true)
.constructor { |v| v.nil? ? Dry::Types::Undefined : v })
attribute :duration_seconds, (Dry::Types["coercible.int"]
.default(3600)
.constructor { |v| v.nil? ? Dry::Types::Undefined : v })
attribute :region, AwsAssumeRole::Types::Region
attribute :serial_number, (AwsAssumeRole::Types::MfaSerial
.default("automatic")
.constructor { |v| v.nil? ? Dry::Types::Undefined : v })
attribute :yubikey_oath_name, Dry::Types["strict.string"].optional

def initialize(options)
options.each { |key, value| instance_variable_set("@#{key}", value) }
@permanent_credentials ||= @credentials
@credentials = nil
@serial_number = resolve_serial_number(serial_number)
@serial_number = resolve_serial_number(@serial_number)
AwsAssumeRole::Vendored::Aws::RefreshingCredentials.instance_method(:initialize).bind(self).call(options)
end

Expand Down
3 changes: 2 additions & 1 deletion lib/aws_assume_role/profile_configuration.rb
Expand Up @@ -4,8 +4,9 @@
require_relative "logging"

class AwsAssumeRole::ProfileConfiguration < Dry::Struct
constructor_type :schema
include AwsAssumeRole::Logging
transform_types { |t| t.meta(omittable: true) }

attribute :access_key_id, Dry::Types["strict.string"].optional
attribute :credentials, Dry::Types["object"].optional
attribute :secret_access_key, Dry::Types["strict.string"].optional
Expand Down
3 changes: 2 additions & 1 deletion lib/aws_assume_role/runner.rb
Expand Up @@ -5,13 +5,14 @@

class AwsAssumeRole::Runner < Dry::Struct
include AwsAssumeRole::Logging
constructor_type :schema
attribute :command, Dry::Types["coercible.array"].of(Dry::Types["strict.string"]).default([])
attribute :exit_on_error, Dry::Types["strict.bool"].default(true)
attribute :expected_exit_code, Dry::Types["strict.int"].default(0)
attribute :environment, Dry::Types["strict.hash"].default({})
attribute :credentials, Dry::Types["object"].optional

transform_types { |t| t.meta(omittable: true) }

def initialize(options)
super(options)
command_to_exec = command.map(&:shellescape).join(" ")
Expand Down
2 changes: 1 addition & 1 deletion lib/aws_assume_role/types.rb
Expand Up @@ -5,7 +5,7 @@ module AwsAssumeRole
module Types
Dry = Dry::Types.module

::Dry::Types.register_class(::Aws::Credentials)
::Dry::Types.register("aws.credentials", ::Aws::Credentials)
AwsAssumeRole::Types::Credentials = ::Dry::Types["aws.credentials"]

ACCESS_KEY_REGEX = /[\w]+/
Expand Down
2 changes: 1 addition & 1 deletion lib/aws_assume_role/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module AwsAssumeRole
VERSION = "1.1.1".freeze
VERSION = "1.2.0".freeze
end

0 comments on commit eed636b

Please sign in to comment.