capistrano-dockercompose-interactive 0.0.1 → 0.0.2
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/capistrano-dockercompose-interactive.gemspec +1 -1
- data/lib/capistrano/dockercompose/interactive/instance.rb +32 -0
- data/lib/capistrano/dockercompose/interactive/service.rb +21 -0
- data/lib/capistrano/dockercompose/interactive.rb +32 -80
- data/lib/capistrano/tasks/docker-compose-interactive.rb +2 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc7603826a1a9abbe0088d78f3944e7725bbe687
|
4
|
+
data.tar.gz: 1fa307f47928da58951dc58ddcd9e0b01aff6cf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1aaecebc7e9e73e44cfeaf6023ca791048a949968adc95ebe629b178ab5b937599660da566ec483f3f2469425827e2773ceca2534a0f34906217c67df0f6e10
|
7
|
+
data.tar.gz: 6c4d8df7fcddd11bb254aa988b7692387ac92b00541cd8828bdfe633af803fcf4092dc3181a4eb7283084620ae450b962a0468681517ae61ff0ef6086ab712da
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'capistrano-dockercompose-interactive'
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.2'
|
8
8
|
spec.date = '2018-02-01'
|
9
9
|
spec.summary = 'Helps managing docker compose excution on local or remote with inetractive shell support'
|
10
10
|
spec.description = spec.summary
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require_relative './service'
|
3
|
+
|
4
|
+
|
5
|
+
class Instance
|
6
|
+
def initialize(file='', project=nil)
|
7
|
+
@file = file
|
8
|
+
@project = project
|
9
|
+
end
|
10
|
+
|
11
|
+
def config
|
12
|
+
return @config if @config
|
13
|
+
raw_config = execute_compose_command('config', true)
|
14
|
+
@config = YAML.load(raw_config)
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute_compose_command(cmd, capture = false)
|
18
|
+
project = @project.empty? ? "" : "-p #{@project}"
|
19
|
+
file = @file.empty? ? "" : "--file #{@file}"
|
20
|
+
cmd = "#{file} #{project} #{cmd}"
|
21
|
+
|
22
|
+
if capture
|
23
|
+
return DockerCompose::Interactive.capture_local_or_remote cmd
|
24
|
+
else
|
25
|
+
DockerCompose::Interactive.execute_local_or_remote_interactive cmd
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def service(name)
|
30
|
+
Service.new(self, name, config()['services'][name])
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
class Service
|
3
|
+
def initialize(compose, name, config)
|
4
|
+
@compose, @name, @config = compose, name, config
|
5
|
+
end
|
6
|
+
|
7
|
+
def id
|
8
|
+
result = @compose.execute_compose_command("ps -q #{@name}", true)
|
9
|
+
result.split(';').shift.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
def exec(cmd, capture=false)
|
13
|
+
cmd = "exec #{@name} #{cmd}"
|
14
|
+
@compose.execute_compose_command(cmd, capture)
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(cmd, capture=false, args="--rm")
|
18
|
+
cmd = "run #{args} #{@name} #{cmd}"
|
19
|
+
@compose.execute_compose_command(cmd, capture)
|
20
|
+
end
|
21
|
+
end
|
@@ -1,96 +1,48 @@
|
|
1
|
-
|
1
|
+
module DockerCompose
|
2
|
+
module Interactive
|
3
|
+
require_relative './interactive/instance'
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
def DockerCompose.local_stage?
|
9
|
-
fetch(:local_stage_name, 'local').to_sym == fetch(:stage).to_sym
|
10
|
-
end
|
5
|
+
def self.instance(file='', project='')
|
6
|
+
Instance.new(file, project)
|
7
|
+
end
|
11
8
|
|
12
|
-
|
13
|
-
|
14
|
-
result = ''
|
15
|
-
if local_stage?
|
16
|
-
run_locally do
|
17
|
-
result = capture "docker-compose #{cmd}"
|
18
|
-
end
|
19
|
-
else
|
20
|
-
on roles :container_host do |_host|
|
21
|
-
within current_path do
|
22
|
-
result = capture "cd #{current_path} && docker-compose #{cmd}"
|
23
|
-
end
|
24
|
-
end
|
9
|
+
def self.local_stage?
|
10
|
+
fetch(:local_stage_name, 'local').to_sym == fetch(:stage).to_sym
|
25
11
|
end
|
26
|
-
result
|
27
|
-
end
|
28
12
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
13
|
+
def self.capture_local_or_remote(cmd)
|
14
|
+
puts "runnig: docker-compose #{cmd}"
|
15
|
+
result = ''
|
16
|
+
if local_stage?
|
17
|
+
run_locally do
|
18
|
+
result = capture "docker-compose #{cmd}"
|
19
|
+
end
|
20
|
+
else
|
21
|
+
on roles fetch(:docker_compose_interactive_roles) do |_host|
|
38
22
|
within current_path do
|
39
|
-
|
23
|
+
result = capture "cd #{current_path} && docker-compose #{cmd}"
|
40
24
|
end
|
41
25
|
end
|
42
26
|
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
class Instance
|
47
|
-
def initialize(file='', project=nil)
|
48
|
-
@file = file
|
49
|
-
@project = project
|
50
|
-
end
|
51
|
-
|
52
|
-
def config
|
53
|
-
return @config if @config
|
54
|
-
raw_config = execute('config', true)
|
55
|
-
@config = YAML.load(raw_config)
|
27
|
+
result
|
56
28
|
end
|
57
29
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
return DockerCompose.capture_local_or_remote cmd
|
30
|
+
def self.execute_local_or_remote_interactive(cmd)
|
31
|
+
puts "runnig: docker-compose #{cmd}"
|
32
|
+
if local_stage?
|
33
|
+
run_locally do
|
34
|
+
execute "docker-compose #{cmd}"
|
35
|
+
end
|
65
36
|
else
|
66
|
-
|
37
|
+
on roles fetch(:docker_compose_interactive_roles) do |host|
|
38
|
+
run_interactively host do
|
39
|
+
within current_path do
|
40
|
+
execute "cd #{current_path} && docker-compose #{cmd}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
67
44
|
end
|
68
45
|
end
|
69
46
|
|
70
|
-
def service(name)
|
71
|
-
Service.new(self, name, config()['services'][name])
|
72
|
-
end
|
73
47
|
end
|
74
|
-
|
75
|
-
class Service
|
76
|
-
def initialize(compose, name, config)
|
77
|
-
@compose, @name, @config = compose, name, config
|
78
|
-
end
|
79
|
-
|
80
|
-
def id
|
81
|
-
result = @compose.execute_compose_command("ps -q #{@name}", true)
|
82
|
-
result.split(';').shift.strip
|
83
|
-
end
|
84
|
-
|
85
|
-
def exec(cmd, capture=false)
|
86
|
-
cmd = "exec #{@name} #{cmd}"
|
87
|
-
@compose.execute_compose_command(cmd, capture)
|
88
|
-
end
|
89
|
-
|
90
|
-
def run(cmd, capture=false, args="--rm")
|
91
|
-
cmd = "run #{args} #{@name} #{cmd}"
|
92
|
-
@compose.execute_compose_command(cmd, capture)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
48
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
namespace :dockercompose do
|
3
3
|
namespace :interactive do
|
4
|
-
|
4
|
+
|
5
5
|
end
|
6
6
|
end
|
7
7
|
|
@@ -10,5 +10,6 @@ namespace :load do
|
|
10
10
|
set :local_stage_name, :local
|
11
11
|
set :docker_compose_interactive_file, ''
|
12
12
|
set :docker_compose_interactive_project, ''
|
13
|
+
set :docker_compose_interactive_roles, :container_host
|
13
14
|
end
|
14
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-dockercompose-interactive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Hanoldt
|
@@ -82,6 +82,8 @@ files:
|
|
82
82
|
- capistrano-dockercompose-interactive.gemspec
|
83
83
|
- lib/capistrano-dockercompose-interactive.rb
|
84
84
|
- lib/capistrano/dockercompose/interactive.rb
|
85
|
+
- lib/capistrano/dockercompose/interactive/instance.rb
|
86
|
+
- lib/capistrano/dockercompose/interactive/service.rb
|
85
87
|
- lib/capistrano/tasks/docker-compose-interactive.rb
|
86
88
|
homepage: https://github.com/creative-workflow/capistrano-dockercompose-interactive
|
87
89
|
licenses:
|