percheron 0.6.3 → 0.6.4
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/percheron/actions/base.rb +2 -2
- data/lib/percheron/actions/build.rb +4 -3
- data/lib/percheron/actions/create.rb +13 -25
- data/lib/percheron/actions/exec.rb +5 -4
- data/lib/percheron/actions/exec_local.rb +4 -2
- data/lib/percheron/actions/purge.rb +5 -4
- data/lib/percheron/actions/recreate.rb +3 -2
- data/lib/percheron/actions/rename.rb +3 -2
- data/lib/percheron/actions/restart.rb +5 -4
- data/lib/percheron/actions/start.rb +13 -6
- data/lib/percheron/actions/stop.rb +3 -2
- data/lib/percheron/commands/abstract.rb +4 -0
- data/lib/percheron/commands/create.rb +1 -1
- data/lib/percheron/commands/purge.rb +3 -2
- data/lib/percheron/commands/recreate.rb +1 -1
- data/lib/percheron/commands/restart.rb +1 -1
- data/lib/percheron/commands/start.rb +1 -1
- data/lib/percheron/commands/stop.rb +1 -1
- data/lib/percheron/stack.rb +5 -9
- data/lib/percheron/version.rb +1 -1
- 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: 61e4d66006bf086c797d921852dae42438f8abca
|
4
|
+
data.tar.gz: b91b6698c444e51757bee46fa5f290b67211670b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a136f407d6823d6983723a36ea9056f56e440411e56df65e2101348fbb4dcd957027f570a9af29b21f9e5c273698ca9a460a05666fa79353577413c00e8892e
|
7
|
+
data.tar.gz: b87043f174f595bd1aed913e087089575d7ee602d5a46a5810d01c98aebd38d4816aa1a45145f2b7b685fb443bb1fd4d10c29a3e7ed0dc8396048a0299bbb97c
|
@@ -36,11 +36,11 @@ module Percheron
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
def start_containers!(containers)
|
39
|
+
def start_containers!(containers, exec_scripts: true)
|
40
40
|
exec_on_containers!(containers) do |container|
|
41
41
|
unless container.running?
|
42
42
|
$logger.debug "Starting '#{container.name}' container"
|
43
|
-
Start.new(container, container.dependant_containers.values).execute!
|
43
|
+
Start.new(container, dependant_containers: container.dependant_containers.values, exec_scripts: exec_scripts).execute!
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -10,8 +10,9 @@ module Percheron
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def execute!
|
13
|
-
|
14
|
-
|
13
|
+
results = []
|
14
|
+
results << build!
|
15
|
+
results.compact.empty? ? nil : container
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
@@ -30,7 +31,7 @@ module Percheron
|
|
30
31
|
def build!
|
31
32
|
in_working_directory(base_dir) do
|
32
33
|
execute_pre_build_scripts! unless container.pre_build_scripts.empty?
|
33
|
-
$logger.info "Building '#{container.image_name}'"
|
34
|
+
$logger.info "Building '#{container.image_name}' image"
|
34
35
|
Docker::Image.build_from_dir(base_dir, build_opts) do |out|
|
35
36
|
$logger.debug '%s' % [ out.strip ]
|
36
37
|
end
|
@@ -10,12 +10,13 @@ module Percheron
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def execute!(opts={})
|
13
|
+
results = []
|
13
14
|
if recreate? || !container.exists?
|
14
|
-
create!(opts)
|
15
|
-
container
|
15
|
+
results << create!(opts)
|
16
16
|
else
|
17
17
|
$logger.debug "Container '#{container.name}' already exists"
|
18
18
|
end
|
19
|
+
results.compact.empty? ? nil : container
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
@@ -60,8 +61,7 @@ module Percheron
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def create!(opts)
|
63
|
-
|
64
|
-
build_image!
|
64
|
+
build_image! unless container.image_exists?
|
65
65
|
insert_scripts!
|
66
66
|
create_container!(opts.fetch(:create, {}))
|
67
67
|
execute_post_create_scripts! unless container.post_create_scripts.empty?
|
@@ -69,41 +69,29 @@ module Percheron
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def build_image!
|
72
|
-
|
73
|
-
$logger.info "Creating '#{container.image_name}' image"
|
74
|
-
Build.new(container).execute!
|
75
|
-
end
|
72
|
+
Build.new(container).execute!
|
76
73
|
end
|
77
74
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
75
|
+
def insert_scripts!
|
76
|
+
insert_files!(container.post_create_scripts)
|
77
|
+
insert_files!(container.post_start_scripts)
|
81
78
|
end
|
82
79
|
|
83
80
|
def create_container!(opts)
|
84
81
|
options = base_options.merge(host_config_options).merge(opts)
|
85
|
-
|
86
82
|
$logger.info "Creating '%s' container" % options['name']
|
87
83
|
Docker::Container.create(options)
|
88
84
|
end
|
89
85
|
|
90
|
-
def insert_scripts!
|
91
|
-
insert_post_create_scripts!
|
92
|
-
insert_post_start_scripts!
|
93
|
-
end
|
94
|
-
|
95
|
-
def insert_post_create_scripts!
|
96
|
-
insert_files!(container.post_create_scripts)
|
97
|
-
end
|
98
|
-
|
99
|
-
def insert_post_start_scripts!
|
100
|
-
insert_files!(container.post_start_scripts)
|
101
|
-
end
|
102
|
-
|
103
86
|
def execute_post_create_scripts!
|
104
87
|
Exec.new(container, container.dependant_containers.values, container.post_create_scripts, 'POST create').execute!
|
105
88
|
end
|
106
89
|
|
90
|
+
def set_dockerfile_md5!
|
91
|
+
$logger.info "Setting MD5 for '#{container.name}' container to #{container.current_dockerfile_md5}"
|
92
|
+
$metastore.set("#{container.metastore_key}.dockerfile_md5", container.current_dockerfile_md5)
|
93
|
+
end
|
94
|
+
|
107
95
|
end
|
108
96
|
end
|
109
97
|
end
|
@@ -12,11 +12,12 @@ module Percheron
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def execute!
|
15
|
+
results = []
|
15
16
|
$logger.debug "Executing #{description} scripts '#{scripts.inspect}' on '#{container.name}'"
|
16
17
|
started_dependant_containers = start_containers!(dependant_containers)
|
17
|
-
execute_scripts_on_running_container!
|
18
|
-
stop_containers!(started_dependant_containers)
|
19
|
-
container
|
18
|
+
results << execute_scripts_on_running_container!
|
19
|
+
results << stop_containers!(started_dependant_containers)
|
20
|
+
results.compact.empty? ? nil : container
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
@@ -25,7 +26,7 @@ module Percheron
|
|
25
26
|
|
26
27
|
def execute_scripts_on_running_container!
|
27
28
|
container_running = container.running?
|
28
|
-
Start.new(container).execute! unless container_running
|
29
|
+
Start.new(container, exec_scripts: false).execute! unless container_running
|
29
30
|
execute_scripts!
|
30
31
|
Stop.new(container).execute! unless container_running
|
31
32
|
end
|
@@ -13,8 +13,9 @@ module Percheron
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def execute!
|
16
|
-
|
17
|
-
execute_scripts!
|
16
|
+
results = []
|
17
|
+
results << execute_scripts!
|
18
|
+
results.compact.empty? ? nil : container
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
@@ -22,6 +23,7 @@ module Percheron
|
|
22
23
|
attr_reader :container, :scripts, :description
|
23
24
|
|
24
25
|
def execute_scripts!
|
26
|
+
$logger.debug "Executing #{description} scripts '#{scripts.inspect}' locally"
|
25
27
|
scripts.each do |script|
|
26
28
|
in_working_directory(base_dir) do
|
27
29
|
execute_command!('/bin/bash -x %s 2>&1' % Pathname.new(File.expand_path(script)))
|
@@ -9,10 +9,11 @@ module Percheron
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def execute!
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
container
|
12
|
+
results = []
|
13
|
+
results << stop!
|
14
|
+
results << delete_container! if container.exists?
|
15
|
+
results << delete_image! if container.image_exists?
|
16
|
+
results.compact.empty? ? nil : container
|
16
17
|
end
|
17
18
|
|
18
19
|
private
|
@@ -11,9 +11,9 @@ module Percheron
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def execute!
|
14
|
+
results = []
|
14
15
|
if recreate?
|
15
|
-
recreate!
|
16
|
-
container
|
16
|
+
results << recreate!
|
17
17
|
else
|
18
18
|
unless dockerfile_md5s_match?
|
19
19
|
$logger.warn "Container '#{container.name}' MD5's do not match, consider recreating (bump the version!)"
|
@@ -21,6 +21,7 @@ module Percheron
|
|
21
21
|
$logger.info "Container '#{container.name}' does not need to be recreated"
|
22
22
|
end
|
23
23
|
end
|
24
|
+
results.compact.empty? ? nil : container
|
24
25
|
end
|
25
26
|
|
26
27
|
private
|
@@ -9,9 +9,10 @@ module Percheron
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def execute!
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
results = []
|
13
|
+
results << stop!
|
14
|
+
results << start!
|
15
|
+
results.compact.empty? ? nil : container
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
@@ -23,7 +24,7 @@ module Percheron
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def start!
|
26
|
-
Start.new(container, container.dependant_containers.values).execute!
|
27
|
+
Start.new(container, dependant_containers: container.dependant_containers.values).execute!
|
27
28
|
end
|
28
29
|
|
29
30
|
end
|
@@ -4,25 +4,32 @@ module Percheron
|
|
4
4
|
|
5
5
|
include Base
|
6
6
|
|
7
|
-
def initialize(container, dependant_containers
|
7
|
+
def initialize(container, dependant_containers: [], exec_scripts: true)
|
8
8
|
@container = container
|
9
9
|
@dependant_containers = dependant_containers
|
10
|
+
@exec_scripts = exec_scripts
|
10
11
|
end
|
11
12
|
|
12
13
|
def execute!
|
13
|
-
|
14
|
+
results = []
|
15
|
+
results << create! unless container.exists?
|
14
16
|
unless container.running?
|
15
|
-
start!
|
16
|
-
execute_post_start_scripts!
|
17
|
+
results << start!
|
18
|
+
results << execute_post_start_scripts! if exec_scripts?
|
17
19
|
end
|
18
|
-
container
|
20
|
+
results.compact.empty? ? nil : container
|
19
21
|
end
|
20
22
|
|
21
23
|
private
|
22
24
|
|
23
|
-
attr_reader :container, :dependant_containers
|
25
|
+
attr_reader :container, :dependant_containers, :exec_scripts
|
26
|
+
|
27
|
+
def exec_scripts?
|
28
|
+
!container.post_start_scripts.empty? && exec_scripts
|
29
|
+
end
|
24
30
|
|
25
31
|
def create!
|
32
|
+
$logger.info "Creating '#{container.name}' container as it doesn't exist"
|
26
33
|
Create.new(container).execute!
|
27
34
|
end
|
28
35
|
|
@@ -2,10 +2,11 @@ module Percheron
|
|
2
2
|
module Commands
|
3
3
|
class Purge < Abstract
|
4
4
|
|
5
|
-
|
5
|
+
default_parameters!
|
6
6
|
|
7
7
|
def execute
|
8
|
-
|
8
|
+
opts = { container_names: container_names }
|
9
|
+
stack.purge!(opts)
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
data/lib/percheron/stack.rb
CHANGED
@@ -46,8 +46,7 @@ module Percheron
|
|
46
46
|
|
47
47
|
def start!(container_names: [])
|
48
48
|
container_names = dependant_containers_for(container_names)
|
49
|
-
exec_on_dependant_containers_for(container_names) { |container| Actions::Start.new(container, container.dependant_containers.values).execute! }
|
50
|
-
|
49
|
+
exec_on_dependant_containers_for(container_names) { |container| Actions::Start.new(container, dependant_containers: container.dependant_containers.values).execute! }
|
51
50
|
end
|
52
51
|
|
53
52
|
def restart!(container_names: [])
|
@@ -73,11 +72,9 @@ module Percheron
|
|
73
72
|
exec_on_dependant_containers_for(container_names_final.uniq) { |container| Actions::Recreate.new(container, force_recreate: force_recreate, delete: delete).execute! }
|
74
73
|
end
|
75
74
|
|
76
|
-
def purge!
|
77
|
-
|
78
|
-
|
79
|
-
$logger.info ''
|
80
|
-
end
|
75
|
+
def purge!(container_names: [])
|
76
|
+
container_names = filter_container_names(container_names)
|
77
|
+
exec_on_dependant_containers_for(container_names) { |container| Actions::Purge.new(container).execute! }
|
81
78
|
end
|
82
79
|
|
83
80
|
def valid?
|
@@ -106,8 +103,7 @@ module Percheron
|
|
106
103
|
|
107
104
|
def exec_on_dependant_containers_for(container_names)
|
108
105
|
serial_processor(container_names) do |container|
|
109
|
-
yield(container)
|
110
|
-
$logger.info ''
|
106
|
+
$logger.info '' if yield(container)
|
111
107
|
end
|
112
108
|
end
|
113
109
|
|
data/lib/percheron/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percheron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash McKenzie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|