docker-env 1.3.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/VERSION +1 -1
- data/bin/docker-env +59 -25
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 49cc173315bbedee1d56df6586b8b643225e1e6749be840474ef21aa926e1206
|
4
|
+
data.tar.gz: 4235d13a8d3555027db37d4b9eea1a994826bd3b1776b243d9f65132f1fff797
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4683c6f9b8826e1940e23561d19ddcb1ec38d87e832c33bc9a84c1839df1889b9608c0158c88cef53a3539485c2e7f7a921856be6f14f25a445f62ef23a45143
|
7
|
+
data.tar.gz: 85503e832d3f91c7339451a278bdd0c955dc2249e483e85431c10f6ee7fea3a91d52a7b871dee39aa994843aab507e9c5eefa0266da6dbbee405a79ff82e996a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
2.1.0
|
data/bin/docker-env
CHANGED
@@ -7,8 +7,8 @@ include GLI::App
|
|
7
7
|
DIR = File.expand_path(
|
8
8
|
'~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux'
|
9
9
|
).freeze
|
10
|
-
|
11
|
-
|
10
|
+
QNAME = 'Docker.qcow2'.freeze
|
11
|
+
RNAME = 'Docker.raw'.freeze
|
12
12
|
|
13
13
|
program_desc 'Manage docker for mac qcow images'
|
14
14
|
version Version.current(File.dirname(__FILE__))
|
@@ -21,12 +21,28 @@ switch %i[v verbose], desc: 'be more verbose'
|
|
21
21
|
switch %i[k kill], desc: 'quit docker if it is running'
|
22
22
|
switch %i[r restart], desc: 'stop and start docker around command'
|
23
23
|
|
24
|
+
def symlink
|
25
|
+
n = File.join(DIR, QNAME);
|
26
|
+
return n if File.exist?(n)
|
27
|
+
|
28
|
+
return File.join(DIR, RNAME);
|
29
|
+
end
|
30
|
+
|
24
31
|
def name(f, options)
|
25
|
-
options[:verbose] ? f : f.sub(/^.+Docker\.qcow2\./, '')
|
32
|
+
options[:verbose] ? f : f.sub(/^.+Docker\.(qcow2|raw)\./, '')
|
33
|
+
end
|
34
|
+
|
35
|
+
def readlink
|
36
|
+
if !File.symlink?(symlink)
|
37
|
+
$stderr.puts "Image not symlink, try init!"
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
|
41
|
+
File.readlink(symlink)
|
26
42
|
end
|
27
43
|
|
28
44
|
def current(options)
|
29
|
-
name(
|
45
|
+
name(readlink, options)
|
30
46
|
end
|
31
47
|
|
32
48
|
def tell_docker(what, options)
|
@@ -61,60 +77,73 @@ post do |global_options, _command, _options, _args|
|
|
61
77
|
tell_docker('open', global_options) if global_options[:restart]
|
62
78
|
end
|
63
79
|
|
64
|
-
desc 'setup by moving Docker.qcow2 to "image_name" and linking back'
|
80
|
+
desc 'setup by moving Docker.{qcow2,raw} to "image_name" and linking back (FORCES RESTART)'
|
65
81
|
arg 'image_name'
|
66
82
|
command :init do |c|
|
67
83
|
c.action do |global_options, _options, args|
|
84
|
+
global_options[:restart] = true
|
68
85
|
running?(global_options)
|
69
|
-
if File.symlink?(
|
86
|
+
if File.symlink?(symlink)
|
70
87
|
$stderr.puts "Already setup. Current is: #{current(global_options)}"
|
71
88
|
exit 1
|
72
89
|
end
|
73
90
|
|
74
|
-
|
75
|
-
|
76
|
-
File.symlink(file, SYMLINK)
|
91
|
+
link = symlink
|
92
|
+
file = "#{symlink}.#{args[0]}"
|
77
93
|
|
94
|
+
$stderr.puts "Moving #{link} -> #{file}" if global_options[:verbose]
|
95
|
+
|
96
|
+
File.rename(link, file)
|
97
|
+
File.symlink(file, link)
|
98
|
+
|
99
|
+
$stderr.puts "Linking #{file} -> #{link} and restarting" if global_options[:verbose]
|
78
100
|
puts 'Current is now: ' + current(global_options)
|
79
101
|
end
|
80
102
|
end
|
81
103
|
|
82
|
-
desc '
|
104
|
+
desc 'Print path to disk imae directory'
|
105
|
+
command [:dir, :directory] do |c|
|
106
|
+
c.action { puts DIR }
|
107
|
+
end
|
108
|
+
|
109
|
+
desc 'list available disk images (.../Docker.(qcow2|raw).{name})'
|
83
110
|
command [:list, :ls] do |c|
|
84
111
|
c.action do |global_options, _options, _args|
|
85
112
|
cur = current(global_options)
|
86
|
-
|
113
|
+
# only list images of base type...
|
114
|
+
ext = File.extname(symlink)
|
115
|
+
puts Dir.glob("#{DIR}/Docker#{ext}.*").map { |f|
|
87
116
|
img = name(f, global_options)
|
88
117
|
sprintf '%-2s%s', img == cur ? '*' : '', img
|
89
118
|
}
|
90
119
|
end
|
91
120
|
end
|
92
121
|
|
93
|
-
desc 'create new
|
122
|
+
desc 'create new disk "image" (FORCES RESTART)'
|
94
123
|
long_desc <<EOF
|
95
124
|
Removes current link so that the next time docker starts, it will create a
|
96
125
|
new empty image file. The (slightly long) steps to follow:
|
97
126
|
|
98
|
-
1.
|
99
|
-
2.
|
100
|
-
3.
|
101
|
-
4. Stop Docker.app
|
102
|
-
5. Run `docker-env init {name}` to name the new image and
|
127
|
+
1. Run this command (`docker-env new`)
|
128
|
+
2. Wait for docker to fully restart
|
129
|
+
3. Run `docker-env init {name}` to name the new image and
|
103
130
|
create the symlink
|
104
131
|
EOF
|
105
132
|
command :new do |c|
|
106
133
|
c.action do |global_options, _options, _args|
|
134
|
+
global_options[:restart] = true
|
107
135
|
running?(global_options)
|
108
|
-
if File.exist?(
|
136
|
+
if File.exist?(symlink) && !File.symlink?(symlink)
|
109
137
|
$stderr.puts "Please use '--force' to force delete current image!"
|
110
138
|
exit 1
|
111
139
|
end
|
112
140
|
|
141
|
+
$stderr.puts "Removing #{symlink} and restarting" if global_options[:verbose]
|
142
|
+
|
113
143
|
begin
|
114
|
-
File.unlink(
|
144
|
+
File.unlink(symlink)
|
115
145
|
rescue Errno::ENOENT # rubocop:disable Lint/HandleExceptions
|
116
146
|
end
|
117
|
-
help(['new'])
|
118
147
|
end
|
119
148
|
end
|
120
149
|
|
@@ -122,16 +151,17 @@ desc 'Delete "image"'
|
|
122
151
|
arg 'image'
|
123
152
|
command :rm do |c|
|
124
153
|
c.action do |_global_options, _options, args|
|
125
|
-
file = "#{
|
154
|
+
file = "#{symlink}.#{args[0]}"
|
126
155
|
unless File.exist?(file)
|
127
156
|
$stderr.puts "Image #{args[0]} doesnt exist!"
|
128
157
|
exit 1
|
129
158
|
end
|
130
|
-
if
|
159
|
+
if readlink == file
|
131
160
|
$stderr.puts "Can't delete currently linked image"
|
132
161
|
exit 1
|
133
162
|
end
|
134
163
|
|
164
|
+
$stderr.puts "Removing #{file} to ${link}" if global_options[:verbose]
|
135
165
|
File.unlink(file)
|
136
166
|
end
|
137
167
|
end
|
@@ -141,14 +171,18 @@ arg 'image'
|
|
141
171
|
command :use do |c|
|
142
172
|
c.action do |global_options, _options, args|
|
143
173
|
running?(global_options)
|
144
|
-
|
174
|
+
ext = args[0]
|
175
|
+
file = Dir.glob("#{DIR}/Docker.*.#{ext}")[0]
|
145
176
|
File.exist?(file) or raise "Image #{file} does not exist"
|
146
177
|
|
147
178
|
begin
|
148
|
-
File.unlink(
|
179
|
+
File.unlink(symlink)
|
149
180
|
rescue Errno::ENOENT # rubocop:disable Lint/HandleExceptions
|
150
181
|
end
|
151
|
-
|
182
|
+
|
183
|
+
$stderr.puts "Linking #{file} to #{symlink}" if global_options[:verbose]
|
184
|
+
|
185
|
+
File.symlink(file, symlink)
|
152
186
|
end
|
153
187
|
end
|
154
188
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Frankel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
118
|
rubyforge_project:
|
119
|
-
rubygems_version: 2.
|
119
|
+
rubygems_version: 2.7.4
|
120
120
|
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: A tool to switch docker for mac environments
|