dip 7.0.1 → 7.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- 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 +13 -4
- data/lib/dip/commands/ssh.rb +7 -7
- data/lib/dip/interaction_tree.rb +1 -0
- data/lib/dip/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b07d037c5f420807fbe56f174c208211fa2d5f1dcee9d6bf8bb9cf86d3f97af5
|
4
|
+
data.tar.gz: 2354f68ddc596c5f1e87076a5cb7fd1f0cc37b69f0354d092db1b389a773e709
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c1210a158918c0bbefa63efe5f8f42cecd2ae87a532fc1b9c98667cf8304c0bedcf5cbc1f7b1aef6e0a49704420aaf45fcb99874beb33b112ff8f6c0083d163
|
7
|
+
data.tar.gz: 24e5113b9c1b96799a0fff2f9c63b9e6182c44ca21fc9a5241c8421de4442c0633d28196ee6f10f474361e6c2730ed8e5bbe2739ca66683fa1eb6b0108d11fbc
|
data/README.md
CHANGED
@@ -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/*
|
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)
|
@@ -75,7 +80,11 @@ module Dip
|
|
75
80
|
if argv.any?
|
76
81
|
argv
|
77
82
|
elsif !(default_args = command[:default_args]).empty?
|
78
|
-
|
83
|
+
if command[:shell]
|
84
|
+
default_args.shellsplit
|
85
|
+
else
|
86
|
+
Array(default_args)
|
87
|
+
end
|
79
88
|
else
|
80
89
|
[]
|
81
90
|
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/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.0
|
4
|
+
version: 7.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bibendi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|