lib/ec2ssh/dsl.rb in ec2ssh-3.1.1 vs lib/ec2ssh/dsl.rb in ec2ssh-4.0.0
- old
+ new
@@ -1,16 +1,26 @@
require 'ec2ssh/exceptions'
+require 'aws-sdk'
module Ec2ssh
class Dsl
attr_reader :_result
+ CREDENTIAL_CLASSES = [Aws::Credentials, Aws::SharedCredentials, Aws::InstanceProfileCredentials, Aws::AssumeRoleCredentials].freeze
+ private_constant :CREDENTIAL_CLASSES
+
def initialize
@_result = Container.new
end
def aws_keys(keys)
+ unless keys.all? {|_, v| v.is_a?(Hash) && v.each_value.all? {|c| CREDENTIAL_CLASSES.any?(&c.method(:is_a?)) } }
+ raise DotfileValidationError, <<-MSG
+Since v4.0, `aws_keys` in the dotfile must be specified regions as a hash key.
+See: https://github.com/mirakui/ec2ssh#how-to-upgrade-from-3x
+ MSG
+ end
@_result.aws_keys = keys
end
def profiles(*profiles)
@_result.profiles = profiles
@@ -26,19 +36,24 @@
def reject(&block)
@_result.reject = block
end
+ def filters(filters)
+ @_result.filters = filters
+ end
+
def path(str)
@_result.path = str
end
class Container < Struct.new(*%i[
aws_keys
profiles
regions
host_line
reject
+ filters
path
])
end
module Parser