module Dopi::CommandParser::Credentials
Public Instance Methods
credentials()
click to toggle source
# File lib/dopi/command_parser/credentials.rb, line 25 def credentials @credentials ||= credentials_valid? ? parse_credentials : [] end
validate_credentials()
click to toggle source
# File lib/dopi/command_parser/credentials.rb, line 21 def validate_credentials log_validation_method('credentials_valid?', CommandParsingError) end
Private Instance Methods
credentials_valid?()
click to toggle source
# File lib/dopi/command_parser/credentials.rb, line 31 def credentials_valid? return false unless hash.kind_of?(Hash) # plugin may not have parameters key_aliases(hash, :credentials, ['credentials', :credential, 'credential']) return false if hash[:credentials].nil? # credentials is optional hash[:credentials].kind_of?(String) or hash[:credentials].kind_of?(Array) or raise CommandParsingError, "the value for 'credentials' has to be a string or an array of strings" [hash[:credentials]].flatten.each do |c| c.kind_of?(String) or raise CommandParsingError, "All values in the 'credentials' array have to be strings" @step.plan.credentials.has_key?(c) or raise CommandParsingError, "Credentials #{c} are not configured" if self.methods.include?(:supported_credential_types) cred_type = @step.plan.credentials[c].type supported_credential_types.include?(cred_type) or raise CommandParsingError, "Credential #{c} is of type #{cred_type}, which is not supported by the plugin" end end true end
parse_credentials()
click to toggle source
# File lib/dopi/command_parser/credentials.rb, line 51 def parse_credentials [hash[:credentials]].flatten.map{|c| @step.plan.credentials[c]} end