docker_rails_proxy 0.0.2 → 0.0.3
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/lib/docker_rails_proxy/commands/data_bags/pull.rb +18 -0
- data/lib/docker_rails_proxy/commands/data_bags/push.rb +37 -0
- data/lib/docker_rails_proxy/commands/data_bags.rb +40 -36
- data/lib/docker_rails_proxy/commands/stack.rb +1 -1
- data/lib/docker_rails_proxy/extends/string_support.rb +3 -1
- data/lib/docker_rails_proxy/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46209c1765250f4682e94b8683c3d4d9a283cd81
|
4
|
+
data.tar.gz: 2a14b285c999e7ee40384db4dc79959f38dcce0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6b857bbcf6c3af589c1bb654ca4dc491a27089cd7fd0c9012554cf91d8d63ca4812431ce1446fd5025ad5ab0e8fc55a282f3c35d51bc737130854bdf93cbac0
|
7
|
+
data.tar.gz: b87e1570ed1c61534c5d2303968e04294ed2aa5c0b9c6b35b66ecd53311208aed60e17e8081ee5a2e0182bce321497a8057022d6426c3a10288e39cb8033ab07
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module DockerRailsProxy
|
2
|
+
class DataBags < AwsCli
|
3
|
+
class Pull < self
|
4
|
+
def process
|
5
|
+
if system <<-EOS.strip
|
6
|
+
aws s3 sync '#{options[:bucket_path]}' '#{options[:folder]}' \
|
7
|
+
--delete \
|
8
|
+
--exact-timestamps \
|
9
|
+
#{exclude_args} \
|
10
|
+
--profile '#{options[:profile]}'
|
11
|
+
EOS
|
12
|
+
|
13
|
+
puts "Data bags pulled from #{options[:bucket_path]} to #{options[:folder]}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module DockerRailsProxy
|
2
|
+
class DataBags < AwsCli
|
3
|
+
class Push < self
|
4
|
+
|
5
|
+
after_initialize do
|
6
|
+
if File.exist?(options[:summary_path])
|
7
|
+
self.local_summary = File.read(options[:summary_path])
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
validates do
|
12
|
+
unless local_summary == bucket_summary
|
13
|
+
%{
|
14
|
+
It seems that someone else pushed something to #{options[:bucket_path]}.
|
15
|
+
Use `bin/#{APP_NAME} data-bags pull` to sync the data-bags.
|
16
|
+
|
17
|
+
P.S. Your changes will be discarded.
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def process
|
23
|
+
if system <<-EOS
|
24
|
+
aws s3 sync '#{options[:folder]}' '#{options[:bucket_path]}' \
|
25
|
+
--delete \
|
26
|
+
--exact-timestamps \
|
27
|
+
#{exclude_args} \
|
28
|
+
--profile '#{options[:profile]}' \
|
29
|
+
--sse aws:kms
|
30
|
+
EOS
|
31
|
+
|
32
|
+
puts "Data bags pushed from #{options[:folder]} to #{options[:bucket_path]}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -2,65 +2,69 @@ require 'optparse'
|
|
2
2
|
|
3
3
|
module DockerRailsProxy
|
4
4
|
class DataBags < AwsCli
|
5
|
-
|
5
|
+
autoload :Pull, 'docker_rails_proxy/commands/data_bags/pull'
|
6
|
+
autoload :Push, 'docker_rails_proxy/commands/data_bags/push'
|
7
|
+
|
8
|
+
EXCLUDE = %w[.summary *.swp *.DS_Store].freeze
|
9
|
+
|
10
|
+
attr_accessor :options, :local_summary
|
6
11
|
|
7
12
|
after_initialize { self.options = {} }
|
8
13
|
after_initialize :parse_options!, :set_defaults
|
9
14
|
|
10
|
-
before_process :set_folder_and_bucket
|
11
|
-
|
12
15
|
validates { '--profile is required.' if options[:profile].nil? }
|
13
16
|
validates { '--bucket is required.' if options[:bucket].nil? }
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
validates do
|
19
|
+
unless system <<-EOS.strip
|
20
|
+
aws s3 ls --profile '#{options[:profile]}' | grep '#{options[:bucket]}'
|
21
|
+
EOS
|
22
|
+
|
23
|
+
"#{options[:bucket]} bucket does not exit."
|
21
24
|
end
|
22
25
|
end
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
--delete \
|
30
|
-
--exact-timestamps \
|
31
|
-
--profile '#{options[:profile]}'
|
32
|
-
EOS
|
27
|
+
after_process do
|
28
|
+
if File.directory?(options[:folder])
|
29
|
+
File.write(options[:summary_path], bucket_summary.strip)
|
30
|
+
end
|
31
|
+
end
|
33
32
|
|
34
|
-
|
33
|
+
builds -> (params:) do
|
34
|
+
case params[:arguments].shift
|
35
|
+
when 'pull' then Pull
|
36
|
+
when 'push' then Push
|
37
|
+
else
|
38
|
+
puts "Usage: bin/#{APP_NAME} #{command} <pull|push> [options]"
|
39
|
+
exit
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
38
|
-
|
39
|
-
puts "#{options[:bucket]} will be synced with #{options[:folder]}, are you sure?: [yes]"
|
40
|
-
confirm = $stdin.gets.chomp
|
43
|
+
private
|
41
44
|
|
42
|
-
|
45
|
+
def bucket_summary
|
46
|
+
summary = %x(
|
47
|
+
aws s3 ls '#{options[:bucket]}' --summarize --recursive \
|
48
|
+
--profile '#{options[:profile]}' | grep -v '^$' | sort -n
|
49
|
+
).strip.split("\n")
|
43
50
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
--sse aws:kms
|
50
|
-
EOS
|
51
|
+
# 0 => Total Size
|
52
|
+
# 1 => Total Objects
|
53
|
+
# last => last updated file
|
54
|
+
(summary[ 0..1 ] << summary.last).map{|s| s.gsub(/\D/, ''.freeze) }.join('-')
|
55
|
+
end
|
51
56
|
|
52
|
-
|
53
|
-
|
57
|
+
def exclude_args
|
58
|
+
EXCLUDE.map{|s| "--exclude '#{s}'" }.join(' ')
|
54
59
|
end
|
55
60
|
|
56
61
|
def set_defaults
|
57
62
|
options[:profile] ||= APP_NAME
|
58
63
|
options[:bucket] ||= "#{APP_NAME}-data-bags"
|
59
|
-
end
|
60
64
|
|
61
|
-
|
62
|
-
options[:folder]
|
63
|
-
options[:
|
65
|
+
options[:bucket_path] = "s3://#{options[:bucket]}"
|
66
|
+
options[:folder] = build_path(".data-bags/#{options[:bucket]}")
|
67
|
+
options[:summary_path] = "#{options[:folder]}/.summary"
|
64
68
|
end
|
65
69
|
|
66
70
|
def parse_options!
|
@@ -21,7 +21,9 @@ class String
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def parameterize(separator = '-'.freeze)
|
24
|
-
|
24
|
+
split(/(?=[A-Z])/).join(separator)
|
25
|
+
.downcase.gsub(/\W/, separator)
|
26
|
+
.gsub('_'.freeze, separator)
|
25
27
|
end
|
26
28
|
|
27
29
|
def present?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker_rails_proxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jairo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-11-
|
12
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Configures docker-compose and provides rails command helpers
|
15
15
|
email:
|
@@ -31,6 +31,8 @@ files:
|
|
31
31
|
- lib/docker_rails_proxy/commands/compose/proxy.rb
|
32
32
|
- lib/docker_rails_proxy/commands/compose/up.rb
|
33
33
|
- lib/docker_rails_proxy/commands/data_bags.rb
|
34
|
+
- lib/docker_rails_proxy/commands/data_bags/pull.rb
|
35
|
+
- lib/docker_rails_proxy/commands/data_bags/push.rb
|
34
36
|
- lib/docker_rails_proxy/commands/rails.rb
|
35
37
|
- lib/docker_rails_proxy/commands/rake.rb
|
36
38
|
- lib/docker_rails_proxy/commands/rspec.rb
|