lib/ec2ssh/dsl.rb in ec2ssh-3.0.3 vs lib/ec2ssh/dsl.rb in ec2ssh-3.1.0.rc1
- old
+ new
@@ -10,10 +10,14 @@
def aws_keys(keys)
@_result.aws_keys = keys
end
+ def profiles(*profiles)
+ @_result.profiles = profiles
+ end
+
def regions(*regions)
@_result.regions = regions
end
def host_line(erb)
@@ -28,10 +32,11 @@
@_result.path = str
end
class Container < Struct.new(*%i[
aws_keys
+ profiles
regions
host_line
reject
path
])
@@ -39,17 +44,23 @@
module Parser
def self.parse(dsl_str)
dsl = Dsl.new
dsl.instance_eval dsl_str
- dsl._result
+ dsl._result.tap {|result| validate result }
rescue SyntaxError => e
raise DotfileSyntaxError, e.to_s
end
def self.parse_file(path)
raise DotfileNotFound, path.to_s unless File.exist?(path)
parse File.read(path)
+ end
+
+ def self.validate(result)
+ if result.aws_keys && result.profiles
+ raise DotfileValidationError, "`aws_keys` and `profiles` doesn't work together in dotfile."
+ end
end
end
end
end