capistrano-s3_archive 0.3.11 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/Vagrantfile +1 -0
- data/lib/capistrano/s3_archive/version.rb +1 -1
- data/lib/capistrano/s3_archive.rb +23 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a39563c25ae86411a943e19dd385a89ebee8af8
|
4
|
+
data.tar.gz: 80dbefa17168b54970c6dbd6855e160c00f611f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac00224eca008d5ea8e22f22b89f55b1667b3d6245d7f7c7eeee08a0437d12efc221df4ff7c094617c87b4aef53f0869c4b20779afb78755d9af90d3dbf44b82
|
7
|
+
data.tar.gz: ed74bca574e0a3f3b2d418074abc5bd9f80b39a1594fc5a0cf0a988477b919c4f0f000f85260ba7ef01c1f0aac24889ca88973b49163415e31e984b50ea9f9bb
|
data/README.md
CHANGED
@@ -61,6 +61,7 @@ Set parameters with `set :key, value`.
|
|
61
61
|
Key | Default | Description
|
62
62
|
--------------|---------|------------
|
63
63
|
branch | `latest` | The S3 Object basename to download. Support `:latest` or such as `'201506011500.zip'`.
|
64
|
+
version_id | nil | Version ID of version-controlled S3 object. It should use with `:branch`. e.g. `set :branch, 'myapp.zip'; set :version_id, 'qawsedrftgyhujikolq'`
|
64
65
|
sort_proc | `->(a,b) { b.key <=> a.key }` | Sort algorithm used to detect `:latest` object basename. It should be proc object for `a,b` as `Aws::S3::Object` comparing.
|
65
66
|
rsync_options | `['-az']` | Options used to rsync.
|
66
67
|
local_cache | `tmp/deploy` | Path where to extruct your archive on local for staging and rsyncing. Can be both relative or absolute.
|
data/Vagrantfile
CHANGED
@@ -25,7 +25,17 @@ module Capistrano
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def get_object(target)
|
28
|
-
|
28
|
+
opts = { bucket: bucket, key: archive_object_key }
|
29
|
+
opts[:version_id] = fetch(:version_id) if fetch(:version_id)
|
30
|
+
s3_client.get_object(opts, target: target)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_object_metadata
|
34
|
+
s3_client.list_object_versions(bucket: bucket, prefix: archive_object_key).versions.find do |v|
|
35
|
+
if fetch(:version_id) then v.version_id == fetch(:version_id)
|
36
|
+
else v.is_latest
|
37
|
+
end
|
38
|
+
end
|
29
39
|
end
|
30
40
|
|
31
41
|
def list_objects(all_page = true)
|
@@ -80,17 +90,23 @@ module Capistrano
|
|
80
90
|
|
81
91
|
def stage
|
82
92
|
stage_lock do
|
83
|
-
|
93
|
+
archive_dir = File.join(fetch(:s3_archive), fetch(:stage).to_s)
|
94
|
+
archive_file = File.join(archive_dir, File.basename(archive_object_key))
|
84
95
|
tmp_file = "#{archive_file}.part"
|
96
|
+
etag_file = File.join(archive_dir, ".#{File.basename(archive_object_key)}.etag")
|
85
97
|
fail "#{tmp_file} is found. Another process is running?" if File.exist?(tmp_file)
|
86
|
-
|
98
|
+
|
99
|
+
etag = get_object_metadata.tap { |it| fail "No such object: #{current_revision}" if it.nil? }.etag
|
100
|
+
if [archive_file, etag_file].all? { |f| File.exist?(f) } && File.read(etag_file) == etag
|
101
|
+
context.info "#{archive_file} (etag:#{etag}) is found. download skipped."
|
102
|
+
else
|
103
|
+
context.info "Download #{current_revision} to #{archive_file}"
|
87
104
|
mkdir_p(File.dirname(archive_file))
|
88
105
|
File.open(tmp_file, 'w') do |f|
|
89
106
|
get_object(f)
|
90
107
|
end
|
91
108
|
move(tmp_file, archive_file)
|
92
|
-
|
93
|
-
context.info "#{archive_file} is found."
|
109
|
+
File.write(etag_file, etag)
|
94
110
|
end
|
95
111
|
|
96
112
|
remove_entry_secure(fetch(:local_cache_dir)) if File.exist? fetch(:local_cache_dir)
|
@@ -161,7 +177,7 @@ module Capistrano
|
|
161
177
|
end
|
162
178
|
|
163
179
|
def current_revision
|
164
|
-
archive_object_key
|
180
|
+
fetch(:version_id) ? "#{archive_object_key}?versionid=#{fetch(:version_id)}" : archive_object_key
|
165
181
|
end
|
166
182
|
|
167
183
|
def ssh_key_for(host)
|
@@ -169,7 +185,7 @@ module Capistrano
|
|
169
185
|
host.keys.first
|
170
186
|
elsif host.ssh_options && host.ssh_options.has_key?(:keys)
|
171
187
|
Array(host.ssh_options[:keys]).first
|
172
|
-
|
188
|
+
elsif fetch(:ssh_options, nil) && fetch(:ssh_options).has_key?(:keys)
|
173
189
|
fetch(:ssh_options)[:keys].first
|
174
190
|
end
|
175
191
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-s3_archive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takuto Komazaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|