Module: Cumulus::S3::Loader
- Includes:
- Common::BaseLoader
- Defined in:
- lib/s3/loader/Loader.rb
Constant Summary collapse
- @@buckets_dir =
Configuration.instance.s3.buckets_directory
- @@cors_dir =
Configuration.instance.s3.cors_directory
- @@policies_dir =
Configuration.instance.s3.policies_directory
Class Method Summary collapse
-
.bucket_policy(name, vars) ⇒ Object
Public: Load a specific bucket policy by name, applying any variables.
-
.buckets ⇒ Object
Public: Load all the bucket configurations a BucketConfig objects.
-
.cors_policy(name, vars) ⇒ Object
Public: Load a specific CORS policy by name, applying any variables.
Methods included from Common::BaseLoader
load_file, resource, resources, template
Class Method Details
.bucket_policy(name, vars) ⇒ Object
Public: Load a specific bucket policy by name, applying any variables
name - the name of the file to load vars - the variables to apply to the template
Returns the bucket policy as a string
57 58 59 60 61 62 63 64 |
# File 'lib/s3/loader/Loader.rb', line 57 def self.bucket_policy(name, vars) Common::BaseLoader.template( name, @@policies_dir, vars, &proc { |n, json| json.deep_sort.to_json } ) end |
.buckets ⇒ Object
Public: Load all the bucket configurations a BucketConfig objects
Returns an array of BucketConfigs
20 21 22 |
# File 'lib/s3/loader/Loader.rb', line 20 def self.buckets Common::BaseLoader.resources(@@buckets_dir, &BucketConfig.method(:new)) end |
.cors_policy(name, vars) ⇒ Object
Public: Load a specific CORS policy by name, applying any variables.
name - the name of the file to load vars - the variables to apply to the template
Returns the CORS policy as a string
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/s3/loader/Loader.rb', line 30 def self.cors_policy(name, vars) Common::BaseLoader.template( name, @@cors_dir, vars, &proc do |n, json| json.map do |rule| Aws::S3::Types::CORSRule.new({ allowed_headers: rule.fetch("headers"), allowed_methods: rule.fetch("methods"), allowed_origins: rule.fetch("origins"), expose_headers: rule.fetch("exposed-headers"), max_age_seconds: rule.fetch("max-age-seconds") }) end end ) rescue KeyError puts "CORS configuration #{name} does not contain all required keys." exit end |