aws_docker_utils 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Gemfile.lock +29 -0
- data/lib/aws_docker_utils.rb +4 -0
- data/lib/aws_docker_utils/collectors/to_s3.rb +33 -0
- data/lib/{docker_compose → aws_docker_utils/docker_compose}/client.rb +0 -0
- data/lib/{s3 → aws_docker_utils/s3}/client.rb +0 -0
- data/lib/{utils.rb → aws_docker_utils/utils.rb} +0 -0
- data/lib/aws_docker_utils/version.rb +3 -0
- metadata +9 -5
- data/lib/collectors/to_s3.rb +0 -31
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
aws_docker_utils (0.0.4)
|
5
|
+
aws-sdk
|
6
|
+
docopt
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
aws-sdk (2.2.34)
|
12
|
+
aws-sdk-resources (= 2.2.34)
|
13
|
+
aws-sdk-core (2.2.34)
|
14
|
+
jmespath (~> 1.0)
|
15
|
+
aws-sdk-resources (2.2.34)
|
16
|
+
aws-sdk-core (= 2.2.34)
|
17
|
+
docopt (0.5.0)
|
18
|
+
jmespath (1.2.4)
|
19
|
+
json_pure (>= 1.8.1)
|
20
|
+
json_pure (1.8.3)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
aws_docker_utils!
|
27
|
+
|
28
|
+
BUNDLED WITH
|
29
|
+
1.11.2
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "aws_docker_utils/utils"
|
2
|
+
require "aws_docker_utils/docker_compose/client"
|
3
|
+
require "aws_docker_utils/s3/client"
|
4
|
+
|
5
|
+
module AwsDockerUtils
|
6
|
+
module Collectors
|
7
|
+
class ToS3
|
8
|
+
|
9
|
+
def initialize(opts={})
|
10
|
+
@bucket_name = opts.fetch('<s3_bucket_name>')
|
11
|
+
@task_name = opts.fetch('<as_task>', "file")
|
12
|
+
@container_name = opts.fetch('<container_name>')
|
13
|
+
@cmd = opts.fetch('<cmd>')
|
14
|
+
|
15
|
+
@file_name = "#{`date '+#{@task_name}_%y-%m-%d_%H-%M'`.chop}.sql"
|
16
|
+
end
|
17
|
+
|
18
|
+
def push
|
19
|
+
DockerCompose::Client.new(container_name: @container_name, cmd: "#{@cmd} > #{@file_name}").exec
|
20
|
+
file_name = Utils.compress(@file_name)
|
21
|
+
|
22
|
+
s3 = S3::Client.new(file_name: file_name, bucket_name: @bucket_name)
|
23
|
+
if s3.put(file_name)
|
24
|
+
Utils.rm(file_name)
|
25
|
+
puts "Pushed to S3."
|
26
|
+
else
|
27
|
+
puts "Unable to do the job."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws_docker_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -51,12 +51,16 @@ extensions: []
|
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
53
|
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
54
56
|
- aws_docker_utils.gemspec
|
55
57
|
- bin/aws_docker_utils
|
56
|
-
- lib/
|
57
|
-
- lib/
|
58
|
-
- lib/
|
59
|
-
- lib/
|
58
|
+
- lib/aws_docker_utils.rb
|
59
|
+
- lib/aws_docker_utils/collectors/to_s3.rb
|
60
|
+
- lib/aws_docker_utils/docker_compose/client.rb
|
61
|
+
- lib/aws_docker_utils/s3/client.rb
|
62
|
+
- lib/aws_docker_utils/utils.rb
|
63
|
+
- lib/aws_docker_utils/version.rb
|
60
64
|
homepage: http://rubygems.org/gems/aws_docker_utils
|
61
65
|
licenses:
|
62
66
|
- MIT
|
data/lib/collectors/to_s3.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require "./../lib/utils"
|
2
|
-
require "./../lib/docker_compose/client"
|
3
|
-
require "./../lib/s3/client"
|
4
|
-
|
5
|
-
module Collectors
|
6
|
-
class ToS3
|
7
|
-
|
8
|
-
def initialize(opts={})
|
9
|
-
@bucket_name = opts.fetch('<s3_bucket_name>')
|
10
|
-
@task_name = opts.fetch('<as_task>', "file")
|
11
|
-
@container_name = opts.fetch('<container_name>')
|
12
|
-
@cmd = opts.fetch('<cmd>')
|
13
|
-
|
14
|
-
@file_name = "#{`date '+#{@task_name}_%y-%m-%d_%H-%M'`.chop}.sql"
|
15
|
-
end
|
16
|
-
|
17
|
-
def push
|
18
|
-
DockerCompose::Client.new(container_name: @container_name, cmd: "#{@cmd} > #{@file_name}").exec
|
19
|
-
file_name = Utils.compress(@file_name)
|
20
|
-
|
21
|
-
s3 = S3::Client.new(file_name: file_name, bucket_name: @bucket_name)
|
22
|
-
if s3.put(file_name)
|
23
|
-
Utils.rm(file_name)
|
24
|
-
puts "Pushed to S3."
|
25
|
-
else
|
26
|
-
puts "Unable to do the job."
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|