dip 6.0.0 → 7.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -35
- data/exe/dip +6 -6
- data/lib/dip.rb +1 -1
- data/lib/dip/cli.rb +29 -24
- data/lib/dip/cli/console.rb +7 -7
- data/lib/dip/cli/dns.rb +31 -31
- data/lib/dip/cli/nginx.rb +25 -25
- data/lib/dip/cli/ssh.rb +25 -22
- data/lib/dip/command.rb +29 -18
- data/lib/dip/commands/compose.rb +11 -10
- data/lib/dip/commands/console.rb +5 -5
- data/lib/dip/commands/dns.rb +12 -12
- data/lib/dip/commands/list.rb +3 -3
- data/lib/dip/commands/nginx.rb +8 -8
- data/lib/dip/commands/provision.rb +2 -2
- data/lib/dip/commands/run.rb +40 -18
- data/lib/dip/commands/ssh.rb +19 -11
- data/lib/dip/config.rb +18 -9
- data/lib/dip/environment.rb +6 -6
- data/lib/dip/ext/hash.rb +1 -1
- data/lib/dip/interaction_tree.rb +4 -16
- data/lib/dip/version.rb +1 -1
- metadata +38 -11
data/lib/dip/commands/ssh.rb
CHANGED
@@ -1,50 +1,58 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "shellwords"
|
4
|
-
require_relative
|
4
|
+
require_relative "../command"
|
5
5
|
|
6
6
|
module Dip
|
7
7
|
module Commands
|
8
8
|
module SSH
|
9
9
|
class Up < Dip::Command
|
10
|
-
def initialize(key:, volume:, interactive:)
|
10
|
+
def initialize(key:, volume:, interactive:, user: nil)
|
11
11
|
@key = key
|
12
12
|
@volume = volume
|
13
13
|
@interactive = interactive
|
14
|
+
@user = user
|
14
15
|
end
|
15
16
|
|
16
17
|
def execute
|
17
|
-
|
18
|
+
exec_subprocess("docker", "volume create --name ssh_data", out: File::NULL, err: File::NULL)
|
18
19
|
|
19
|
-
|
20
|
+
exec_subprocess(
|
21
|
+
"docker",
|
22
|
+
"run #{user_args}--detach --volume ssh_data:/ssh --name=ssh-agent whilp/ssh-agent"
|
23
|
+
)
|
20
24
|
|
21
25
|
key = Dip.env.interpolate(@key)
|
22
|
-
|
26
|
+
exec_subprocess("docker", "run #{container_args} whilp/ssh-agent ssh-add #{key}")
|
23
27
|
end
|
24
28
|
|
25
29
|
private
|
26
30
|
|
31
|
+
def user_args
|
32
|
+
"-u #{@user} " if @user
|
33
|
+
end
|
34
|
+
|
27
35
|
def container_args
|
28
|
-
result = %w
|
36
|
+
result = %w[--rm]
|
29
37
|
volume = Dip.env.interpolate(@volume)
|
30
38
|
result << "--volume ssh_data:/ssh"
|
31
39
|
result << "--volume #{volume}:#{volume}"
|
32
40
|
result << "--interactive --tty" if @interactive
|
33
|
-
result.join(
|
41
|
+
result.join(" ")
|
34
42
|
end
|
35
43
|
end
|
36
44
|
|
37
45
|
class Down < Dip::Command
|
38
46
|
def execute
|
39
|
-
|
40
|
-
|
41
|
-
|
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)
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
45
53
|
class Status < Dip::Command
|
46
54
|
def execute
|
47
|
-
|
55
|
+
exec_subprocess("docker", "inspect --format '{{.State.Status}}' ssh-agent")
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
data/lib/dip/config.rb
CHANGED
@@ -29,10 +29,10 @@ module Dip
|
|
29
29
|
@override = override
|
30
30
|
|
31
31
|
@file_path = if ENV["DIP_FILE"]
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
Pathname.new(prepared_name(ENV["DIP_FILE"]))
|
33
|
+
else
|
34
|
+
find(Pathname.new(work_dir))
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def exist?
|
@@ -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
|
|
@@ -119,7 +128,7 @@ module Dip
|
|
119
128
|
end
|
120
129
|
|
121
130
|
def config_missing_error(config_key)
|
122
|
-
msg =
|
131
|
+
msg = "config for %<key>s is not defined in %<path>s" % {key: config_key, path: finder.file_path}
|
123
132
|
ConfigKeyMissingError.new(msg)
|
124
133
|
end
|
125
134
|
end
|
data/lib/dip/environment.rb
CHANGED
@@ -4,7 +4,7 @@ require "pathname"
|
|
4
4
|
|
5
5
|
module Dip
|
6
6
|
class Environment
|
7
|
-
VAR_REGEX =
|
7
|
+
VAR_REGEX = /\$\{?(?<var_name>[a-zA-Z_][a-zA-Z0-9_]*)\}?/.freeze
|
8
8
|
SPECIAL_VARS = %i[os work_dir_rel_path].freeze
|
9
9
|
|
10
10
|
attr_reader :vars
|
@@ -26,8 +26,8 @@ module Dip
|
|
26
26
|
vars.fetch(name) { ENV[name] }
|
27
27
|
end
|
28
28
|
|
29
|
-
def fetch(name)
|
30
|
-
vars.fetch(name) { ENV.fetch(name)
|
29
|
+
def fetch(name, &block)
|
30
|
+
vars.fetch(name) { ENV.fetch(name, &block) }
|
31
31
|
end
|
32
32
|
|
33
33
|
def []=(key, value)
|
@@ -35,18 +35,18 @@ module Dip
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def interpolate(value)
|
38
|
-
value.gsub(VAR_REGEX) do
|
38
|
+
value.gsub(VAR_REGEX) do |match|
|
39
39
|
var_name = Regexp.last_match[:var_name]
|
40
40
|
|
41
41
|
if special_vars.key?(var_name)
|
42
42
|
fetch(var_name) { send(special_vars[var_name]) }
|
43
43
|
else
|
44
|
-
|
44
|
+
fetch(var_name) { match }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
alias_method :replace, :interpolate
|
50
50
|
|
51
51
|
private
|
52
52
|
|
data/lib/dip/ext/hash.rb
CHANGED
@@ -24,7 +24,7 @@ module ActiveSupportHashHelpers
|
|
24
24
|
merge!(other_hash) do |key, this_val, other_val|
|
25
25
|
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
26
26
|
this_val.deep_merge(other_val, &block)
|
27
|
-
elsif
|
27
|
+
elsif block
|
28
28
|
block.call(key, this_val, other_val)
|
29
29
|
else
|
30
30
|
other_val
|
data/lib/dip/interaction_tree.rb
CHANGED
@@ -58,9 +58,10 @@ module Dip
|
|
58
58
|
def build_command(entry)
|
59
59
|
{
|
60
60
|
description: entry[:description],
|
61
|
-
service: entry
|
62
|
-
command: entry[:command],
|
63
|
-
|
61
|
+
service: entry[:service],
|
62
|
+
command: entry[:command].to_s.strip,
|
63
|
+
shell: entry.fetch(:shell, true),
|
64
|
+
default_args: entry[:default_args].to_s.strip,
|
64
65
|
environment: entry[:environment] || {},
|
65
66
|
compose: {
|
66
67
|
method: entry.dig(:compose, :method) || entry[:compose_method] || "run",
|
@@ -76,19 +77,6 @@ module Dip
|
|
76
77
|
entry[:description] ||= nil
|
77
78
|
end
|
78
79
|
|
79
|
-
def prepare_default_args(args)
|
80
|
-
return [] if args.nil?
|
81
|
-
|
82
|
-
case args
|
83
|
-
when Array
|
84
|
-
args
|
85
|
-
when String
|
86
|
-
args.shellsplit
|
87
|
-
else
|
88
|
-
raise ArgumentError, "Unknown type for default_args: #{args.inspect}"
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
80
|
def compose_run_options(value)
|
93
81
|
return [] unless value
|
94
82
|
|
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:
|
4
|
+
version: 7.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bibendi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -87,19 +87,47 @@ dependencies:
|
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '3.0'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
90
|
+
name: standard
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '0
|
95
|
+
version: '1.0'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '0
|
102
|
+
version: '1.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rubocop-rake
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.5'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.5'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rubocop-rspec
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '2.2'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '2.2'
|
103
131
|
- !ruby/object:Gem::Dependency
|
104
132
|
name: simplecov
|
105
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,7 +196,7 @@ licenses:
|
|
168
196
|
- MIT
|
169
197
|
metadata:
|
170
198
|
allowed_push_host: https://rubygems.org/
|
171
|
-
post_install_message:
|
199
|
+
post_install_message:
|
172
200
|
rdoc_options: []
|
173
201
|
require_paths:
|
174
202
|
- lib
|
@@ -176,16 +204,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
204
|
requirements:
|
177
205
|
- - ">="
|
178
206
|
- !ruby/object:Gem::Version
|
179
|
-
version: '2.
|
207
|
+
version: '2.5'
|
180
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
209
|
requirements:
|
182
210
|
- - ">="
|
183
211
|
- !ruby/object:Gem::Version
|
184
212
|
version: '0'
|
185
213
|
requirements: []
|
186
|
-
|
187
|
-
|
188
|
-
signing_key:
|
214
|
+
rubygems_version: 3.1.2
|
215
|
+
signing_key:
|
189
216
|
specification_version: 4
|
190
217
|
summary: Ruby gem CLI tool for better interacting docker-compose files.
|
191
218
|
test_files: []
|