docker-template 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/docker/template/cli.rb +4 -7
- data/lib/docker/template/cli/build.rb +12 -13
- data/lib/docker/template/cli/list.rb +33 -23
- data/lib/docker/template/metadata.rb +10 -8
- data/lib/docker/template/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65d8ac03dfdfff807d45042ee8ef216ab95ed5e9
|
4
|
+
data.tar.gz: 5880b1219f93034e09a4aa2e1883b21613ceebcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db84df63be77fc58635612412aad480149256d0bfe7d0c1091fe48e63c06b1253847992753ba8246f2e7f4c6060afc75406fe084ae493ecc07e9db930903a89a
|
7
|
+
data.tar.gz: 11fd17eb806960784b721c4b66f0849d484c924384a47b6fa539f4f5d5cdc253c3be37f8adfc3a30941faf8e0122c6cadb563cce4013949157b1054d8d0faa13
|
data/lib/docker/template/cli.rb
CHANGED
@@ -28,20 +28,18 @@ module Docker
|
|
28
28
|
option :mocking, :type => :boolean, :desc => "Disable Certain Actions."
|
29
29
|
option :clean, :type => :boolean, :desc => "Cleanup your caches."
|
30
30
|
|
31
|
+
# ----------------------------------------------------------------------
|
32
|
+
# rubocop:disable Lint/RescueException
|
31
33
|
# ----------------------------------------------------------------------
|
32
34
|
|
33
35
|
def build(*args)
|
34
36
|
Build.new(args, options).start
|
37
|
+
|
35
38
|
rescue Docker::Template::Error::StandardError => e
|
36
39
|
$stderr.puts Simple::Ansi.red(e.message)
|
37
40
|
exit e.respond_to?(:status) ? \
|
38
41
|
e.status : 1
|
39
42
|
|
40
|
-
rescue Excon::Errors::SocketError
|
41
|
-
$stderr.puts "Unable to connect to your Docker Instance."
|
42
|
-
$stderr.puts "Are you absolutely sure that you have the Docker installed?"
|
43
|
-
abort "Unable to build your images."
|
44
|
-
|
45
43
|
rescue Exception
|
46
44
|
raise unless $ERROR_POSITION
|
47
45
|
$ERROR_POSITION.delete_if do |source|
|
@@ -52,13 +50,12 @@ module Docker
|
|
52
50
|
end
|
53
51
|
|
54
52
|
# ----------------------------------------------------------------------
|
53
|
+
# rubocop:enable Lint/RescueException
|
55
54
|
# docker-template list [options]
|
56
55
|
# ----------------------------------------------------------------------
|
57
56
|
|
58
57
|
desc "list [OPTS]", "List all possible builds."
|
59
58
|
|
60
|
-
# ----------------------------------------------------------------------
|
61
|
-
# rubocop:disable Metrics/AbcSize
|
62
59
|
# ----------------------------------------------------------------------
|
63
60
|
|
64
61
|
def list
|
@@ -19,23 +19,20 @@ module Docker
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# --------------------------------------------------------------------
|
23
|
+
# rubocop:disable Metrics/AbcSize
|
22
24
|
# --------------------------------------------------------------------
|
23
25
|
|
24
26
|
def reselect_repos
|
25
27
|
Template._require "rugged" do
|
26
|
-
git = Rugged::Repository.new(
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
set.merge(file.split("/").values_at(
|
35
|
-
1
|
36
|
-
))
|
37
|
-
end
|
38
|
-
end
|
28
|
+
git = Rugged::Repository.new(Template.root.to_s)
|
29
|
+
dir = Template.root.join(@opts.repos_dir)
|
30
|
+
|
31
|
+
repos = git.last_commit.diff.each_delta.each_with_object(Set.new) do |delta, set|
|
32
|
+
next unless Pathutil.new(delta.new_file[:path]).expand_path(Template.root).in_path?(dir)
|
33
|
+
set.merge(delta.new_file[:path].split("/").values_at(
|
34
|
+
1
|
35
|
+
))
|
39
36
|
end
|
40
37
|
|
41
38
|
@repos = @repos.select do |repo|
|
@@ -46,6 +43,8 @@ module Docker
|
|
46
43
|
end
|
47
44
|
end
|
48
45
|
|
46
|
+
# --------------------------------------------------------------------
|
47
|
+
# rubocop:enable Metrics/AbcSize
|
49
48
|
# --------------------------------------------------------------------
|
50
49
|
|
51
50
|
private
|
@@ -3,9 +3,7 @@ module Docker
|
|
3
3
|
class CLI
|
4
4
|
class List
|
5
5
|
def self.build
|
6
|
-
return
|
7
|
-
new.build
|
8
|
-
)
|
6
|
+
return new.build
|
9
7
|
end
|
10
8
|
|
11
9
|
# --------------------------------------------------------------------
|
@@ -19,7 +17,7 @@ module Docker
|
|
19
17
|
def build
|
20
18
|
out = ""
|
21
19
|
|
22
|
-
@images.group_by
|
20
|
+
@images.group_by(&:user).each do |user, images|
|
23
21
|
out += "[user] " + Simple::Ansi.blue(user) + "\n" + repos(
|
24
22
|
user, images
|
25
23
|
)
|
@@ -33,7 +31,7 @@ module Docker
|
|
33
31
|
def repos(user, images)
|
34
32
|
out = ""
|
35
33
|
|
36
|
-
images.group_by
|
34
|
+
images.group_by(&:name).each do |name, _|
|
37
35
|
out += " ├─ [repo] " + Simple::Ansi.green(name) + "\n"
|
38
36
|
out += tags(user, name, images)
|
39
37
|
out += remote_aliases(
|
@@ -49,9 +47,7 @@ module Docker
|
|
49
47
|
def tags(user, name, images)
|
50
48
|
out = ""
|
51
49
|
|
52
|
-
images.select { |image| image.name == name && image.user == user
|
53
|
-
&& !image.alias? }.each do |image|
|
54
|
-
|
50
|
+
images.select { |image| image.name == name && image.user == user && !image.alias? }.each do |image|
|
55
51
|
out += " │ ├─ [tag] " + Simple::Ansi.magenta(image.tag) + "\n"
|
56
52
|
out += aliases(
|
57
53
|
user, name, image.tag, images
|
@@ -63,19 +59,22 @@ module Docker
|
|
63
59
|
|
64
60
|
# --------------------------------------------------------------------
|
65
61
|
|
66
|
-
def remote_aliases(
|
62
|
+
def remote_aliases(*args)
|
67
63
|
out = ""
|
68
64
|
|
69
|
-
|
70
|
-
|
71
|
-
|
65
|
+
remotes = _remote_aliases(*args).group_by do |image|
|
66
|
+
image.metadata[:aliases][
|
67
|
+
image.tag
|
68
|
+
]
|
69
|
+
end
|
72
70
|
|
71
|
+
remotes.each do |remote, images_|
|
73
72
|
out += " │ ├─ [remote] "
|
74
73
|
out += Simple::Ansi.yellow(remote)
|
75
74
|
out += "\n"
|
76
75
|
|
77
76
|
images_.each do |image|
|
78
|
-
out +=
|
77
|
+
out += " │ │ ├─ [alias] "
|
79
78
|
out += Simple::Ansi.yellow(
|
80
79
|
image.tag
|
81
80
|
)
|
@@ -89,20 +88,31 @@ module Docker
|
|
89
88
|
|
90
89
|
# --------------------------------------------------------------------
|
91
90
|
|
91
|
+
def _remote_aliases(user, name, images)
|
92
|
+
images.select do |image|
|
93
|
+
image.user == user && image.name == name && aliased_remote?(
|
94
|
+
image
|
95
|
+
)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# --------------------------------------------------------------------
|
100
|
+
|
92
101
|
def aliases(user, name, tag, images, depth: 0)
|
93
102
|
out = ""
|
94
103
|
|
95
104
|
_aliases(user, name, tag, images).each do |alias_|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
105
|
+
name_ = \
|
106
|
+
if alias_.name == name
|
107
|
+
Simple::Ansi.yellow(
|
108
|
+
alias_.tag
|
109
|
+
)
|
110
|
+
|
111
|
+
else
|
112
|
+
Simple::Ansi.yellow(
|
113
|
+
"#{alias_.name}:#{alias_.tag}"
|
114
|
+
)
|
115
|
+
end
|
106
116
|
|
107
117
|
out += " │ │ #{"│ " * depth}├─ [alias] #{name_}\n"
|
108
118
|
out += aliases(user, name, alias_.tag, images, {
|
@@ -596,21 +596,23 @@ module Docker
|
|
596
596
|
|
597
597
|
private
|
598
598
|
def method_missing(method, *args, shell: false, &block)
|
599
|
-
key
|
600
|
-
val
|
601
|
-
|
599
|
+
key = method.to_s.gsub(/\?$/, "")
|
600
|
+
val = self[key] || self[key.singularize] \
|
601
|
+
|| self[key.pluralize]
|
602
602
|
|
603
603
|
if !args.empty? || block_given?
|
604
604
|
super
|
605
605
|
|
606
606
|
elsif method !~ /\?$/
|
607
|
-
string_wrapper(
|
608
|
-
|
609
|
-
)
|
607
|
+
string_wrapper(val, {
|
608
|
+
:shell => shell
|
609
|
+
})
|
610
610
|
|
611
611
|
else
|
612
|
-
|
613
|
-
|
612
|
+
[true, false].include?(val) ? val : \
|
613
|
+
if val.respond_to?(:empty?)
|
614
|
+
then !val.empty? else !!val
|
615
|
+
end
|
614
616
|
end
|
615
617
|
end
|
616
618
|
|