durable-dockerpage 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/dockerpage +164 -0
- data/lib/durable/dockerpage/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bdb1be1ed901b25ca42769d8c16e5c82db63d4fd02d285223f1220d2df0d11d
|
4
|
+
data.tar.gz: 2dfb5abb858e6f96b792af36a404947c78b1b711a02e0bfabfb30c795655879f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56f45ce039715c9097fb2de2ad6f19f6d80a9d5d4ae96a32933a34b37bd5f7f9a7e093c4fd779985e052e8c2bfc13b86533801e9fa05b7255731f86a07373a7c
|
7
|
+
data.tar.gz: bdbeacf7bc4937547b44a8927b932f7addebc8a6100e2ac9f35be088a90135d3169a7571065e111c178c54b8a81a4e09435a24cf536a6c65c644032f239ade51
|
data/bin/dockerpage
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
#!/usr/bin/env -S sh -c '"`dirname $(readlink -f $0)`/wrapper.sh" ruby "$0" "$@"'
|
2
|
+
|
3
|
+
require 'bundler/inline'
|
4
|
+
|
5
|
+
gemfile do
|
6
|
+
source 'https://rubygems.org'
|
7
|
+
gem 'docker-api'
|
8
|
+
gem 'terminal-table'
|
9
|
+
gem 'curses'
|
10
|
+
gem 'tty-screen'
|
11
|
+
gem 'tty-table'
|
12
|
+
gem 'pastel'
|
13
|
+
gem 'clipboard'
|
14
|
+
gem 'launchy'
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'docker-api'
|
18
|
+
require 'csv'
|
19
|
+
require 'terminal-table'
|
20
|
+
require 'curses'
|
21
|
+
require 'tty-screen'
|
22
|
+
require 'tty-table'
|
23
|
+
require 'pastel'
|
24
|
+
require 'clipboard'
|
25
|
+
require 'launchy'
|
26
|
+
|
27
|
+
port_data = {}
|
28
|
+
|
29
|
+
class DockerTUI
|
30
|
+
def initialize
|
31
|
+
@selected_index = 0
|
32
|
+
end
|
33
|
+
|
34
|
+
def col_fmt(raw, width)
|
35
|
+
out = raw.dup
|
36
|
+
|
37
|
+
if out.length > width
|
38
|
+
overage = out.length - ( width )
|
39
|
+
out = out[0..(-(overage+7))] + '...' + out[-3..-1]
|
40
|
+
end
|
41
|
+
|
42
|
+
puts 'oopsy' if out.length > width
|
43
|
+
out = out.ljust(width)
|
44
|
+
out
|
45
|
+
end
|
46
|
+
def run
|
47
|
+
Curses.init_screen
|
48
|
+
Curses.start_color
|
49
|
+
Curses.cbreak
|
50
|
+
Curses.noecho
|
51
|
+
Curses.stdscr.keypad(true)
|
52
|
+
Curses.curs_set 0
|
53
|
+
Curses.timeout = 1
|
54
|
+
|
55
|
+
|
56
|
+
Curses.init_pair(1, 0, 0)
|
57
|
+
Curses.init_pair(2, 16, 2)
|
58
|
+
Curses.init_pair(3, 2, 0)
|
59
|
+
Curses.init_pair(4, 3, 0)
|
60
|
+
Curses.init_pair(5, 4, 0)
|
61
|
+
Curses.init_pair(6, 5, 0)
|
62
|
+
Curses.init_pair(7, 6, 0)
|
63
|
+
Curses.init_pair(8, 7, 0)
|
64
|
+
Curses.init_pair(9, 8, 0)
|
65
|
+
Curses.init_pair(10, 9, 0)
|
66
|
+
begin
|
67
|
+
update_screen
|
68
|
+
|
69
|
+
die = false
|
70
|
+
while !die
|
71
|
+
key = Curses.getch
|
72
|
+
case key
|
73
|
+
when 'q'
|
74
|
+
die = true
|
75
|
+
when 'k'
|
76
|
+
@selected_index -= 1
|
77
|
+
when 'j'
|
78
|
+
@selected_index += 1
|
79
|
+
when 'c'
|
80
|
+
Clipboard.copy(@display_rows[@selected_index][2])
|
81
|
+
when 'l'
|
82
|
+
Launchy.open( "http://" + @display_rows[@selected_index][2])
|
83
|
+
when 'x'
|
84
|
+
@display_row_containers[@selected_index].stop
|
85
|
+
end
|
86
|
+
|
87
|
+
update_screen
|
88
|
+
end
|
89
|
+
ensure
|
90
|
+
Curses.close_screen
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def update_screen
|
97
|
+
@containers = Docker::Container.all
|
98
|
+
headers = ['Container Name', 'Image', 'Private IPs', 'Ports']
|
99
|
+
pastel = Pastel.new
|
100
|
+
table = TTY::Table.new(headers, [])
|
101
|
+
|
102
|
+
|
103
|
+
@display_rows = []
|
104
|
+
@display_row_containers = []
|
105
|
+
idx = 0
|
106
|
+
@selected_index = [0,@selected_index].max
|
107
|
+
@selected_index = [@containers.length-1,@selected_index].min
|
108
|
+
@containers.each do |container|
|
109
|
+
|
110
|
+
@display_row_containers[idx] = container
|
111
|
+
|
112
|
+
|
113
|
+
row = [container.info['Names'][0].gsub(/^\//, '')]
|
114
|
+
row << container.info['Image']
|
115
|
+
|
116
|
+
ips = []
|
117
|
+
|
118
|
+
container.info.dig('NetworkSettings', 'Networks').each do |name, net|
|
119
|
+
ips << net['IPAddress']
|
120
|
+
end
|
121
|
+
|
122
|
+
row << ips.first #.join(', ').slice(0..32)
|
123
|
+
|
124
|
+
ports = []
|
125
|
+
(container.info['Ports']).each do |portspec|
|
126
|
+
ports << [portspec['PublicPort'], portspec['PrivatePort']].join(":")
|
127
|
+
end
|
128
|
+
|
129
|
+
row << ports.sort.join(', ').slice(0..32)
|
130
|
+
|
131
|
+
@display_rows[idx] = row
|
132
|
+
idx += 1
|
133
|
+
end
|
134
|
+
|
135
|
+
idx = 0
|
136
|
+
@display_rows.each do |row|
|
137
|
+
Curses.setpos( (idx)*1, 0)
|
138
|
+
if idx == @selected_index
|
139
|
+
|
140
|
+
Curses.attron(Curses.color_pair(2)) do
|
141
|
+
out = []
|
142
|
+
row.each_with_index { |v,k| out.push col_fmt(v, k == 0 ? 30 : 16) }
|
143
|
+
|
144
|
+
Curses.addstr( out .join(" | ") + "\n\n")
|
145
|
+
end
|
146
|
+
|
147
|
+
else
|
148
|
+
Curses.attron(Curses.color_pair(3)) do
|
149
|
+
out = []
|
150
|
+
row.each_with_index { |v,k| out.push col_fmt(v, k == 0 ? 30 : 16) }
|
151
|
+
|
152
|
+
Curses.addstr( out .join(" | ") + "\n\n")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
idx +=1
|
157
|
+
end
|
158
|
+
|
159
|
+
Curses.refresh
|
160
|
+
#Curses.addstr(table.render(:unicode, resize: true))
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
DockerTUI.new.run
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: durable-dockerpage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Your Name
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -238,13 +238,15 @@ description: Durable Dockerpage provides a terminal user interface for managing
|
|
238
238
|
containers
|
239
239
|
email:
|
240
240
|
- djberube@durableprogramming.com
|
241
|
-
executables:
|
241
|
+
executables:
|
242
|
+
- dockerpage
|
242
243
|
extensions: []
|
243
244
|
extra_rdoc_files: []
|
244
245
|
files:
|
245
246
|
- ".mise.toml"
|
246
247
|
- LICENSE.txt
|
247
248
|
- README.md
|
249
|
+
- bin/dockerpage
|
248
250
|
- lib/durable/dockerpage.rb
|
249
251
|
- lib/durable/dockerpage/version.rb
|
250
252
|
homepage: https://github.com/yourusername/durable-dockerpage
|