Sha256: dba35963f88c7b81fcbe448972238f16ac96385c15775ac695105aec9c9de5be
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require_relative "includes" require_relative "logging" class AwsAssumeRole::Runner < Dry::Struct include AwsAssumeRole::Logging constructor_type :schema attribute :command, Dry::Types["coercible.array"].member(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 def initialize(options) super(options) command_to_exec = command.join(" ") process_credentials unless credentials.blank? system environment, command_to_exec exit_status = $CHILD_STATUS.exitstatus process_error(exit_status) if exit_status != expected_exit_code end private def process_credentials cred_env = { "AWS_ACCESS_KEY_ID" => credentials.credentials.access_key_id, "AWS_SECRET_ACCESS_KEY" => credentials.credentials.secret_access_key, "AWS_SESSION_TOKEN" => credentials.credentials.session_token, } @environment = environment.merge cred_env end def process_error(exit_status) logger.error "#{command} failed with #{exit_status}" exit exit_status if exit_on_error raise "#{command} failed with #{exit_status}" end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
aws_assume_role-0.2.2 | lib/aws_assume_role/runner.rb |
aws_assume_role-0.2.0 | lib/aws_assume_role/runner.rb |
aws_assume_role-0.1.2 | lib/aws_assume_role/runner.rb |