dip 7.0.1 → 7.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/lib/dip/cli.rb +1 -1
- data/lib/dip/command.rb +22 -13
- data/lib/dip/commands/compose.rb +4 -3
- data/lib/dip/commands/dns.rb +5 -5
- data/lib/dip/commands/nginx.rb +4 -4
- data/lib/dip/commands/provision.rb +1 -1
- data/lib/dip/commands/run.rb +18 -5
- data/lib/dip/commands/ssh.rb +7 -7
- data/lib/dip/config.rb +13 -4
- data/lib/dip/interaction_tree.rb +1 -0
- data/lib/dip/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42ac21bbebf1b0ad111a5bc783a9a539ad9b27bf6ef46b6e64fb3a6109f87005
|
4
|
+
data.tar.gz: 8988eb2450aaa51ddfacc05749405fdc1879da5f622bc130fb8d4a64af0b7359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9f6c9e006584fa20d7d42b4586b8b35a5908aa8f1587f4ca506cb42445b786db5a569033af8f466606db015c681458b6f961221afef360d0b7558cf941fa631
|
7
|
+
data.tar.gz: f77739aa2ffc4c245630732c88f2264a4c83421d1dc8b83807776d8c2eac507b991743aa3e482a117edcfc0424deb3e4a93785e69c9a46e47fb8d08db2fa28a9
|
data/README.md
CHANGED
@@ -81,7 +81,7 @@ Also, you can check out examples at the top.
|
|
81
81
|
|
82
82
|
```yml
|
83
83
|
# Required minimum dip version
|
84
|
-
version: '7.
|
84
|
+
version: '7.1'
|
85
85
|
|
86
86
|
environment:
|
87
87
|
COMPOSE_EXT: development
|
@@ -142,6 +142,12 @@ interaction:
|
|
142
142
|
default_args: db_dev
|
143
143
|
command: psql -h pg -U postgres
|
144
144
|
|
145
|
+
setup_key:
|
146
|
+
description: Copy key
|
147
|
+
service: app
|
148
|
+
command: cp `pwd`/config/key.pem /root/keys/
|
149
|
+
shell: false # you can disable shell interpolations on the host machine and send the command as is
|
150
|
+
|
145
151
|
clean_cache:
|
146
152
|
description: Delete cache files on the host machine
|
147
153
|
command: rm -rf $(pwd)/tmp/cache/*
|
@@ -292,8 +298,6 @@ Runs Nginx server container based on [bibendi/nginx-proxy](https://github.com/bi
|
|
292
298
|
foo-project/docker-compose.yml
|
293
299
|
|
294
300
|
```yml
|
295
|
-
version: '2'
|
296
|
-
|
297
301
|
services:
|
298
302
|
foo-web:
|
299
303
|
image: company/foo_image
|
@@ -314,8 +318,6 @@ networks:
|
|
314
318
|
baz-project/docker-compose.yml
|
315
319
|
|
316
320
|
```yml
|
317
|
-
version: '2'
|
318
|
-
|
319
321
|
services:
|
320
322
|
baz-web:
|
321
323
|
image: company/baz_image
|
data/lib/dip/cli.rb
CHANGED
@@ -111,7 +111,7 @@ module Dip
|
|
111
111
|
subcommand :nginx, Dip::CLI::Nginx
|
112
112
|
|
113
113
|
require_relative "cli/console"
|
114
|
-
desc "console", "Integrate Dip commands into shell (only ZSH and Bash
|
114
|
+
desc "console", "Integrate Dip commands into shell (only ZSH and Bash are supported)"
|
115
115
|
subcommand :console, Dip::CLI::Console
|
116
116
|
end
|
117
117
|
end
|
data/lib/dip/command.rb
CHANGED
@@ -6,38 +6,47 @@ module Dip
|
|
6
6
|
class Command
|
7
7
|
extend Forwardable
|
8
8
|
|
9
|
-
def_delegators self, :
|
9
|
+
def_delegators self, :exec_program, :exec_subprocess
|
10
10
|
|
11
|
-
class
|
11
|
+
class ProgramRunner
|
12
12
|
def self.call(cmdline, env: {}, **options)
|
13
|
-
|
13
|
+
if cmdline.is_a?(Array)
|
14
|
+
::Kernel.exec(env, cmdline[0], *cmdline[1..-1], **options)
|
15
|
+
else
|
16
|
+
::Kernel.exec(env, cmdline, **options)
|
17
|
+
end
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
17
|
-
class
|
21
|
+
class SubprocessRunner
|
18
22
|
def self.call(cmdline, env: {}, panic: true, **options)
|
19
|
-
return if ::Kernel.system(env, cmdline, options)
|
23
|
+
return if ::Kernel.system(env, cmdline, **options)
|
20
24
|
raise Dip::Error, "Command '#{cmdline}' executed with error." if panic
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
28
|
class << self
|
25
|
-
def
|
29
|
+
def exec_program(*args, **kwargs)
|
30
|
+
run(ProgramRunner, *args, **kwargs)
|
31
|
+
end
|
32
|
+
|
33
|
+
def exec_subprocess(*args, **kwargs)
|
34
|
+
run(SubprocessRunner, *args, **kwargs)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def run(runner, cmd, argv = [], shell: true, **options)
|
26
40
|
cmd = Dip.env.interpolate(cmd)
|
27
41
|
argv = [argv] if argv.is_a?(String)
|
28
42
|
argv = argv.map { |arg| Dip.env.interpolate(arg) }
|
29
|
-
cmdline = [cmd, *argv].compact
|
43
|
+
cmdline = [cmd, *argv].compact
|
44
|
+
cmdline = cmdline.join(" ").strip if shell
|
30
45
|
|
31
46
|
puts [Dip.env.vars, cmdline].inspect if Dip.debug?
|
32
47
|
|
33
|
-
runner = subshell ? SubshellRunner : ExecRunner
|
34
48
|
runner.call(cmdline, env: Dip.env.vars, **options)
|
35
49
|
end
|
36
|
-
|
37
|
-
def subshell(*args, **kwargs)
|
38
|
-
kwargs[:subshell] = true
|
39
|
-
shell(*args, **kwargs)
|
40
|
-
end
|
41
50
|
end
|
42
51
|
end
|
43
52
|
end
|
data/lib/dip/commands/compose.rb
CHANGED
@@ -10,10 +10,11 @@ module Dip
|
|
10
10
|
class Compose < Dip::Command
|
11
11
|
DOCKER_EMBEDDED_DNS = "127.0.0.11"
|
12
12
|
|
13
|
-
attr_reader :argv, :config
|
13
|
+
attr_reader :argv, :config, :shell
|
14
14
|
|
15
|
-
def initialize(*argv)
|
15
|
+
def initialize(*argv, shell: true)
|
16
16
|
@argv = argv
|
17
|
+
@shell = shell
|
17
18
|
@config = ::Dip.config.compose || {}
|
18
19
|
end
|
19
20
|
|
@@ -22,7 +23,7 @@ module Dip
|
|
22
23
|
|
23
24
|
compose_argv = Array(find_files) + Array(cli_options) + argv
|
24
25
|
|
25
|
-
|
26
|
+
exec_program("docker-compose", compose_argv, shell: shell)
|
26
27
|
end
|
27
28
|
|
28
29
|
private
|
data/lib/dip/commands/dns.rb
CHANGED
@@ -17,8 +17,8 @@ module Dip
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def execute
|
20
|
-
|
21
|
-
|
20
|
+
exec_subprocess("docker", "network create #{@net}", panic: false, err: File::NULL)
|
21
|
+
exec_subprocess("docker", "run #{container_args} #{@image} --domain=#{@domain}")
|
22
22
|
end
|
23
23
|
|
24
24
|
private
|
@@ -40,8 +40,8 @@ module Dip
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def execute
|
43
|
-
|
44
|
-
|
43
|
+
exec_subprocess("docker", "stop #{@name}", panic: false, out: File::NULL, err: File::NULL)
|
44
|
+
exec_subprocess("docker", "rm -v #{@name}", panic: false, out: File::NULL, err: File::NULL)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -52,7 +52,7 @@ module Dip
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def execute(**options)
|
55
|
-
|
55
|
+
exec_subprocess(
|
56
56
|
"docker",
|
57
57
|
"inspect --format '{{ .NetworkSettings.Networks.#{@net}.IPAddress }}' #{@name}",
|
58
58
|
**options
|
data/lib/dip/commands/nginx.rb
CHANGED
@@ -18,8 +18,8 @@ module Dip
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def execute
|
21
|
-
|
22
|
-
|
21
|
+
exec_subprocess("docker", "network create #{@net}", panic: false, err: File::NULL)
|
22
|
+
exec_subprocess("docker", "run #{container_args} #{@image}")
|
23
23
|
end
|
24
24
|
|
25
25
|
private
|
@@ -43,8 +43,8 @@ module Dip
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def execute
|
46
|
-
|
47
|
-
|
46
|
+
exec_subprocess("docker", "stop #{@name}", panic: false, out: File::NULL, err: File::NULL)
|
47
|
+
exec_subprocess("docker", "rm -v #{@name}", panic: false, out: File::NULL, err: File::NULL)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
data/lib/dip/commands/run.rb
CHANGED
@@ -23,11 +23,12 @@ module Dip
|
|
23
23
|
|
24
24
|
def execute
|
25
25
|
if command[:service].nil?
|
26
|
-
|
26
|
+
exec_program(command[:command], get_args, shell: command[:shell])
|
27
27
|
else
|
28
28
|
Dip::Commands::Compose.new(
|
29
29
|
command[:compose][:method],
|
30
|
-
*compose_arguments
|
30
|
+
*compose_arguments,
|
31
|
+
shell: command[:shell]
|
31
32
|
).execute
|
32
33
|
end
|
33
34
|
end
|
@@ -48,7 +49,11 @@ module Dip
|
|
48
49
|
compose_argv << command.fetch(:service)
|
49
50
|
|
50
51
|
unless (cmd = command[:command]).empty?
|
51
|
-
|
52
|
+
if command[:shell]
|
53
|
+
compose_argv << cmd
|
54
|
+
else
|
55
|
+
compose_argv.concat(cmd.shellsplit)
|
56
|
+
end
|
52
57
|
end
|
53
58
|
|
54
59
|
compose_argv.concat(get_args)
|
@@ -73,9 +78,17 @@ module Dip
|
|
73
78
|
|
74
79
|
def get_args
|
75
80
|
if argv.any?
|
76
|
-
|
81
|
+
if command[:shell]
|
82
|
+
[argv.shelljoin]
|
83
|
+
else
|
84
|
+
Array(argv)
|
85
|
+
end
|
77
86
|
elsif !(default_args = command[:default_args]).empty?
|
78
|
-
|
87
|
+
if command[:shell]
|
88
|
+
default_args.shellsplit
|
89
|
+
else
|
90
|
+
Array(default_args)
|
91
|
+
end
|
79
92
|
else
|
80
93
|
[]
|
81
94
|
end
|
data/lib/dip/commands/ssh.rb
CHANGED
@@ -15,15 +15,15 @@ module Dip
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def execute
|
18
|
-
|
18
|
+
exec_subprocess("docker", "volume create --name ssh_data", out: File::NULL, err: File::NULL)
|
19
19
|
|
20
|
-
|
20
|
+
exec_subprocess(
|
21
21
|
"docker",
|
22
22
|
"run #{user_args}--detach --volume ssh_data:/ssh --name=ssh-agent whilp/ssh-agent"
|
23
23
|
)
|
24
24
|
|
25
25
|
key = Dip.env.interpolate(@key)
|
26
|
-
|
26
|
+
exec_subprocess("docker", "run #{container_args} whilp/ssh-agent ssh-add #{key}")
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -44,15 +44,15 @@ module Dip
|
|
44
44
|
|
45
45
|
class Down < Dip::Command
|
46
46
|
def execute
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
exec_subprocess("docker", "stop ssh-agent", panic: false, out: File::NULL, err: File::NULL)
|
48
|
+
exec_subprocess("docker", "rm -v ssh-agent", panic: false, out: File::NULL, err: File::NULL)
|
49
|
+
exec_subprocess("docker", "volume rm ssh_data", panic: false, out: File::NULL, err: File::NULL)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
class Status < Dip::Command
|
54
54
|
def execute
|
55
|
-
|
55
|
+
exec_subprocess("docker", "inspect --format '{{.State.Status}}' ssh-agent")
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
data/lib/dip/config.rb
CHANGED
@@ -62,10 +62,19 @@ module Dip
|
|
62
62
|
def load_yaml(file_path = path)
|
63
63
|
return {} unless File.exist?(file_path)
|
64
64
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
data = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new("4.0.0")
|
66
|
+
YAML.safe_load(
|
67
|
+
ERB.new(File.read(file_path)).result,
|
68
|
+
aliases: true
|
69
|
+
)
|
70
|
+
else
|
71
|
+
YAML.safe_load(
|
72
|
+
ERB.new(File.read(file_path)).result,
|
73
|
+
[], [], true
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
data&.deep_symbolize_keys! || {}
|
69
78
|
end
|
70
79
|
end
|
71
80
|
|
data/lib/dip/interaction_tree.rb
CHANGED
data/lib/dip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bibendi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '0.20'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '0.20'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -196,7 +196,7 @@ licenses:
|
|
196
196
|
- MIT
|
197
197
|
metadata:
|
198
198
|
allowed_push_host: https://rubygems.org/
|
199
|
-
post_install_message:
|
199
|
+
post_install_message:
|
200
200
|
rdoc_options: []
|
201
201
|
require_paths:
|
202
202
|
- lib
|
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
212
|
version: '0'
|
213
213
|
requirements: []
|
214
214
|
rubygems_version: 3.1.2
|
215
|
-
signing_key:
|
215
|
+
signing_key:
|
216
216
|
specification_version: 4
|
217
217
|
summary: Ruby gem CLI tool for better interacting docker-compose files.
|
218
218
|
test_files: []
|