takelage 0.27.1 → 0.28.14
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 +12 -5
- data/lib/takelage.rb +12 -0
- data/lib/takelage/default.yml +9 -0
- data/lib/takelage/docker/container/clean.rb +1 -0
- data/lib/takelage/docker/container/cli.rb +8 -0
- data/lib/takelage/docker/container/command.rb +2 -0
- data/lib/takelage/docker/container/daemon.rb +5 -1
- data/lib/takelage/docker/container/lib.rb +6 -2
- data/lib/takelage/docker/container/login.rb +3 -0
- data/lib/takelage/docker/container/prune.rb +1 -0
- data/lib/takelage/info/status/cli.rb +33 -0
- data/lib/takelage/lib/system.rb +9 -5
- data/lib/takelage/mutagen/check/cli.rb +44 -0
- data/lib/takelage/mutagen/check/daemon.rb +56 -0
- data/lib/takelage/mutagen/cli.rb +12 -0
- data/lib/takelage/mutagen/socket/check.rb +33 -0
- data/lib/takelage/mutagen/socket/cli.rb +111 -0
- data/lib/takelage/mutagen/socket/create.rb +41 -0
- data/lib/takelage/mutagen/socket/list.rb +33 -0
- data/lib/takelage/mutagen/socket/terminate.rb +32 -0
- data/lib/takelage/mutagen/socket/tidy.rb +21 -0
- data/lib/takelage/version +1 -1
- metadata +10 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 011a1f337984e2512deb1b67601fe20191a29d38d24b356c922f7c9e5e12a467
|
4
|
+
data.tar.gz: 5decfcfd262bfb3466baa3a38b7ae80bb9d314838751ae4a17777915cb90edde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 279972fa01d7b84f786198d9abcd5f7757a3ef840b13d5d9f4de31032979ede3ab45ad5d21deb8d71f8ab806ac711e6cae17bf7389c8838e15efe68abd2aaba2
|
7
|
+
data.tar.gz: 1e0c9eb0a468ff8fd5f4adbd0c969e3c2f466a5fbcdb9e0eeb0ca592ad31bcc5f11b0a0454a1fd5c819e46c545ea402ad131ab6b7b7cabe68eb105b23f7a67ad
|
data/README.md
CHANGED
@@ -102,11 +102,18 @@ tau [info project active](features/cucumber/features/info/info.project.active.fe
|
|
102
102
|
tau [info project dir](features/cucumber/features/info/info.project.dir.feature) | Print project root directory
|
103
103
|
tau [info project main](features/cucumber/features/info/info.project.main.feature) | Print main project info
|
104
104
|
tau [info project private](features/cucumber/features/info/info.project.private.feature) | Print private project info
|
105
|
-
tau [info status
|
106
|
-
tau [info status
|
107
|
-
tau [info status
|
108
|
-
tau [info status
|
109
|
-
tau [info status
|
105
|
+
tau [info status bar](features/cucumber/features/info/info.status.bar.feature) | Print status bar
|
106
|
+
tau [info status git](features/cucumber/features/info/info.status.git.feature) | Check git status
|
107
|
+
tau [info status gopass](features/cucumber/features/info/info.status.gopass.feature) | Check gopass status
|
108
|
+
tau [info status gpg](features/cucumber/features/info/info.status.gpg.feature) | Check gpg status
|
109
|
+
tau [info status mutagen](features/cucumber/features/info/info.status.mutagen.feature) | Check mutagen status
|
110
|
+
tau [info status ssh](features/cucumber/features/info/info.status.ssh.feature) | Check ssh status
|
111
|
+
tau [mutagen check daemon](features/cucumber/features/mutagen/mutagen.check.daemon.feature)) | Check if mutagen host conenction is available
|
112
|
+
tau [mutagen socket check](features/cucumber/features/mutagen/mutagen.socket.check.feature) [SOCKET] | Check if mutagen [SOCKET] exists
|
113
|
+
tau [mutagen socket create](features/cucumber/features/mutagen/mutagen.socket.create.feature) [IN] [OUT] | Create a mutagen socket from [IN] to [OUT] of the container
|
114
|
+
tau [mutagen socket list](features/cucumber/features/mutagen/mutagen.socket.list.feature) | List mutagen sockets
|
115
|
+
tau [mutagen socket tidy](features/cucumber/features/mutagen/mutagen.socket.tidy.feature) | Remove mutagen daemon files
|
116
|
+
tau [mutagen socket terminate](features/cucumber/features/mutagen/mutagen.socket.terminate.feature) | Terminate a mutagen socket
|
110
117
|
tau [self config active](features/cucumber/features/self/self.config.active.feature) | Print active takelage configuration
|
111
118
|
tau [self config default](features/cucumber/features/self/self.config.default.feature) | Print takelage default configuration
|
112
119
|
tau [self config home](features/cucumber/features/self/self.config.home.feature) | Print takelage home config file configuration
|
data/lib/takelage.rb
CHANGED
@@ -44,6 +44,10 @@ require_relative 'takelage/bit/require/import'
|
|
44
44
|
require_relative 'takelage/bit/require/cli'
|
45
45
|
require_relative 'takelage/bit/cli'
|
46
46
|
require_relative 'takelage/completion/cli'
|
47
|
+
require_relative 'takelage/mutagen/check/daemon'
|
48
|
+
require_relative 'takelage/mutagen/socket/create'
|
49
|
+
require_relative 'takelage/mutagen/socket/terminate'
|
50
|
+
require_relative 'takelage/mutagen/socket/tidy'
|
47
51
|
require_relative 'takelage/docker/check/daemon'
|
48
52
|
require_relative 'takelage/docker/check/socat'
|
49
53
|
require_relative 'takelage/docker/check/cli'
|
@@ -71,6 +75,11 @@ require_relative 'takelage/docker/container/clean'
|
|
71
75
|
require_relative 'takelage/docker/container/prune'
|
72
76
|
require_relative 'takelage/docker/container/cli'
|
73
77
|
require_relative 'takelage/docker/cli'
|
78
|
+
require_relative 'takelage/mutagen/check/cli'
|
79
|
+
require_relative 'takelage/mutagen/socket/check'
|
80
|
+
require_relative 'takelage/mutagen/socket/list'
|
81
|
+
require_relative 'takelage/mutagen/socket/cli'
|
82
|
+
require_relative 'takelage/mutagen/cli'
|
74
83
|
require_relative 'takelage/info/status/lib'
|
75
84
|
require_relative 'takelage/info/status/git'
|
76
85
|
require_relative 'takelage/info/status/gopass'
|
@@ -143,6 +152,9 @@ module Takelage
|
|
143
152
|
desc 'info [COMMAND] ', 'Get information'
|
144
153
|
subcommand 'info', Info
|
145
154
|
|
155
|
+
desc 'mutagen [COMMAND] ', 'Manage mutagen'
|
156
|
+
subcommand 'mutagen', Mutagen
|
157
|
+
|
146
158
|
desc 'self [COMMAND] ', 'Manage takelage tools'
|
147
159
|
subcommand 'self', Self
|
148
160
|
|
data/lib/takelage/default.yml
CHANGED
@@ -66,6 +66,13 @@ cmd_info_status_gopass_root_store: 'gopass config | grep "path" | cut -d " " -f
|
|
66
66
|
cmd_info_status_gpg_agent: 'gpg-connect-agent /bye'
|
67
67
|
cmd_info_status_gpg_keys: 'gpg --list-keys'
|
68
68
|
cmd_info_status_ssh_keys: 'ssh-add -l'
|
69
|
+
cmd_mutagen_check_daemon_host_connection: 'mutagen forward list --label-selector="%{hostlabel}"'
|
70
|
+
cmd_mutagen_check_daemon_version: 'mutagen version'
|
71
|
+
cmd_mutagen_forward_socket_create: 'mutagen forward create --name=%{socketname} --label=%{hostlabel} --label=%{takellabel} docker://%{username}@%{container}:unix:%{containersock} unix:%{hostsock}'
|
72
|
+
cmd_mutagen_forward_socket_check: 'mutagen forward list %{socketname}'
|
73
|
+
cmd_mutagen_forward_socket_terminate: 'mutagen forward terminate %{socketname}'
|
74
|
+
cmd_mutagen_forward_socket_remove: 'rm -f ~/.mutagen/daemon/*'
|
75
|
+
cmd_mutagen_forward_socket_list: 'mutagen forward list --label-selector="%{takellabel}"'
|
69
76
|
docker_debug: 'ansible/roles/takel-takelage/files/takelscripts'
|
70
77
|
docker_entrypoint_extra: '.config/gcloud'
|
71
78
|
docker_entrypoint_options: ''
|
@@ -80,3 +87,5 @@ docker_user: 'takelage'
|
|
80
87
|
git_main_branch: 'main'
|
81
88
|
info_project_main: 'project.yml'
|
82
89
|
info_project_private: 'private/project.yml'
|
90
|
+
mutagen_socket_path: '~/.mutagen/daemon/daemon.sock'
|
91
|
+
mutagen_socket_takelage_label: 'type=takelage-socket'
|
@@ -10,6 +10,7 @@ module DockerContainerClean
|
|
10
10
|
|
11
11
|
return false if _docker_container_clean_harakiri?
|
12
12
|
|
13
|
+
mutagen_socket_terminate "--label-selector='#{@takellabel}'"
|
13
14
|
networks = _docker_container_clean_kill_existing_containers
|
14
15
|
_docker_container_lib_remove_networks networks
|
15
16
|
end
|
@@ -24,9 +24,13 @@ module Takelage
|
|
24
24
|
include DockerSocketHost
|
25
25
|
include DockerSocketScheme
|
26
26
|
include DockerSocketStart
|
27
|
+
include MutagenCheckDaemon
|
28
|
+
include MutagenSocketCreate
|
29
|
+
include MutagenSocketTerminate
|
27
30
|
|
28
31
|
# Initialize docker container
|
29
32
|
# rubocop:disable Metrics/AbcSize
|
33
|
+
# rubocop:disable Metrics/MethodLength
|
30
34
|
def initialize(args = [], local_options = {}, configuration = {})
|
31
35
|
# initialize thor parent class
|
32
36
|
super args, local_options, configuration
|
@@ -38,9 +42,13 @@ module Takelage
|
|
38
42
|
@username = ENV['USER'] || 'noname'
|
39
43
|
@workdir = Dir.getwd
|
40
44
|
@hostname = _docker_container_lib_hostname
|
45
|
+
@hostlabel = "hostname=#{@hostname}"
|
46
|
+
@takellabel = config.active['mutagen_socket_takelage_label']
|
41
47
|
@socket_host = docker_socket_host
|
42
48
|
@sockets = docker_socket_scheme
|
49
|
+
@mutagensock = config.active['mutagen_socket_path']
|
43
50
|
end
|
51
|
+
# rubocop:enable Metrics/MethodLength
|
44
52
|
# rubocop:enable Metrics/AbcSize
|
45
53
|
|
46
54
|
desc 'check [COMMAND]', 'Check docker container'
|
@@ -11,6 +11,8 @@ module DockerContainerCommand
|
|
11
11
|
docker_socket_start
|
12
12
|
return false unless _docker_container_lib_create_net_and_ctr @hostname
|
13
13
|
|
14
|
+
mutagen_socket_create @mutagensock, @mutagensock if mutagen_check_daemon
|
15
|
+
|
14
16
|
_docker_container_command_run_command @hostname, command
|
15
17
|
end
|
16
18
|
|
@@ -8,6 +8,10 @@ module DockerContainerDaemon
|
|
8
8
|
|
9
9
|
return false unless docker_check_daemon
|
10
10
|
|
11
|
-
_docker_container_lib_create_net_and_ctr @hostname
|
11
|
+
result = _docker_container_lib_create_net_and_ctr @hostname
|
12
|
+
|
13
|
+
mutagen_socket_create @mutagensock, @mutagensock if mutagen_check_daemon
|
14
|
+
|
15
|
+
result
|
12
16
|
end
|
13
17
|
end
|
@@ -16,7 +16,10 @@ module DockerContainerLib
|
|
16
16
|
|
17
17
|
# Create docker container and network.
|
18
18
|
def _docker_container_lib_create_net_and_ctr(name)
|
19
|
-
|
19
|
+
if _docker_container_lib_check_matrjoschka
|
20
|
+
log.error 'You cannot log in to takelage from within takelage'
|
21
|
+
return false
|
22
|
+
end
|
20
23
|
|
21
24
|
unless docker_container_check_network name
|
22
25
|
_docker_container_lib_create_network name
|
@@ -108,6 +111,7 @@ module DockerContainerLib
|
|
108
111
|
|
109
112
|
try cmd_docker_create
|
110
113
|
end
|
114
|
+
|
111
115
|
# rubocop:enable Metrics/AbcSize
|
112
116
|
# rubocop:enable Metrics/MethodLength
|
113
117
|
|
@@ -117,7 +121,7 @@ module DockerContainerLib
|
|
117
121
|
|
118
122
|
return false unless ENV.keys.include? 'TAKELAGE_PROJECT_BASE_DIR'
|
119
123
|
|
120
|
-
log.
|
124
|
+
log.debug 'We are already inside a takelage container'
|
121
125
|
|
122
126
|
# wait or the github workflow will fail
|
123
127
|
sleep 1
|
@@ -9,8 +9,11 @@ module DockerContainerLogin
|
|
9
9
|
return false unless docker_check_daemon
|
10
10
|
|
11
11
|
docker_socket_start
|
12
|
+
|
12
13
|
return false unless _docker_container_lib_create_net_and_ctr @hostname
|
13
14
|
|
15
|
+
mutagen_socket_create @mutagensock, @mutagensock if mutagen_check_daemon
|
16
|
+
|
14
17
|
run_and_exit _docker_container_login_enter_container @hostname
|
15
18
|
end
|
16
19
|
|
@@ -22,6 +22,7 @@ module DockerContainerPrune
|
|
22
22
|
next unless docker_container_check_orphaned container
|
23
23
|
|
24
24
|
name = _docker_container_lib_get_container_name_by_id container
|
25
|
+
mutagen_socket_terminate "--label-selector='hostname=#{name}'"
|
25
26
|
_docker_container_lib_stop_container container
|
26
27
|
networks << name unless networks.include? name
|
27
28
|
end
|
@@ -6,7 +6,15 @@ module Takelage
|
|
6
6
|
include LoggingModule
|
7
7
|
include SystemModule
|
8
8
|
include ConfigModule
|
9
|
+
include DockerCheckDaemon
|
10
|
+
include DockerCheckSocat
|
11
|
+
include DockerContainerCheckExisting
|
12
|
+
include DockerContainerCheckNetwork
|
13
|
+
include DockerContainerCommand
|
14
|
+
include DockerContainerLib
|
15
|
+
include DockerSocketLib
|
9
16
|
include DockerSocketScheme
|
17
|
+
include DockerSocketStart
|
10
18
|
include GitCheckWorkspace
|
11
19
|
include InfoStatusLib
|
12
20
|
include InfoStatusGit
|
@@ -14,6 +22,19 @@ module Takelage
|
|
14
22
|
include InfoStatusGPG
|
15
23
|
include InfoStatusSSH
|
16
24
|
include InfoStatusBar
|
25
|
+
include MutagenCheckDaemon
|
26
|
+
|
27
|
+
# Initialize info status
|
28
|
+
def initialize(args = [], local_options = {}, configuration = {})
|
29
|
+
# initialize thor parent class
|
30
|
+
super args, local_options, configuration
|
31
|
+
|
32
|
+
@workdir = Dir.getwd
|
33
|
+
|
34
|
+
inside = _docker_container_lib_check_matrjoschka
|
35
|
+
@hostname = inside ? ENV['HOSTNAME'] : _docker_container_lib_hostname
|
36
|
+
@hostlabel = "hostname=#{@hostname}"
|
37
|
+
end
|
17
38
|
|
18
39
|
#
|
19
40
|
# info status bar
|
@@ -63,6 +84,18 @@ module Takelage
|
|
63
84
|
exit info_status_gpg
|
64
85
|
end
|
65
86
|
|
87
|
+
#
|
88
|
+
# info status mutagen
|
89
|
+
#
|
90
|
+
desc 'mutagen', 'Check mutagen status info'
|
91
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
92
|
+
Check mutagen status info
|
93
|
+
LONGDESC
|
94
|
+
# Check mutagen status info.
|
95
|
+
def mutagen
|
96
|
+
exit mutagen_check_daemon
|
97
|
+
end
|
98
|
+
|
66
99
|
#
|
67
100
|
# info status ssh
|
68
101
|
#
|
data/lib/takelage/lib/system.rb
CHANGED
@@ -51,8 +51,10 @@ module SystemModule
|
|
51
51
|
# @return [String] stdout of command
|
52
52
|
def run(command)
|
53
53
|
log.debug "Running command \"#{command}\""
|
54
|
-
stdout_str, = Open3.capture3 command
|
54
|
+
stdout_str, stderr_str, status = Open3.capture3 command
|
55
55
|
log.debug "Command \"#{command}\" has stdout:\n\"\"\"\n#{stdout_str}\"\"\""
|
56
|
+
log.debug "Command \"#{command}\" has stderr:\n\"\"\"\n#{stderr_str}\"\"\""
|
57
|
+
log.debug "Command \"#{command}\" has exit status: \"#{status.exitstatus}\""
|
56
58
|
stdout_str
|
57
59
|
end
|
58
60
|
|
@@ -75,8 +77,10 @@ module SystemModule
|
|
75
77
|
# @return [Boolean] success of command run
|
76
78
|
def try(command)
|
77
79
|
log.debug "Running command \"#{command}\""
|
78
|
-
|
79
|
-
log.debug "Command \"#{command}\" has
|
80
|
+
stdout_str, stderr_str, status = Open3.capture3 command
|
81
|
+
log.debug "Command \"#{command}\" has stdout:\n\"\"\"\n#{stdout_str}\"\"\""
|
82
|
+
log.debug "Command \"#{command}\" has stderr:\n\"\"\"\n#{stderr_str}\"\"\""
|
83
|
+
log.debug "Command \"#{command}\" has exit status: \"#{status.exitstatus}\""
|
80
84
|
status
|
81
85
|
end
|
82
86
|
|
@@ -84,7 +88,7 @@ module SystemModule
|
|
84
88
|
|
85
89
|
# Check if file exists.
|
86
90
|
def _file_exists?(file)
|
87
|
-
unless File.exist? file
|
91
|
+
unless File.exist? File.expand_path(file)
|
88
92
|
log.debug "File \"#{file}\" doesn't exist"
|
89
93
|
return false
|
90
94
|
end
|
@@ -94,7 +98,7 @@ module SystemModule
|
|
94
98
|
# Read yaml file.
|
95
99
|
def _file_read(file)
|
96
100
|
begin
|
97
|
-
@content_file = File.read file
|
101
|
+
@content_file = File.read File.expand_path(file)
|
98
102
|
rescue SystemCallError
|
99
103
|
log.debug "Unable to read file \"#{file}\""
|
100
104
|
return false
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Takelage
|
4
|
+
# takelage mutagen check
|
5
|
+
class MutagenCheck < SubCommandBase
|
6
|
+
include LoggingModule
|
7
|
+
include SystemModule
|
8
|
+
include ConfigModule
|
9
|
+
include DockerCheckDaemon
|
10
|
+
include DockerCheckSocat
|
11
|
+
include DockerContainerCheckExisting
|
12
|
+
include DockerContainerCheckNetwork
|
13
|
+
include DockerContainerCommand
|
14
|
+
include DockerContainerLib
|
15
|
+
include DockerSocketLib
|
16
|
+
include DockerSocketScheme
|
17
|
+
include DockerSocketStart
|
18
|
+
include MutagenCheckDaemon
|
19
|
+
|
20
|
+
# Initialize mutagen check
|
21
|
+
def initialize(args = [], local_options = {}, configuration = {})
|
22
|
+
# initialize thor parent class
|
23
|
+
super args, local_options, configuration
|
24
|
+
|
25
|
+
@workdir = Dir.getwd
|
26
|
+
|
27
|
+
inside = _docker_container_lib_check_matrjoschka
|
28
|
+
@hostname = inside ? ENV['HOSTNAME'] : _docker_container_lib_hostname
|
29
|
+
@hostlabel = "hostname=#{@hostname}"
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# mutagen check daemon
|
34
|
+
#
|
35
|
+
desc 'daemon', 'Check if mutagen host conenction is available'
|
36
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
37
|
+
Check if mutagen host conenction is available
|
38
|
+
LONGDESC
|
39
|
+
# Check if mutagen host conenction is available.
|
40
|
+
def daemon
|
41
|
+
exit mutagen_check_daemon
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage info status mutagen
|
4
|
+
module MutagenCheckDaemon
|
5
|
+
# Backend method for mutagen check daemon.
|
6
|
+
# @return [Boolean] is mutagen available?
|
7
|
+
# rubocop:disable Metrics/MethodLength
|
8
|
+
# rubocop:disable Metrics/AbcSize
|
9
|
+
def mutagen_check_daemon
|
10
|
+
log.debug 'Check mutagen status'
|
11
|
+
|
12
|
+
# are we outside of a takelage container?
|
13
|
+
unless _docker_container_lib_check_matrjoschka
|
14
|
+
unless _mutagen_check_daemon_version
|
15
|
+
log.error 'mutagen is not available'
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
|
19
|
+
log.debug 'mutagen is available'
|
20
|
+
return true
|
21
|
+
end
|
22
|
+
|
23
|
+
unless _file_exists? config.active['mutagen_socket_path']
|
24
|
+
log.error 'mutagen socket is not available'
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
|
28
|
+
unless _mutagen_check_daemon_host_connection
|
29
|
+
log.error 'mutagen host connection is not available'
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
log.debug 'mutagen is available'
|
34
|
+
true
|
35
|
+
end
|
36
|
+
# rubocop:enable Metrics/AbcSize
|
37
|
+
# rubocop:enable Metrics/MethodLength
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
# Check mutagen host connection
|
42
|
+
def _mutagen_check_daemon_host_connection
|
43
|
+
check_host_connection = format(
|
44
|
+
config.active['cmd_mutagen_check_daemon_host_connection'],
|
45
|
+
hostlabel: @hostlabel
|
46
|
+
)
|
47
|
+
host_connection = try check_host_connection
|
48
|
+
host_connection.exitstatus.zero?
|
49
|
+
end
|
50
|
+
|
51
|
+
# Check mutagen version
|
52
|
+
def _mutagen_check_daemon_version
|
53
|
+
version = try config.active['cmd_mutagen_check_daemon_version']
|
54
|
+
version.exitstatus.zero?
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Takelage
|
4
|
+
# takelage git
|
5
|
+
class Mutagen < SubCommandBase
|
6
|
+
desc 'check [COMMAND]', 'Check mutagen'
|
7
|
+
subcommand 'check', MutagenCheck
|
8
|
+
|
9
|
+
desc 'socket [COMMAND]', 'Manage mutagen socket'
|
10
|
+
subcommand 'socket', MutagenSocket
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage mutagen socket check
|
4
|
+
module MutagenSocketCheck
|
5
|
+
# Backend method for mutagen socket check.
|
6
|
+
# @return [Boolean] Does a mutagen socket exist?
|
7
|
+
def mutagen_socket_check(socket)
|
8
|
+
log.debug "Check if the mutagen socket \"#{socket}\" exists"
|
9
|
+
|
10
|
+
return false unless mutagen_check_daemon
|
11
|
+
|
12
|
+
socket_exists = _mutagen_socket_check_socket(socket)
|
13
|
+
|
14
|
+
unless socket_exists.exitstatus.zero?
|
15
|
+
log.debug "A mutagen socket \"#{socket}\" does not exist"
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
|
19
|
+
log.debug "The mutagen socket \"#{socket}\" does exist"
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Get git branch.
|
26
|
+
def _mutagen_socket_check_socket(socketname)
|
27
|
+
cmd_check_socket = format(
|
28
|
+
config.active['cmd_mutagen_forward_socket_check'],
|
29
|
+
socketname: socketname
|
30
|
+
)
|
31
|
+
try cmd_check_socket
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Takelage
|
4
|
+
# takelage mutagen socket
|
5
|
+
class MutagenSocket < SubCommandBase
|
6
|
+
include LoggingModule
|
7
|
+
include SystemModule
|
8
|
+
include ConfigModule
|
9
|
+
include DockerCheckDaemon
|
10
|
+
include DockerCheckSocat
|
11
|
+
include DockerContainerCheckExisting
|
12
|
+
include DockerContainerCheckNetwork
|
13
|
+
include DockerContainerCommand
|
14
|
+
include DockerContainerLib
|
15
|
+
include DockerSocketLib
|
16
|
+
include DockerSocketScheme
|
17
|
+
include DockerSocketStart
|
18
|
+
include DockerImageTagLatest
|
19
|
+
include DockerImageTagList
|
20
|
+
include DockerImageTagCheck
|
21
|
+
include MutagenCheckDaemon
|
22
|
+
include MutagenSocketCheck
|
23
|
+
include MutagenSocketCreate
|
24
|
+
include MutagenSocketList
|
25
|
+
include MutagenSocketTidy
|
26
|
+
include MutagenSocketTerminate
|
27
|
+
|
28
|
+
# Initialize mutagen socket
|
29
|
+
def initialize(args = [], local_options = {}, configuration = {})
|
30
|
+
# initialize thor parent class
|
31
|
+
super args, local_options, configuration
|
32
|
+
|
33
|
+
@docker_repo = config.active['docker_repo']
|
34
|
+
@username = ENV['USER'] || 'noname'
|
35
|
+
@workdir = Dir.getwd
|
36
|
+
|
37
|
+
inside = _docker_container_lib_check_matrjoschka
|
38
|
+
@hostname = inside ? ENV['HOSTNAME'] : _docker_container_lib_hostname
|
39
|
+
# See DockerContainerLib::_docker_container_lib_hostname
|
40
|
+
@socketname = @hostname[-11..-1]
|
41
|
+
|
42
|
+
@hostlabel = "hostname=#{@hostname}"
|
43
|
+
@takellabel = config.active['mutagen_socket_takelage_label']
|
44
|
+
|
45
|
+
@sockets = docker_socket_scheme
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# mutagen socket check
|
50
|
+
#
|
51
|
+
desc 'check [SOCKET]', 'Check if mutagen [SOCKET] exists'
|
52
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
53
|
+
Check if mutagen [SOCKET] exists
|
54
|
+
LONGDESC
|
55
|
+
# Check if mutagen [SOCKET] exists.
|
56
|
+
def check(socket)
|
57
|
+
exit mutagen_socket_check socket
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# mutagen socket create
|
62
|
+
#
|
63
|
+
desc 'create [IN] [OUT]', 'Create a mutagen socket from [IN] to [OUT] of the container'
|
64
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
65
|
+
Create a mutagen socket from [IN] to [OUT] of the container
|
66
|
+
LONGDESC
|
67
|
+
# Create a mutagen socket from [IN] to [OUT] of the container.
|
68
|
+
def create(containersock, hostsock)
|
69
|
+
exit mutagen_socket_create containersock, hostsock
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# mutagen socket list
|
74
|
+
#
|
75
|
+
desc 'list', 'List mutagen sockets'
|
76
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
77
|
+
List mutagen sockets
|
78
|
+
LONGDESC
|
79
|
+
# List mutagen sockets.
|
80
|
+
def list
|
81
|
+
socket_list = mutagen_socket_list
|
82
|
+
exit false if socket_list == false
|
83
|
+
say socket_list
|
84
|
+
true
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# mutagen socket terminate
|
89
|
+
#
|
90
|
+
desc 'terminate', 'Terminate a mutagen socket'
|
91
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
92
|
+
Terminate a mutagen socket
|
93
|
+
LONGDESC
|
94
|
+
# Terminate a mutagen socket.
|
95
|
+
def terminate(socket)
|
96
|
+
exit mutagen_socket_terminate socket
|
97
|
+
end
|
98
|
+
|
99
|
+
#
|
100
|
+
# mutagen socket tidy
|
101
|
+
#
|
102
|
+
desc 'tidy', 'Remove mutagen daemon files'
|
103
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
104
|
+
Remove mutagen daemon files
|
105
|
+
LONGDESC
|
106
|
+
# Remove mutagen daemon files.
|
107
|
+
def tidy
|
108
|
+
exit mutagen_socket_tidy
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage mutagen socket create
|
4
|
+
module MutagenSocketCreate
|
5
|
+
# Backend method for mutagen socket create.
|
6
|
+
def mutagen_socket_create(containersock, hostsock)
|
7
|
+
log.debug "Create the mutagen socket \"#{@socketname}\" in the container" \
|
8
|
+
"at \"#{containersock}\" pointing to the host at \"#{hostsock}\""
|
9
|
+
|
10
|
+
return false unless mutagen_check_daemon
|
11
|
+
|
12
|
+
socket_created = _mutagen_socket_create_socket(containersock, hostsock)
|
13
|
+
|
14
|
+
unless socket_created.include? 'Created session'
|
15
|
+
log.debug "Unable to create mutagen socket \"#{@socketname}\""
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
|
19
|
+
log.debug "Created the mutagen socket \"#{@socketname}\""
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Get git branch.
|
26
|
+
# rubocop:disable Metrics/MethodLength
|
27
|
+
def _mutagen_socket_create_socket(containersock, hostsock)
|
28
|
+
cmd_create_socket = format(
|
29
|
+
config.active['cmd_mutagen_forward_socket_create'],
|
30
|
+
socketname: @socketname,
|
31
|
+
containersock: containersock,
|
32
|
+
hostsock: hostsock,
|
33
|
+
username: @username,
|
34
|
+
container: @hostname,
|
35
|
+
hostlabel: @hostlabel,
|
36
|
+
takellabel: @takellabel
|
37
|
+
)
|
38
|
+
run cmd_create_socket
|
39
|
+
end
|
40
|
+
# rubocop:enable Metrics/MethodLength
|
41
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage mutagen socket list
|
4
|
+
module MutagenSocketList
|
5
|
+
# Backend method for mutagen socket list.
|
6
|
+
# @return [String] List of takelage sockets
|
7
|
+
def mutagen_socket_list
|
8
|
+
log.debug 'List the mutagen takelage sockets'
|
9
|
+
|
10
|
+
return false unless mutagen_check_daemon
|
11
|
+
|
12
|
+
sockets = _mutagen_socket_list
|
13
|
+
|
14
|
+
if sockets.to_s.empty?
|
15
|
+
log.debug 'No mutagen takelage sockets found'
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
|
19
|
+
log.debug "Found mutagen takelage sockets: \n\"\"\"\n#{sockets}\"\"\""
|
20
|
+
sockets.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
# Get git branch.
|
26
|
+
def _mutagen_socket_list
|
27
|
+
cmd_list_socket = format(
|
28
|
+
config.active['cmd_mutagen_forward_socket_list'],
|
29
|
+
takellabel: @takellabel
|
30
|
+
)
|
31
|
+
run cmd_list_socket
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage mutagen socket terminate
|
4
|
+
module MutagenSocketTerminate
|
5
|
+
# Backend method for mutagen socket terminate.
|
6
|
+
def mutagen_socket_terminate(socket)
|
7
|
+
log.debug "Terminate the mutagen socket \"#{socket}\""
|
8
|
+
|
9
|
+
return false unless mutagen_check_daemon
|
10
|
+
|
11
|
+
socket_terminated = _mutagen_socket_terminate_socket socket
|
12
|
+
|
13
|
+
unless socket_terminated.exitstatus.zero?
|
14
|
+
log.debug "Unable to terminated mutagen socket \"#{socket}\""
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
|
18
|
+
log.debug "Terminated the mutagen socket \"#{socket}\""
|
19
|
+
true
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
# Get git branch.
|
25
|
+
def _mutagen_socket_terminate_socket(socketname)
|
26
|
+
cmd_terminate_socket = format(
|
27
|
+
config.active['cmd_mutagen_forward_socket_terminate'],
|
28
|
+
socketname: socketname
|
29
|
+
)
|
30
|
+
try cmd_terminate_socket
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# takelage mutagen socket tidy
|
4
|
+
module MutagenSocketTidy
|
5
|
+
# Backend method for mutagen socket tidy.
|
6
|
+
def mutagen_socket_tidy
|
7
|
+
log.debug "Remove the mutagen daemon files in container \"#{@hostname}\""
|
8
|
+
|
9
|
+
container_existing = docker_container_check_existing @hostname
|
10
|
+
cmd_remove = config.active['cmd_mutagen_forward_socket_remove']
|
11
|
+
return false unless container_existing && cmd_remove.empty?
|
12
|
+
|
13
|
+
unless docker_container_command cmd_remove
|
14
|
+
log.error "Unable to remove the mutagen daemon files in container \"#{@hostname}\""
|
15
|
+
return false
|
16
|
+
end
|
17
|
+
|
18
|
+
log.debug "Removed the mutagen daemon files in container \"#{@hostname}\""
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
data/lib/takelage/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.28.14
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: takelage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.28.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geospin
|
@@ -271,6 +271,15 @@ files:
|
|
271
271
|
- lib/takelage/lib/project.rb
|
272
272
|
- lib/takelage/lib/subcmd.rb
|
273
273
|
- lib/takelage/lib/system.rb
|
274
|
+
- lib/takelage/mutagen/check/cli.rb
|
275
|
+
- lib/takelage/mutagen/check/daemon.rb
|
276
|
+
- lib/takelage/mutagen/cli.rb
|
277
|
+
- lib/takelage/mutagen/socket/check.rb
|
278
|
+
- lib/takelage/mutagen/socket/cli.rb
|
279
|
+
- lib/takelage/mutagen/socket/create.rb
|
280
|
+
- lib/takelage/mutagen/socket/list.rb
|
281
|
+
- lib/takelage/mutagen/socket/terminate.rb
|
282
|
+
- lib/takelage/mutagen/socket/tidy.rb
|
274
283
|
- lib/takelage/self/cli.rb
|
275
284
|
- lib/takelage/self/config/cli.rb
|
276
285
|
- lib/takelage/self/list.rb
|