percheron 0.7.4 → 0.7.5
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/README.md +4 -0
- data/lib/percheron/actions/shell.rb +11 -6
- data/lib/percheron/commands/console.rb +3 -0
- data/lib/percheron/commands/shell.rb +2 -2
- data/lib/percheron/formatters/stack/table.rb +36 -12
- data/lib/percheron/stack.rb +2 -2
- 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: 60e75ad43ed6c18a865ea07d76f9fa2b1d893eed
|
4
|
+
data.tar.gz: 54207bfa168a15d727ba18bba758bf40d4d885f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af2d8a877d52f2a51b76c69b809b6773b26d7a22ac3e6acbb4dcce2673257d9302fc9d2079d5af7564f9e92ce8150d859ed16d4c512195f5832ca89bc7ba9afd
|
7
|
+
data.tar.gz: ad859eabacf9550306947c969dff212fb7aa9b2bb888ab87acc20bb6a4ed1e208f303a04a6cf55a27cc6d75f84df48a92d76e85ffa048e335e1569a3c0fb0a30
|
data/README.md
CHANGED
@@ -3,29 +3,34 @@ module Percheron
|
|
3
3
|
class Shell
|
4
4
|
include Base
|
5
5
|
|
6
|
-
|
6
|
+
DEFAULT_COMMAND = '/bin/sh'
|
7
7
|
DOCKER_CLIENT = 'docker'
|
8
8
|
|
9
|
-
def initialize(container,
|
9
|
+
def initialize(container, command: DEFAULT_COMMAND)
|
10
10
|
@container = container
|
11
|
-
@
|
11
|
+
@command = command
|
12
12
|
end
|
13
13
|
|
14
14
|
def execute!
|
15
|
-
$logger.debug "Executing #{shell} on '#{container.name}' container"
|
16
15
|
exec! if valid?
|
17
16
|
end
|
18
17
|
|
19
18
|
private
|
20
19
|
|
21
|
-
attr_reader :container
|
20
|
+
attr_reader :container
|
22
21
|
|
23
22
|
def valid?
|
24
23
|
Validators::DockerClient.new.valid?
|
25
24
|
end
|
26
25
|
|
26
|
+
def command
|
27
|
+
"sh -c '%s'" % @command
|
28
|
+
end
|
29
|
+
|
27
30
|
def exec!
|
28
|
-
|
31
|
+
cmd = '%s exec -ti %s %s' % [ DOCKER_CLIENT, container.full_name, command ]
|
32
|
+
$logger.debug "Executing '#{cmd}' on '#{container.name}' container"
|
33
|
+
system(cmd)
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
@@ -12,6 +12,7 @@ module Percheron
|
|
12
12
|
|
13
13
|
private
|
14
14
|
|
15
|
+
# FIXME: Dupe?
|
15
16
|
def list
|
16
17
|
Stack.get(config, stack_name).each do |_, stack|
|
17
18
|
puts("\n", Percheron::Formatters::Stack::Table.new(stack).generate)
|
@@ -58,6 +59,8 @@ module Percheron
|
|
58
59
|
stack.restart!(container_names: [ *container_names ])
|
59
60
|
nil
|
60
61
|
end
|
62
|
+
|
63
|
+
alias_method :status, :list
|
61
64
|
end
|
62
65
|
end
|
63
66
|
end
|
@@ -4,11 +4,11 @@ module Percheron
|
|
4
4
|
|
5
5
|
parameter('STACK_NAME', 'stack name', required: true)
|
6
6
|
parameter('CONTAINER_NAME', 'container name', required: true)
|
7
|
-
option('--
|
7
|
+
option('--command', 'COMMAND', 'command', default: Percheron::Actions::Shell::DEFAULT_COMMAND)
|
8
8
|
|
9
9
|
def execute
|
10
10
|
super
|
11
|
-
stack.shell!(container_name,
|
11
|
+
stack.shell!(container_name, command: command)
|
12
12
|
rescue Errors::DockerClientInvalid => e
|
13
13
|
signal_usage_error(e.message)
|
14
14
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'thread'
|
2
|
+
|
1
3
|
module Percheron
|
2
4
|
module Formatters
|
3
5
|
module Stack
|
@@ -5,6 +7,7 @@ module Percheron
|
|
5
7
|
|
6
8
|
def initialize(stack)
|
7
9
|
@stack = stack
|
10
|
+
@queue = Queue.new
|
8
11
|
end
|
9
12
|
|
10
13
|
def generate
|
@@ -13,7 +16,7 @@ module Percheron
|
|
13
16
|
|
14
17
|
private
|
15
18
|
|
16
|
-
attr_reader :stack
|
19
|
+
attr_reader :stack, :queue
|
17
20
|
|
18
21
|
def title
|
19
22
|
stack.name
|
@@ -31,21 +34,42 @@ module Percheron
|
|
31
34
|
]
|
32
35
|
end
|
33
36
|
|
34
|
-
# rubocop:disable Metrics/MethodLength
|
35
37
|
def rows
|
38
|
+
resp = {}
|
39
|
+
queue_jobs(resp)
|
40
|
+
process_queue!
|
41
|
+
sort_rows(resp)
|
42
|
+
end
|
43
|
+
|
44
|
+
def queue_jobs(resp)
|
36
45
|
stack.containers.map do |_, container|
|
37
|
-
[
|
38
|
-
container.name,
|
39
|
-
container.id,
|
40
|
-
startable(container),
|
41
|
-
container.ip,
|
42
|
-
container.ports.join(', '),
|
43
|
-
container.volumes.join(', '),
|
44
|
-
(container.built_version == '0.0.0') ? '' : container.built_version
|
45
|
-
]
|
46
|
+
queue << Thread.new { resp[Time.now.to_f] = row_for(container) }
|
46
47
|
end
|
47
48
|
end
|
48
|
-
|
49
|
+
|
50
|
+
def process_queue!
|
51
|
+
queue.length.times { queue.pop.join }
|
52
|
+
end
|
53
|
+
|
54
|
+
def sort_rows(resp)
|
55
|
+
resp.sort.map { |_, row| row.flatten }
|
56
|
+
end
|
57
|
+
|
58
|
+
def row_for(container)
|
59
|
+
[
|
60
|
+
container.name,
|
61
|
+
container.id,
|
62
|
+
startable(container),
|
63
|
+
container.ip,
|
64
|
+
container.ports.join(', '),
|
65
|
+
container.volumes.join(', '),
|
66
|
+
version(container)
|
67
|
+
]
|
68
|
+
end
|
69
|
+
|
70
|
+
def version(container)
|
71
|
+
(container.built_version == '0.0.0') ? '' : container.built_version
|
72
|
+
end
|
49
73
|
|
50
74
|
def startable(container)
|
51
75
|
if container.startable?
|
data/lib/percheron/stack.rb
CHANGED
@@ -32,8 +32,8 @@ module Percheron
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def shell!(container_name,
|
36
|
-
Actions::Shell.new(container_from_name(container_name),
|
35
|
+
def shell!(container_name, command: Percheron::Actions::Shell::DEFAULT_COMMAND)
|
36
|
+
Actions::Shell.new(container_from_name(container_name), command: command).execute!
|
37
37
|
end
|
38
38
|
|
39
39
|
def logs!(container_name, follow: false)
|
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.7.
|
4
|
+
version: 0.7.5
|
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-04-
|
11
|
+
date: 2015-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|