takeltau 0.44.8 → 0.44.11
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/README.md +3 -0
- data/lib/takeltau/ship/cli.rb +32 -0
- data/lib/takeltau/ship/container/lib.rb +1 -1
- data/lib/takeltau/ship/ports/lib.rb +16 -2
- data/lib/takeltau/ship/project/start.rb +43 -23
- data/lib/takeltau/version +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ddae907069e4203d6fd9ab233e4e39573a2c9db4a4921868fa53e3375172d18
|
4
|
+
data.tar.gz: 0bae02ff5ccaa0885c4c08c9ea2dd4e48dec96b8b6164532a86b5fd3add3fc8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a263b2321750b5547d6234c35a85a75a06fbe8b9e357f5aa18af74f0aa1300c28fab6b830d662fb239f03a6188e730a39659c1fc8e8db2b89b6ff4ef6349b0a
|
7
|
+
data.tar.gz: b0024cf566206e62ffd3e5d1f407d04217ca66b0738d77ee8c2c31e5f897af951ad312cf7c799761ee3ea3abd1f2afba6fbfc9aaf2dd86442fcc3d54115fccc7
|
data/README.md
CHANGED
@@ -131,15 +131,18 @@ tau [ship project list](features/cucumber/features/ship/project/ship.project.lis
|
|
131
131
|
tau [ship project logs](features/cucumber/features/ship/project/ship.project.logs.feature) [PROJECT] | Follow logs of a takelship [PROJECT]
|
132
132
|
tau [ship project start](features/cucumber/features/ship/project/ship.project.start.feature) [PROJECT] | Start a takelship [PROJECT]
|
133
133
|
tau [ship project stop](features/cucumber/features/ship/project/ship.project.stop.feature) | Stop a takelship project
|
134
|
+
tau ship board | Alias for tau [ship container login](features/cucumber/features/ship/container/ship.container.login.feature)
|
134
135
|
tau ship command [COMMAND] | Alias for tau [ship container command](features/cucumber/features/ship/container/ship.container.command.feature)
|
135
136
|
tau ship list | Alias for tau [ship container list](features/cucumber/features/ship/container/ship.container.list.feature)
|
136
137
|
tau ship login | Alias for tau [ship container login](features/cucumber/features/ship/container/ship.container.login.feature)
|
137
138
|
tau ship logs [PROJECT] | Alias for tau [ship project logs](features/cucumber/features/ship/project/ship.project.logs.feature)
|
138
139
|
tau ship ls | Alias for tau [ship container list](features/cucumber/features/ship/container/ship.container.list.feature)
|
139
140
|
tau ship podman [COMMAND] | Alias for tau [ship container podman](features/cucumber/features/ship/container/ship.container.podman.feature)
|
141
|
+
tau ship sail [PROJECT] | Alias for tau [ship project start](features/cucumber/features/ship/project/ship.project.start.feature)
|
140
142
|
tau ship start [PROJECT] | Alias for tau [ship project start](features/cucumber/features/ship/project/ship.project.start.feature)
|
141
143
|
tau ship stop | Alias for tau [ship project stop](features/cucumber/features/ship/project/ship.project.stop.feature)
|
142
144
|
tau ship sudo [COMMAND] | Alias for tau [ship container sudo](features/cucumber/features/ship/container/ship.container.sudo.feature)
|
145
|
+
tau ship wreck | Alias for tau [ship project stop](features/cucumber/features/ship/project/ship.project.stop.feature)
|
143
146
|
tau ship update | Alias for tau [ship container update](features/cucumber/features/ship/container/ship.container.update.feature)
|
144
147
|
tau clean | Alias for tau [docker container clean](features/cucumber/features/docker/docker.container.clean.feature)
|
145
148
|
tau commands | Alias for tau [self commands](features/cucumber/features/self/self.commands.feature)
|
data/lib/takeltau/ship/cli.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
module Takeltau
|
4
4
|
# tau ship
|
5
|
+
# rubocop:disable Metrics/ClassLength
|
5
6
|
class Ship < SubCommandBase
|
6
7
|
include LoggingModule
|
7
8
|
include SystemModule
|
@@ -35,6 +36,16 @@ module Takeltau
|
|
35
36
|
# Top-level ship commands
|
36
37
|
#
|
37
38
|
|
39
|
+
desc 'board', 'Log in to a takelship'
|
40
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
41
|
+
Log in to a takelship as root.
|
42
|
+
Alias for ship container login.
|
43
|
+
LONGDESC
|
44
|
+
# ship board: {Takeltau::ShipContainer#login}
|
45
|
+
def board
|
46
|
+
Takeltau::ShipContainer.new.login
|
47
|
+
end
|
48
|
+
|
38
49
|
desc 'command [COMMAND]', 'Run a [COMMAND] in a takelship'
|
39
50
|
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
40
51
|
Run a command in a takelship container as user podman.
|
@@ -115,6 +126,16 @@ module Takeltau
|
|
115
126
|
Takeltau::ShipProject.new.start project
|
116
127
|
end
|
117
128
|
|
129
|
+
desc 'sail [PROJECT]', 'Start takelship [PROJECT]'
|
130
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
131
|
+
Start a takelship and run project [PROJECT] in it.
|
132
|
+
Alias for ship project start.
|
133
|
+
LONGDESC
|
134
|
+
# ship sail: {Takeltau::ShipProject#start}
|
135
|
+
def sail(project = 'default')
|
136
|
+
Takeltau::ShipProject.new.start project
|
137
|
+
end
|
138
|
+
|
118
139
|
desc 'stop', 'Stop a takelship'
|
119
140
|
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
120
141
|
Stop a takelship container.
|
@@ -125,6 +146,16 @@ module Takeltau
|
|
125
146
|
Takeltau::ShipProject.new.stop
|
126
147
|
end
|
127
148
|
|
149
|
+
desc 'wreck', 'Stop a takelship'
|
150
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
151
|
+
Stop a takelship container.
|
152
|
+
Alias for ship container stop.
|
153
|
+
LONGDESC
|
154
|
+
# ship wreck: {Takeltau::ShipProject#stop}
|
155
|
+
def wreck
|
156
|
+
Takeltau::ShipProject.new.stop
|
157
|
+
end
|
158
|
+
|
128
159
|
desc 'update', 'Update takelship image'
|
129
160
|
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
130
161
|
Update the takelship docker image.
|
@@ -135,4 +166,5 @@ module Takeltau
|
|
135
166
|
Takeltau::ShipContainer.new.update
|
136
167
|
end
|
137
168
|
end
|
169
|
+
# rubocop:enable Metrics/ClassLength
|
138
170
|
end
|
@@ -22,7 +22,7 @@ module ShipContainerLib
|
|
22
22
|
ship_data_dir = config.active['ship_data_dir']
|
23
23
|
ship_env = [config.active['ship_env']]
|
24
24
|
ports.each do |key, port|
|
25
|
-
envvar = "
|
25
|
+
envvar = "TAKELSHIP_#{key}".upcase
|
26
26
|
envstr = "--env #{envvar}=#{port['localhost']}"
|
27
27
|
ship_env << envstr
|
28
28
|
end
|
@@ -53,27 +53,41 @@ module ShipPortsLib
|
|
53
53
|
takel_docker = takelship['docker_host']
|
54
54
|
docker_key = "ship_ports_dind_docker_#{takel_docker}"
|
55
55
|
local_docker = _ship_ports_lib_get_localhost_port docker_key, takel_docker
|
56
|
+
docker_host = "DOCKER_HOST=tcp://localhost:#{local_docker}"
|
56
57
|
{
|
57
58
|
docker_key => {
|
58
59
|
'service' => 'dind',
|
59
60
|
'protocol' => 'docker',
|
60
61
|
'takelship' => takel_docker.to_i,
|
61
|
-
'localhost' => local_docker
|
62
|
+
'localhost' => local_docker,
|
63
|
+
'description' => docker_host
|
62
64
|
}
|
63
65
|
}
|
64
66
|
end
|
65
67
|
# rubocop:enable Metrics/MethodLength
|
66
68
|
|
67
69
|
# map a takelship port
|
70
|
+
# rubocop:disable Metrics/MethodLength
|
68
71
|
def _ship_ports_lib_get_port(key, port, service)
|
69
72
|
localhost = _ship_ports_lib_get_localhost_port key, port['port']
|
73
|
+
unless port.key?('description')
|
74
|
+
return {
|
75
|
+
'service' => service['name'],
|
76
|
+
'protocol' => port['protocol'],
|
77
|
+
'takelship' => port['port'],
|
78
|
+
'localhost' => localhost
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
70
82
|
{
|
71
83
|
'service' => service['name'],
|
72
84
|
'protocol' => port['protocol'],
|
73
85
|
'takelship' => port['port'],
|
74
|
-
'localhost' => localhost
|
86
|
+
'localhost' => localhost,
|
87
|
+
'description' => port['description']
|
75
88
|
}
|
76
89
|
end
|
90
|
+
# rubocop:enable Metrics/MethodLength
|
77
91
|
|
78
92
|
# get new port on localhost for takelport
|
79
93
|
def _ship_ports_lib_get_localhost_port(key, port)
|
@@ -3,8 +3,9 @@
|
|
3
3
|
# tau ship project start
|
4
4
|
module ShipProjectStart
|
5
5
|
# Start a takelship
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
6
7
|
def ship_project_start(project)
|
7
|
-
return false unless
|
8
|
+
return false unless _ship_project_start_matrjoschka?
|
8
9
|
|
9
10
|
takelship = _ship_info_lib_get_takelshipinfo
|
10
11
|
project = _ship_info_lib_get_project project, takelship
|
@@ -13,30 +14,35 @@ module ShipProjectStart
|
|
13
14
|
|
14
15
|
ports = _ship_ports_lib_get_ports(takelship, project)
|
15
16
|
|
17
|
+
return false unless _ship_project_start_sailing? project, ports
|
18
|
+
|
16
19
|
log.debug 'Writing port configuration to takelage.yml'
|
17
20
|
_ship_ports_lib_write_ports(ports, project)
|
18
21
|
|
19
22
|
log.debug "Starting takelship project \"#{project}\""
|
20
23
|
_ship_container_lib_docker_privileged ports, project
|
21
|
-
|
22
|
-
_ship_project_start_print_ports
|
24
|
+
say "Started project \"#{project}\" on takelship \"#{_ship_container_lib_ship_hostname}\".\n\n"
|
25
|
+
_ship_project_start_print_ports ports
|
23
26
|
end
|
27
|
+
# rubocop:enable Metrics/MethodLength
|
24
28
|
|
25
29
|
private
|
26
30
|
|
27
|
-
# check
|
28
|
-
def
|
29
|
-
|
30
|
-
say 'Cannot start a takelship from within a takelage container!'
|
31
|
-
return false
|
32
|
-
end
|
31
|
+
# check if we are inside a takelage container
|
32
|
+
def _ship_project_start_matrjoschka?
|
33
|
+
return true unless _docker_container_lib_check_matrjoschka
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
say 'Cannot start a takelship from within a takelage container!'
|
36
|
+
false
|
37
|
+
end
|
38
|
+
|
39
|
+
# check if the takelship is already existng
|
40
|
+
def _ship_project_start_sailing?(project, ports)
|
41
|
+
return true unless ship_container_check_existing
|
38
42
|
|
39
|
-
|
43
|
+
say "The takelship \"#{_ship_container_lib_ship_hostname}\" is sailing with project \"#{project}\".\n\n"
|
44
|
+
say _ship_project_start_print_ports ports
|
45
|
+
false
|
40
46
|
end
|
41
47
|
|
42
48
|
# check if the project is a valid takelship project
|
@@ -44,35 +50,49 @@ module ShipProjectStart
|
|
44
50
|
return true if _ship_info_lib_valid_project? takelship, project
|
45
51
|
|
46
52
|
say 'No valid project found!'
|
53
|
+
say 'Hint: ship project list'
|
47
54
|
false
|
48
55
|
end
|
49
56
|
|
50
57
|
# print ports after starting a takelship
|
51
|
-
|
58
|
+
# rubocop:disable Metrics/MethodLength
|
59
|
+
# rubocop:disable Metrics/AbcSize
|
60
|
+
def _ship_project_start_print_ports(ports)
|
52
61
|
output = []
|
53
|
-
output << "Started takelship project \"#{project}\"\n"
|
54
62
|
max_length = _ship_project_start_get_maxlength ports
|
55
|
-
|
56
63
|
ports.each_value do |port|
|
57
64
|
next unless port['localhost'].to_i.between? 1, 65_535
|
58
65
|
|
59
|
-
|
60
|
-
|
61
|
-
|
66
|
+
url = "localhost:#{port['localhost']}"
|
67
|
+
service = "[#{port['service']} #{port['protocol']}]"
|
68
|
+
description = port['description']
|
69
|
+
description = " (#{description})" if port.key? 'description'
|
70
|
+
output << "#{url.ljust(max_length['url'])} #{service.ljust(max_length['service'])}#{description}"
|
62
71
|
end
|
63
72
|
output.join("\n")
|
64
73
|
end
|
74
|
+
# rubocop:enable Metrics/AbcSize
|
75
|
+
# rubocop:enable Metrics/MethodLength
|
65
76
|
|
66
77
|
# get max length of left column
|
78
|
+
# rubocop:disable Metrics/MethodLength
|
79
|
+
# rubocop:disable Metrics/AbcSize
|
67
80
|
def _ship_project_start_get_maxlength(ports)
|
68
|
-
max_length =
|
81
|
+
max_length = {}
|
82
|
+
max_length['url'] = 0
|
83
|
+
max_length['service'] = 0
|
69
84
|
ports.each_value do |port|
|
70
85
|
localport = port['localhost']
|
71
86
|
next unless localport.to_i.between? 1, 65_535
|
72
87
|
|
73
|
-
|
74
|
-
max_length =
|
88
|
+
url = "localhost:#{localport}"
|
89
|
+
max_length['url'] = url.length if max_length['url'] < url.length
|
90
|
+
|
91
|
+
service = "[#{port['service']} #{port['protocol']}]"
|
92
|
+
max_length['service'] = service.length if max_length['service'] < service.length
|
75
93
|
end
|
76
94
|
max_length
|
77
95
|
end
|
96
|
+
# rubocop:enable Metrics/AbcSize
|
97
|
+
# rubocop:enable Metrics/MethodLength
|
78
98
|
end
|
data/lib/takeltau/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.44.
|
1
|
+
0.44.11
|