scout-camp 0.1.10 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.vimproject +1 -0
- data/VERSION +1 -1
- data/lib/scout/aws/s3.rb +70 -4
- data/lib/scout/offsite/resource.rb +1 -1
- data/scout-camp.gemspec +2 -2
- data/scout_commands/sync +1 -0
- data/share/aws/lambda_function.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4310a29a500f7fe04fb974b8a5cb3ae5aae506a9a3663663ec6bd86270c17fd2
|
4
|
+
data.tar.gz: a6e9b6a396a76f9ddde67a502658b9cb37cddeb12355c1bbe244c5f1ff7c3f36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86dbee75e288daf9d1be188a9d13e79b9656314ef3345e24d226fd79fa987c7723c4bd1d2df488a5a2e56e04cdcb97bf69e4a2ef0f2a88bde00713978ff3b4be
|
7
|
+
data.tar.gz: 7d7bd20736cad39b68d9dc0406490a5ea2a5095bec45dfe550fd2e5131ecbbdf4ecfbd21ac523cfcddadd163c4988465ad6358038d38a9c3d5151a48c50cb6cb
|
data/.vimproject
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.11
|
data/lib/scout/aws/s3.rb
CHANGED
@@ -21,14 +21,18 @@ module Open
|
|
21
21
|
uri.start_with? 's3://'
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.
|
24
|
+
def self.claim_uri(uri)
|
25
25
|
if Path === uri and not uri.located?
|
26
|
-
is_s3?
|
26
|
+
is_s3?(uri.find)
|
27
27
|
else
|
28
28
|
is_s3? uri
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
def self.claim(uri, uri2=nil, ...)
|
33
|
+
claim_uri(uri) || (String === uri2 && claim_uri(uri2))
|
34
|
+
end
|
35
|
+
|
32
36
|
def self.parse_s3_uri(uri)
|
33
37
|
uri = uri.find if Path === uri and not uri.located?
|
34
38
|
uri = uri.sub(%r{^s3://}, '')
|
@@ -66,13 +70,12 @@ module Open
|
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
69
|
-
def self.glob(uri, pattern="
|
73
|
+
def self.glob(uri, pattern="*")
|
70
74
|
bucket, prefix = parse_s3_uri(uri)
|
71
75
|
s3 = Aws::S3::Client.new
|
72
76
|
matches = []
|
73
77
|
continuation_token = nil
|
74
78
|
|
75
|
-
Log.debug "Glob: #{uri} #{pattern}"
|
76
79
|
loop do
|
77
80
|
resp = s3.list_objects_v2(
|
78
81
|
bucket: bucket,
|
@@ -185,6 +188,7 @@ module Open
|
|
185
188
|
bucket, key = parse_s3_uri(uri)
|
186
189
|
return false if key.empty? # Can't check existence of bucket this way
|
187
190
|
|
191
|
+
key += '/' unless key.end_with?('/')
|
188
192
|
s3 = Aws::S3::Client.new
|
189
193
|
response = s3.list_objects_v2({
|
190
194
|
bucket: bucket,
|
@@ -224,6 +228,68 @@ module Open
|
|
224
228
|
def self.ln_s(source, target, options = {})
|
225
229
|
cp(source, target)
|
226
230
|
end
|
231
|
+
|
232
|
+
def self.sync(source, target, options = {})
|
233
|
+
excludes, files, hard_link, test, print, delete, other = IndiferentHash.process_options options,
|
234
|
+
:excludes, :files, :hard_link, :test, :print, :delete, :other
|
235
|
+
|
236
|
+
excludes ||= %w(.save .crap .source tmp filecache open-remote)
|
237
|
+
excludes = excludes.split(/,\s*/) if excludes.is_a?(String) and not excludes.include?("--exclude")
|
238
|
+
|
239
|
+
if File.directory?(source) || source.end_with?("/")
|
240
|
+
source += "/" unless source.end_with? '/'
|
241
|
+
target += "/" unless target.end_with? '/'
|
242
|
+
end
|
243
|
+
|
244
|
+
if source == target
|
245
|
+
Log.warn "Asking to sync with itself"
|
246
|
+
return
|
247
|
+
end
|
248
|
+
|
249
|
+
Log.low "Migrating #{source} #{files.length} files to #{target} - #{Misc.fingerprint(files)}}" if files
|
250
|
+
|
251
|
+
sync_args = %w()
|
252
|
+
sync_args << excludes.collect{|s| "--exclude '#{s}'" } if excludes and excludes.any?
|
253
|
+
sync_args << "-nv" if test
|
254
|
+
|
255
|
+
if files
|
256
|
+
tmp_files = TmpFile.tmp_file 's3_sync_files-'
|
257
|
+
Open.write(tmp_files, files * "\n")
|
258
|
+
sync_args << "--files-from='#{tmp_files}'"
|
259
|
+
end
|
260
|
+
|
261
|
+
if Open.directory?(source)
|
262
|
+
cmd = "aws s3 sync #{sync_args * " "} #{source} #{target}"
|
263
|
+
else
|
264
|
+
cmd = "aws s3 cp #{source} #{target}"
|
265
|
+
end
|
266
|
+
case other
|
267
|
+
when String
|
268
|
+
cmd << " " << other
|
269
|
+
when Array
|
270
|
+
cmd << " " << other * " "
|
271
|
+
end
|
272
|
+
cmd << " && rm -Rf #{source}" if delete && ! files
|
273
|
+
|
274
|
+
if print
|
275
|
+
cmd
|
276
|
+
else
|
277
|
+
CMD.cmd_log(cmd, :log => Log::HIGH)
|
278
|
+
|
279
|
+
if delete && files
|
280
|
+
remove_files = files.collect{|f| File.join(source, f) }
|
281
|
+
dirs = remove_files.select{|f| File.directory? f }
|
282
|
+
remove_files.each do |file|
|
283
|
+
next if dirs.include? file
|
284
|
+
Open.rm file
|
285
|
+
end
|
286
|
+
|
287
|
+
dirs.each do |dir|
|
288
|
+
FileUtils.rmdir dir if Dir.glob(dir).empty?
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
227
293
|
end
|
228
294
|
end
|
229
295
|
|
@@ -11,7 +11,7 @@ module Resource
|
|
11
11
|
resource = path.pkgdir if resource.nil? and path.is_a?(Path) and path.pkgdir.is_a?(Resource)
|
12
12
|
resource = Resource.default_resource if resource.nil?
|
13
13
|
|
14
|
-
if
|
14
|
+
if Path.located?(path)
|
15
15
|
real_paths = [path]
|
16
16
|
else
|
17
17
|
path = Path.setup(path, pkgdir: resource) unless path.is_a?(Path)
|
data/scout-camp.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: scout-camp 0.1.
|
5
|
+
# stub: scout-camp 0.1.11 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "scout-camp".freeze
|
9
|
-
s.version = "0.1.
|
9
|
+
s.version = "0.1.11".freeze
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
data/scout_commands/sync
CHANGED
@@ -40,7 +40,7 @@ def lambda_handler(event:, context:)
|
|
40
40
|
body: job.path
|
41
41
|
}
|
42
42
|
elsif queue
|
43
|
-
save_inputs = Scout.var.queue[workflow.to_s][task_name][job.name].find
|
43
|
+
save_inputs = Scout.var.queue[workflow.to_s][task_name][job.name].find :bucket
|
44
44
|
job.save_inputs(save_inputs)
|
45
45
|
{
|
46
46
|
statusCode: 202,
|