shred 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shred/commands/s3.rb +29 -4
- data/lib/shred/version.rb +1 -1
- data/lib/shred.yml.tt +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ebc646e30059b1b213e40852da3996c35fc4ea0
|
4
|
+
data.tar.gz: 9db8cfd8a2899f6084bc4d5796f8de6772dc6ff7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77cc7cd9d43dcdf9981567c0156ab8b593355bc1a9218ed11194189c45df8875b566ae4659f9eebfd00f2c9281029385770231b8b14b53c4000033569099fa2d
|
7
|
+
data.tar.gz: f74ceb2db0ff64d82c6c82f563c1cf516a5aef0b9171ad998ad34df4946dd3bd1fc4f45814f175f577da87f0d7168d3c67e9ae55e5995fb6291dc13fe0bd9997
|
data/lib/shred/commands/s3.rb
CHANGED
@@ -31,21 +31,46 @@ module Shred
|
|
31
31
|
cfg('buckets').each do |(key, bucket_cfg)|
|
32
32
|
name = interpolate_value(bucket_cfg['name'])
|
33
33
|
region = interpolate_value(bucket_cfg['region'])
|
34
|
+
cors_cfg = bucket_cfg['cors']
|
35
|
+
files_cfg = bucket_cfg['files']
|
34
36
|
|
35
|
-
create_bucket(name, region)
|
37
|
+
create_bucket(name, region, cors: cors_cfg, files: files_cfg)
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
39
41
|
no_commands do
|
40
|
-
def create_bucket(name, region)
|
42
|
+
def create_bucket(name, region, cors: nil, files: nil)
|
41
43
|
s3 = AWS::S3.new(region: region)
|
42
44
|
region ||= 'default'
|
43
|
-
|
45
|
+
bucket = s3.buckets[name]
|
46
|
+
if bucket.exists?
|
44
47
|
console.say_ok("S3 bucket #{name} already exists in #{region} region")
|
45
48
|
else
|
46
|
-
s3.buckets.create(name)
|
49
|
+
bucket = s3.buckets.create(name)
|
47
50
|
console.say_ok("Created S3 bucket #{name} in #{region} region")
|
48
51
|
end
|
52
|
+
if cors
|
53
|
+
rules = cors.map do |id, rule_cfg|
|
54
|
+
{
|
55
|
+
allowed_methods: Array(rule_cfg['allowed_methods']),
|
56
|
+
allowed_origins: Array(rule_cfg['allowed_origins']),
|
57
|
+
allowed_headers: Array(rule_cfg['allowed_headers']),
|
58
|
+
max_age_seconds: rule_cfg['max_age_seconds'],
|
59
|
+
expose_headers: Array(rule_cfg['expose_headers'])
|
60
|
+
}
|
61
|
+
end
|
62
|
+
bucket.cors.set(rules)
|
63
|
+
console.say_ok("Set CORS config for bucket #{name}")
|
64
|
+
end
|
65
|
+
if files
|
66
|
+
files.map do |id, file_cfg|
|
67
|
+
path = interpolate_value(file_cfg['path'])
|
68
|
+
key = interpolate_value(file_cfg['key'])
|
69
|
+
acl = interpolate_value(file_cfg['acl'])
|
70
|
+
bucket.objects[key].write(Pathname.new(path), acl: acl)
|
71
|
+
console.say_ok("Uploaded file #{path} to bucket #{name} at #{key}")
|
72
|
+
end
|
73
|
+
end
|
49
74
|
end
|
50
75
|
end
|
51
76
|
end
|
data/lib/shred/version.rb
CHANGED
data/lib/shred.yml.tt
CHANGED
@@ -90,6 +90,18 @@ commands:
|
|
90
90
|
default:
|
91
91
|
name: '{env:AWS_S3_BUCKET}'
|
92
92
|
region: '{env:AWS_S3_REGION}'
|
93
|
+
cors:
|
94
|
+
local:
|
95
|
+
allowed_methods:
|
96
|
+
- POST
|
97
|
+
- PUT
|
98
|
+
allowed_origins: 'http://*.example.com'
|
99
|
+
allowed_headers: '*'
|
100
|
+
files:
|
101
|
+
crossdomain:
|
102
|
+
path: etc/crossdomain.xml
|
103
|
+
key: 'crossdomain.xml'
|
104
|
+
acl: public_read
|
93
105
|
setup:
|
94
106
|
platform_deps: install
|
95
107
|
services: start
|