class Bosh::Workspace::Schemas::Credentials

Public Instance Methods

validate(object) click to toggle source
# File lib/bosh/workspace/schemas/credentials.rb, line 6
def validate(object)
  Membrane::SchemaParser.parse do
    [enum(UsernamePassword.new, SshKey.new)]
  end.validate object
  validate_protocol_credentials_combination(object)
end
validate_protocol_credentials_combination(object) click to toggle source
# File lib/bosh/workspace/schemas/credentials.rb, line 13
def validate_protocol_credentials_combination(object)
  object.each do |creds|
    case git_protocol_from_url(creds['url'])
    when :https, :http
      next if creds.keys.include? 'username'
      validation_err "Provide username/password for: #{creds['url']}"
    when :ssh
      next if creds.keys.include? 'private_key'
      validation_err "Provide private_key for: #{creds['url']}"
    else
      validation_err "Credentials not supported for: #{creds['url']}"
    end
  end
end
validation_err(message) click to toggle source
# File lib/bosh/workspace/schemas/credentials.rb, line 28
def validation_err(message)
  raise Membrane::SchemaValidationError.new(message)
end