hyperdock 0.17.0 → 0.17.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3199bd98c6e433616b7f93f2ebc5cc563bf5245b
4
- data.tar.gz: f7e9f3b3766168c5346644a12edd1ce113a8d2ad
3
+ metadata.gz: eadebb2c8c8687e53e78bcfea870323b5f439816
4
+ data.tar.gz: d7d9a58cac8f941cc409c62ebebc02800ee77be2
5
5
  SHA512:
6
- metadata.gz: 0524fa9d17bd4795df39fc9f4c387b22bd0a5b9c92ea1a1261adf4cf405276199411313185b7cc10dc10d5ebd7802399a3ea0ef47bdedc7a2a0d044846f7c4b1
7
- data.tar.gz: 39a028023a305107825a1106f62e4400aba42e1fcaf362d512e0f8e03a5814a67ec1ec82ea0af105f794d670b1cf16ad0088e9fb0ee0db85efd2ce8d20aa30bc
6
+ metadata.gz: 66fdfab3468bf520587f966e878eb10fd55c879a0508a312546c2067a2a2b6881fe562a0961379750191f67c68f372ca149d0d8458d937d175f7241e307833e0
7
+ data.tar.gz: c6b360a7e348a953efd79df830993152ebfb7384ca6eb42529ead6c4af994ab24a0aca5ea46dcf31e5dfe5bea6bf959646e3586cd0a806351c47ea2cf3e869f9
@@ -19,32 +19,50 @@ module HyperDock
19
19
  false
20
20
  end
21
21
 
22
- Contract None => ArrayOf[HashOf[RespondTo[:to_s], String]]
22
+ def attributes
23
+ @attributes ||= container.info
24
+ end
25
+
26
+ Contract None => Hash
23
27
  def networks
24
- @networks ||= (container.info.dig('NetworkSettings', 'Networks') || {})
25
- .values
26
- .map { |network| network['NetworkID'] }
27
- .compact
28
- .map { |network| { href: "/network/#{network}" } }
28
+ @networks ||= attributes.dig('NetworkSettings', 'Networks') || {}
29
29
  end
30
30
 
31
+ Contract None => ArrayOf[Hash]
32
+ def network_links
33
+ @network_links ||= networks.flat_map do |name, network|
34
+ { name: name, href: "/network/#{network['NetworkID']}" }
35
+ end
36
+ end
37
+
38
+ Contract None => ArrayOf[Hash]
31
39
  def volumes
32
- @volumes ||= container
33
- .info
34
- .fetch('Mounts') { [] }
35
- .map { |volume| { href: "/volume/#{volume.fetch('Name')}" } }
40
+ @volumes ||= attributes.fetch('Mounts') { [] }
41
+ end
42
+
43
+ Contract None => ArrayOf[Hash]
44
+ def volume_links
45
+ @volume_links ||= volumes.map do |volume|
46
+ { name: volume['Destination'], href: "/volume/#{volume['Name']}" }
47
+ end
48
+ end
49
+
50
+ def named_links
51
+ @named_links ||= [
52
+ network_links
53
+ .map { |network| { "network:#{network[:name]}" => network } },
54
+ volume_links
55
+ .map { |volume| { "volume:#{volume[:name]}" => volume } }
56
+ ].flatten.reduce(&:merge)
36
57
  end
37
58
 
59
+ Contract None => HashOf[RespondTo[:to_s], Or[Hash, ArrayOf[Hash]]]
38
60
  def links
39
61
  @links ||= {
40
- networks: networks,
41
- volumes: volumes,
62
+ networks: network_links,
63
+ volumes: volume_links,
42
64
  ports: { href: "/#{request.disp_path}/ports" }
43
- }
44
- end
45
-
46
- def attributes
47
- { info: container.info }
65
+ }.merge(named_links)
48
66
  end
49
67
  end
50
68
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperdock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.17.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Olstrom