Class: Longleaf::S3LocationValidator

Inherits:
Object
  • Object
show all
Defined in:
lib/longleaf/services/s3_location_validator.rb

Overview

Validates the configuration of a s3 based location

Class Method Summary collapse

Class Method Details

.validate(p_validator, name, path_prop, section_name, path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/longleaf/services/s3_location_validator.rb', line 8

def self.validate(p_validator, name, path_prop, section_name, path)
  base_msg = "Storage location '#{name}' specifies invalid #{section_name} '#{path_prop}' property: "
  p_validator.assert(base_msg + 'Path must not be empty', !path.nil? && !path.to_s.strip.empty?)
  begin
    bucket_name = S3UriHelper.extract_bucket(path)
    p_validator.assert(base_msg + 'Path must specify a bucket', !bucket_name.nil?)
  rescue ArgumentError => e
    p_validator.fail(base_msg + e.message)
  end
end