Sha256: 826f1c2c4221e16261738639f60c4b42298f98bcaf4a5fb2a80f3361d5f7c833
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
require_relative "includes" require_relative "../../profile_configuration" class AwsAssumeRole::Cli::Actions::AbstractAction include AwsAssumeRole include AwsAssumeRole::Types include AwsAssumeRole::Ui include AwsAssumeRole::Logging CommandSchema = proc { raise "CommandSchema Not implemented" } def initialize(global_options, options, args) config = ProfileConfiguration.new_from_cli(global_options, options, args) logger.debug "Config initialized with #{config.to_hash}" result = validate_options(config.to_hash) logger.debug "Config validated as #{result.to_hash}" return act_on(config) if result.success? Ui.show_validation_errors result end private def try_for_credentials(config) @provider ||= AwsAssumeRole::Credentials::Factories::DefaultChainProvider.new(config.to_hash) creds = @provider.resolve(nil_with_role_not_set: true) logger.debug "Got credentials #{creds}" return creds unless creds.nil? rescue Smartcard::PCSC::Exception error t("errors.SmartcardException") exit 403 rescue NoMethodError error t("errors.MissingCredentialsError") exit 404 end def resolved_region @provider.region end def resolved_profile @provider.profile end def validate_options(options) command_schema = self.class::CommandSchema ::Dry::Validation.Schema do configure { config.messages = :i18n } instance_eval(&command_schema) end.call(options) end def prompt_for_option(key, option_name, validator, fmt: nil) text_lookup = t("options.#{key}") text = fmt.nil? ? text_lookup : format(text_lookup, fmt) Ui.ask_with_validation(option_name, text) { instance_eval(&validator) } end def act_on(_options) raise "Act On Not Implemented" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aws_assume_role-0.2.2 | lib/aws_assume_role/cli/actions/abstract_action.rb |
aws_assume_role-0.2.0 | lib/aws_assume_role/cli/actions/abstract_action.rb |