dpl 1.6.6.travis.492.1 → 1.6.6.travis.496.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +1 -0
- data/README.md +7 -0
- data/lib/dpl/provider.rb +14 -0
- data/lib/dpl/provider/gcs.rb +20 -5
- data/lib/dpl/provider/s3.rb +0 -14
- data/spec/provider/gcs_spec.rb +62 -0
- data/spec/provider_spec.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmVkYmQ0NTM5ZjkxNzBiMWUwMGQyZGU1Y2JlYTA3YjQzNTNmYmFmMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTUxZTNjNWFlMzY1ZjRkZTI4YTFmMTYzZDA1OWY4N2Q0MmY3YTM1Zg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YWE4NjZlNDM3MzVhMGRlNDRlZTc3NDdjY2NlYjUyZjU5YmQzMzI5NTk2YzQ0
|
10
|
+
NjczOTRhMWM3YmIyN2ZiNzQ2ZTYwMWNmZGYwMmM3YTJjYmUyMTE1YjEzZjk1
|
11
|
+
NWE5MjJlODAyYzFiYjNkMzFlZmJkNjMwNTg3ODI5Nzc5YWQ2MWY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDE2NTYyMDg5ZTJlYzY3ZDFkZWM2N2ZlZTNhNzE5MDc4YWEwZTQzNmQwMWZk
|
14
|
+
NjJiY2M4NDlmYTRlN2JlYjIwNjZlYTNiMmQ2N2NlYjNjNTUxZWJlMDBiYTVm
|
15
|
+
MDQ3Yzk3ZWNlNDczNzkwN2RmYzJlNWRhOTExNzkxMGM2Mjk5OTg=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -343,10 +343,17 @@ For accounts using two factor authentication, you have to use an oauth token as
|
|
343
343
|
* **access-key-id**: GCS Interoperable Access Key ID. Info about Interoperable Access Key from [here](https://developers.google.com/storage/docs/migrating).
|
344
344
|
* **secret-access-key**: GCS Interoperable Access Secret.
|
345
345
|
* **bucket**: GCS Bucket.
|
346
|
+
* **upload-dir**: GCS directory to upload to. Defaults to root directory.
|
346
347
|
* **local-dir**: Local directory to upload from. Can be set from a global perspective (~/travis/build) or relative perspective (build) Defaults to project root.
|
347
348
|
* **dot_match**: When set to `true`, upload files starting a `.`.
|
349
|
+
* **detect-encoding**: Set HTTP header `Content-Encoding` for files compressed with `gzip` and `compress` utilities. Defaults to not set.
|
350
|
+
* **cache_control**: Set HTTP header `Cache-Control` to suggest that the browser cache the file. Defaults to not set. Info is [here](https://developers.google.com/storage/docs/reference-headers#cachecontrol)
|
351
|
+
* **acl**: Sets the access control for the uploaded objects. Defaults to not set. Info is [here](https://developers.google.com/storage/docs/reference-headers#xgoogacl)
|
348
352
|
|
349
353
|
#### Examples:
|
350
354
|
|
351
355
|
dpl --provider=gcs --access-key-id=<access-key-id> --secret-access-key=<secret-access-key> --bucket=<bucket>
|
352
356
|
dpl --provider=gcs --access-key-id=<access-key-id> --secret-access-key=<secret-access-key> --bucket=<bucket> --local-dir= BUILD
|
357
|
+
dpl --provider=gcs --access-key-id=<access-key-id> --secret-access-key=<secret-access-key> --bucket=<bucket> --acl=public-read
|
358
|
+
dpl --provider=gcs --access-key-id=<access-key-id> --secret-access-key=<secret-access-key> --bucket=<bucket> --detect-encoding --cache_control=max-age=99999
|
359
|
+
dpl --provider=gcs --access-key-id=<access-key-id> --secret-access-key=<secret-access-key> --bucket=<bucket> --local-dir=BUILD --upload-dir=BUILDS
|
data/lib/dpl/provider.rb
CHANGED
@@ -165,6 +165,20 @@ module DPL
|
|
165
165
|
ENV['GIT_SSH'] = path
|
166
166
|
end
|
167
167
|
|
168
|
+
def detect_encoding?
|
169
|
+
options[:detect_encoding]
|
170
|
+
end
|
171
|
+
|
172
|
+
def encoding_for(path)
|
173
|
+
file_cmd_output = `file #{path}`
|
174
|
+
case file_cmd_output
|
175
|
+
when /gzip compressed/
|
176
|
+
'gzip'
|
177
|
+
when /compress'd/
|
178
|
+
'compress'
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
168
182
|
def log(message)
|
169
183
|
$stderr.puts(message)
|
170
184
|
end
|
data/lib/dpl/provider/gcs.rb
CHANGED
@@ -4,7 +4,7 @@ module DPL
|
|
4
4
|
class Provider
|
5
5
|
class GCS < Provider
|
6
6
|
requires 'gstore'
|
7
|
-
|
7
|
+
requires 'mime-types'
|
8
8
|
|
9
9
|
def needs_key?
|
10
10
|
false
|
@@ -21,24 +21,39 @@ module DPL
|
|
21
21
|
log "Logging in with Access Key: #{option(:access_key_id)[-4..-1].rjust(20, '*')}"
|
22
22
|
end
|
23
23
|
|
24
|
+
def upload_path(filename)
|
25
|
+
[options[:upload_dir], filename].compact.join("/")
|
26
|
+
end
|
27
|
+
|
24
28
|
def push_app
|
25
29
|
glob_args = ["**/*"]
|
26
30
|
glob_args << File::FNM_DOTMATCH if options[:dot_match]
|
27
31
|
Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
|
28
32
|
Dir.glob(*glob_args) do |filename|
|
29
33
|
next if File.directory?(filename)
|
30
|
-
|
31
|
-
|
34
|
+
content_type = MIME::Types.type_for(filename).first.to_s
|
35
|
+
opts = { :"Content-Type" => content_type }.merge(encoding_option_for(filename))
|
36
|
+
opts["Cache-Control"] = options[:cache_control] if options[:cache_control]
|
37
|
+
opts["x-goog-acl"] = options[:acl] if options[:acl]
|
32
38
|
|
33
39
|
client.put_object(
|
34
40
|
option(:bucket),
|
35
|
-
filename,
|
36
|
-
:data => File.read(filename)
|
41
|
+
upload_path(filename),
|
42
|
+
{ :data => File.read(filename), :headers => opts }
|
37
43
|
)
|
38
44
|
end
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
48
|
+
private
|
49
|
+
def encoding_option_for(path)
|
50
|
+
if detect_encoding? && encoding_for(path)
|
51
|
+
{"Content-Encoding" => encoding_for(path)}
|
52
|
+
else
|
53
|
+
{}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
42
57
|
end
|
43
58
|
end
|
44
59
|
end
|
data/lib/dpl/provider/s3.rb
CHANGED
@@ -59,20 +59,6 @@ module DPL
|
|
59
59
|
end
|
60
60
|
|
61
61
|
private
|
62
|
-
def detect_encoding?
|
63
|
-
options[:detect_encoding]
|
64
|
-
end
|
65
|
-
|
66
|
-
def encoding_for(path)
|
67
|
-
file_cmd_output = `file #{path}`
|
68
|
-
case file_cmd_output
|
69
|
-
when /gzip compressed/
|
70
|
-
'gzip'
|
71
|
-
when /compress'd/
|
72
|
-
'compress'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
62
|
def encoding_option_for(path)
|
77
63
|
if detect_encoding? && encoding_for(path)
|
78
64
|
{:content_encoding => encoding_for(path)}
|
data/spec/provider/gcs_spec.rb
CHANGED
@@ -20,6 +20,21 @@ describe DPL::Provider::GCS do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
describe "#upload_path" do
|
24
|
+
example "Without: :upload_dir" do
|
25
|
+
filename = "testfile.file"
|
26
|
+
|
27
|
+
expect(provider.upload_path(filename)).to eq("testfile.file")
|
28
|
+
end
|
29
|
+
|
30
|
+
example "With :upload_dir" do
|
31
|
+
provider.options.update(:upload_dir => 'BUILD3')
|
32
|
+
filename = "testfile.file"
|
33
|
+
|
34
|
+
expect(provider.upload_path(filename)).to eq("BUILD3/testfile.file")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
23
38
|
describe "#push_app" do
|
24
39
|
example "Without local_dir" do
|
25
40
|
expect(Dir).to receive(:chdir).with(Dir.pwd)
|
@@ -33,12 +48,59 @@ describe DPL::Provider::GCS do
|
|
33
48
|
provider.push_app
|
34
49
|
end
|
35
50
|
|
51
|
+
example "Sends MIME type" do
|
52
|
+
expect(Dir).to receive(:glob).and_yield(__FILE__)
|
53
|
+
expect_any_instance_of(GStore::Client).to receive(:put_object).with(
|
54
|
+
anything(),
|
55
|
+
anything(),
|
56
|
+
hash_including(:headers => {:"Content-Type" => 'application/x-ruby'})
|
57
|
+
)
|
58
|
+
provider.push_app
|
59
|
+
end
|
60
|
+
|
61
|
+
example "Sets Cache" do
|
62
|
+
provider.options.update(:cache_control => "max-age=99999999")
|
63
|
+
expect(Dir).to receive(:glob).and_yield(__FILE__)
|
64
|
+
expect_any_instance_of(GStore::Client).to receive(:put_object).with(
|
65
|
+
anything(),
|
66
|
+
anything(),
|
67
|
+
hash_including(:headers => hash_including("Cache-Control" => 'max-age=99999999'))
|
68
|
+
)
|
69
|
+
provider.push_app
|
70
|
+
end
|
71
|
+
|
72
|
+
example "Sets ACL" do
|
73
|
+
provider.options.update(:acl => "public-read")
|
74
|
+
expect(Dir).to receive(:glob).and_yield(__FILE__)
|
75
|
+
expect_any_instance_of(GStore::Client).to receive(:put_object).with(
|
76
|
+
anything(),
|
77
|
+
anything(),
|
78
|
+
hash_including(:headers => hash_including("x-goog-acl" => 'public-read'))
|
79
|
+
)
|
80
|
+
provider.push_app
|
81
|
+
end
|
82
|
+
|
83
|
+
example "when detect_encoding is set" do
|
84
|
+
path = 'foo.js'
|
85
|
+
provider.options.update(:detect_encoding => true)
|
86
|
+
expect(Dir).to receive(:glob).and_yield(path)
|
87
|
+
expect(provider).to receive(:`).at_least(1).times.with("file #{path}").and_return('gzip compressed')
|
88
|
+
expect(File).to receive(:read).with(path).and_return("")
|
89
|
+
expect_any_instance_of(GStore::Client).to receive(:put_object).with(
|
90
|
+
anything(),
|
91
|
+
anything(),
|
92
|
+
hash_including(:headers => hash_including("Content-Encoding" => 'gzip'))
|
93
|
+
)
|
94
|
+
provider.push_app
|
95
|
+
end
|
96
|
+
|
36
97
|
example "With dot_match" do
|
37
98
|
provider.options.update(:dot_match => true)
|
38
99
|
|
39
100
|
expect(Dir).to receive(:glob).with('**/*', File::FNM_DOTMATCH)
|
40
101
|
provider.push_app
|
41
102
|
end
|
103
|
+
|
42
104
|
end
|
43
105
|
|
44
106
|
describe '#client' do
|
data/spec/provider_spec.rb
CHANGED
@@ -126,6 +126,21 @@ describe DPL::Provider do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
describe "#detect_encoding?" do
|
130
|
+
example do
|
131
|
+
provider.options.update(:detect_encoding => true)
|
132
|
+
expect(provider.detect_encoding?).to eq(true)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "#encoding_for" do
|
137
|
+
example do
|
138
|
+
path = 'foo.js'
|
139
|
+
expect(provider).to receive(:`).at_least(1).times.with("file #{path}").and_return('gzip compressed')
|
140
|
+
expect(provider.encoding_for(path)).to eq('gzip')
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
129
144
|
describe "#log" do
|
130
145
|
example do
|
131
146
|
expect($stderr).to receive(:puts).with("foo")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dpl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.6.travis.
|
4
|
+
version: 1.6.6.travis.496.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|