takeltau 0.36.5 → 0.38.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/takeltau/default.yml +7 -4
- data/lib/takeltau/docker/container/cli.rb +6 -3
- data/lib/takeltau/docker/container/lib.rb +3 -3
- data/lib/takeltau/git/lib.rb +24 -27
- data/lib/takeltau/hg/pull.rb +7 -24
- data/lib/takeltau/hg/push.rb +7 -17
- data/lib/takeltau/info/status/bar.rb +26 -7
- data/lib/takeltau/info/status/cli.rb +14 -1
- data/lib/takeltau/info/status/hg.rb +26 -0
- data/lib/takeltau/mutagen/check/daemon.rb +17 -9
- data/lib/takeltau/version +1 -1
- data/lib/takeltau.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e8150c32b54f9b2c4e94e2814dbe6b74327f24720ed6f2b8554dfbb39d80f49
|
4
|
+
data.tar.gz: 861e643d2b18ff92415383306a1118b68bdd4a9ab59011c5579261c58a9221b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c10d3e74ef0ed8bf7052884dee6326f0b5ae007708dc5cfc9a2213295ece10f67347154126ecdc5794d01da384e5171f3edffa35d496225ef7dbbd0cf1f093d
|
7
|
+
data.tar.gz: 9ebcb11b7bc216d638d9a14cb7b75c49379289e0653a27eda4fae5a1ae5abe8ec8212eb6bd9158a0d82111e7ccbf70d6048bc738eda5466acc27d1693b246ff9
|
data/lib/takeltau/default.yml
CHANGED
@@ -23,7 +23,6 @@ cmd_git_check_clean_git_status: 'git status --porcelain'
|
|
23
23
|
cmd_git_check_hg_get_git_branch: 'git symbolic-ref HEAD'
|
24
24
|
cmd_git_check_workspace_git_repo: 'git -C %{dir} rev-parse'
|
25
25
|
cmd_git_check_workspace_pwd: 'pwd'
|
26
|
-
cmd_git_lib_git_add_all: 'git add --all'
|
27
26
|
cmd_git_lib_git_add_hg_dirs: 'git add \*/.hg/\*'
|
28
27
|
cmd_git_lib_git_commit: 'git commit --message="%{message}"'
|
29
28
|
cmd_git_lib_git_pull_origin: 'git pull origin %{main}'
|
@@ -38,6 +37,7 @@ cmd_info_status_lib_git_key_available: 'gpg --list-key %{key}'
|
|
38
37
|
cmd_info_status_gopass_root_store: 'gopass config | grep "path" | cut -d " " -f 2'
|
39
38
|
cmd_info_status_gpg_agent: 'gpg-connect-agent /bye'
|
40
39
|
cmd_info_status_gpg_keys: 'gpg --list-keys'
|
40
|
+
cmd_info_status_hg_username: 'hg config ui.username'
|
41
41
|
cmd_info_status_ssh_keys: 'ssh-add -l'
|
42
42
|
cmd_info_status_ssh_socket: 'gpgconf --list-dirs agent-ssh-socket'
|
43
43
|
cmd_init_lib_git_init: 'git init && git checkout -b main'
|
@@ -65,7 +65,10 @@ git_hg_branch: 'main'
|
|
65
65
|
info_project_main: 'project.yml'
|
66
66
|
info_project_private: 'private/project.yml'
|
67
67
|
login_wait_for_sockets: '0'
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
mutagen_socket_path_mutagen_container: '~/.mutagen/daemon/daemon.sock'
|
69
|
+
mutagen_socket_path_mutagen_host: '~/.mutagen/daemon/daemon.sock'
|
70
|
+
mutagen_socket_path_gpg_container: '~/.gnupg/S.gpg-agent'
|
71
|
+
mutagen_socket_path_gpg_host: '~/.gnupg/S.gpg-agent'
|
72
|
+
mutagen_socket_path_ssh_container: '~/.gnupg/S.gpg-agent.ssh'
|
73
|
+
mutagen_socket_path_ssh_host: '~/.gnupg/S.gpg-agent.ssh'
|
71
74
|
mutagen_socket_takelage_label: 'type=takelage'
|
@@ -40,9 +40,12 @@ module Takeltau
|
|
40
40
|
@hostname = _docker_container_lib_hostname
|
41
41
|
@hostlabel = "hostname=#{@hostname}"
|
42
42
|
@takellabel = config.active['mutagen_socket_takelage_label']
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
43
|
+
@mutagensock_container = config.active['mutagen_socket_path_mutagen_container']
|
44
|
+
@mutagensock_host = config.active['mutagen_socket_path_mutagen_host']
|
45
|
+
@gpgsock_container = config.active['mutagen_socket_path_gpg_container']
|
46
|
+
@gpgsock_host = config.active['mutagen_socket_path_gpg_host']
|
47
|
+
@sshsock_container = config.active['mutagen_socket_path_ssh_container']
|
48
|
+
@sshsock_host = config.active['mutagen_socket_path_ssh_host']
|
46
49
|
end
|
47
50
|
# rubocop:enable Metrics/MethodLength
|
48
51
|
# rubocop:enable Metrics/AbcSize
|
@@ -10,9 +10,9 @@ module DockerContainerLib
|
|
10
10
|
def _docker_container_lib_start_sockets
|
11
11
|
return false unless mutagen_check_daemon
|
12
12
|
|
13
|
-
mutagen_socket_create 'mutagen', @
|
14
|
-
mutagen_socket_create 'gpg', @
|
15
|
-
mutagen_socket_create 'ssh', @
|
13
|
+
mutagen_socket_create 'mutagen', @mutagensock_container, @mutagensock_host
|
14
|
+
mutagen_socket_create 'gpg', @gpgsock_container, @gpgsock_host
|
15
|
+
mutagen_socket_create 'ssh', @sshsock_container, @sshsock_host
|
16
16
|
end
|
17
17
|
|
18
18
|
# Create unique docker hostname
|
data/lib/takeltau/git/lib.rb
CHANGED
@@ -2,23 +2,29 @@
|
|
2
2
|
|
3
3
|
# tau git lib
|
4
4
|
module GitLib
|
5
|
-
#
|
6
|
-
|
7
|
-
|
5
|
+
# Prepare git workspace.
|
6
|
+
# rubocop:disable Metrics/MethodLength
|
7
|
+
def git_lib_prepare_git_workspace
|
8
|
+
log.debug 'Prepare git workspace'
|
8
9
|
|
9
|
-
|
10
|
-
end
|
10
|
+
return false unless configured? %w[project_root_dir]
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
unless git_check_hg
|
13
|
+
log.error 'Not on git hg branch'
|
14
|
+
return false
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
unless git_check_clean
|
18
|
+
log.error 'No clean git workspace'
|
19
|
+
return false
|
20
|
+
end
|
19
21
|
|
20
|
-
|
22
|
+
return true if _git_lib_git_pull_origin_hg
|
23
|
+
|
24
|
+
log.error 'Unable to pull git workspace'
|
25
|
+
false
|
21
26
|
end
|
27
|
+
# rubocop:enable Metrics/MethodLength
|
22
28
|
|
23
29
|
# Push git workspace.
|
24
30
|
def git_lib_push_hg_dirs
|
@@ -29,30 +35,21 @@ module GitLib
|
|
29
35
|
return false unless _git_lib_git_add_hg_dirs
|
30
36
|
return false unless _git_lib_git_commit message
|
31
37
|
|
32
|
-
_git_lib_git_push_origin_hg
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
# git add all.
|
38
|
-
def _git_lib_git_add_all
|
39
|
-
log.debug 'Adding all files to git'
|
40
|
-
|
41
|
-
cmd_git_add_all = config.active['cmd_git_lib_git_add_all']
|
38
|
+
return true if _git_lib_git_push_origin_hg
|
42
39
|
|
43
|
-
|
44
|
-
|
45
|
-
log.error 'Unable to add all files to git'
|
40
|
+
log.error 'Unable to git push .hg mercurial directories'
|
46
41
|
false
|
47
42
|
end
|
48
43
|
|
44
|
+
private
|
45
|
+
|
49
46
|
# git add hg dirs.
|
50
47
|
def _git_lib_git_add_hg_dirs
|
51
48
|
log.debug 'Adding all .hg mercurial dirs to git'
|
52
49
|
|
53
50
|
cmd_git_add_hg_dirs = config.active['cmd_git_lib_git_add_hg_dirs']
|
54
51
|
|
55
|
-
return true if try cmd_git_add_hg_dirs
|
52
|
+
return true if (try cmd_git_add_hg_dirs).exitstatus.zero?
|
56
53
|
|
57
54
|
log.error 'Unable to add all .hg mercurial dirs to git'
|
58
55
|
false
|
@@ -67,7 +64,7 @@ module GitLib
|
|
67
64
|
message: message
|
68
65
|
)
|
69
66
|
|
70
|
-
return true if try cmd_git_commit
|
67
|
+
return true if (try cmd_git_commit).exitstatus.zero?
|
71
68
|
|
72
69
|
log.error 'Unable to commit to git'
|
73
70
|
false
|
data/lib/takeltau/hg/pull.rb
CHANGED
@@ -3,37 +3,18 @@
|
|
3
3
|
# tau hg pull
|
4
4
|
module HgPull
|
5
5
|
# Backend method for hg pull.
|
6
|
-
# rubocop:disable Metrics/AbcSize
|
7
|
-
# rubocop:disable Metrics/MethodLength
|
8
6
|
def hg_pull
|
9
7
|
log.debug 'Pull hg repos'
|
10
8
|
|
11
|
-
return false unless
|
9
|
+
return false unless git_lib_prepare_git_workspace
|
12
10
|
|
13
|
-
unless
|
14
|
-
log.error '
|
11
|
+
unless _hg_pull_hg_pull_repos
|
12
|
+
log.error 'Unable to tau hg pull'
|
15
13
|
return false
|
16
14
|
end
|
17
15
|
|
18
|
-
|
19
|
-
log.error 'No clean git workspace'
|
20
|
-
return false
|
21
|
-
end
|
22
|
-
|
23
|
-
unless git_lib_pull_workspace
|
24
|
-
log.error 'Unable to pull git workspace'
|
25
|
-
return false
|
26
|
-
end
|
27
|
-
|
28
|
-
log.info _hg_pull_hg_pull_repos
|
29
|
-
|
30
|
-
return true if git_lib_push_hg_dirs
|
31
|
-
|
32
|
-
log.error 'Unable to push .hg mercurial directories'
|
33
|
-
false
|
16
|
+
git_lib_push_hg_dirs
|
34
17
|
end
|
35
|
-
# rubocop:enable Metrics/MethodLength
|
36
|
-
# rubocop:enable Metrics/AbcSize
|
37
18
|
|
38
19
|
private
|
39
20
|
|
@@ -44,6 +25,8 @@ module HgPull
|
|
44
25
|
root: config.active['project_root_dir']
|
45
26
|
)
|
46
27
|
|
47
|
-
|
28
|
+
stdout, _, exitstatus = run_and_capture cmd_hg_pull_repos
|
29
|
+
log.info stdout
|
30
|
+
exitstatus.zero?
|
48
31
|
end
|
49
32
|
end
|
data/lib/takeltau/hg/push.rb
CHANGED
@@ -3,30 +3,18 @@
|
|
3
3
|
# tau hg push
|
4
4
|
module HgPush
|
5
5
|
# Backend method for hg push.
|
6
|
-
# rubocop:disable Metrics/MethodLength
|
7
6
|
def hg_push
|
8
7
|
log.debug 'Push hg repos'
|
9
8
|
|
10
|
-
return false unless
|
9
|
+
return false unless git_lib_prepare_git_workspace
|
11
10
|
|
12
|
-
unless
|
13
|
-
log.error '
|
11
|
+
unless _hg_push_hg_push_repos
|
12
|
+
log.error 'Unable to tau hg push'
|
14
13
|
return false
|
15
14
|
end
|
16
15
|
|
17
|
-
|
18
|
-
log.error 'No clean git workspace'
|
19
|
-
return false
|
20
|
-
end
|
21
|
-
|
22
|
-
log.info _hg_push_hg_push_repos
|
23
|
-
|
24
|
-
return true if git_lib_push_workspace 'tau hg push'
|
25
|
-
|
26
|
-
log.error 'Unable to push git workspace'
|
27
|
-
false
|
16
|
+
git_lib_push_hg_dirs
|
28
17
|
end
|
29
|
-
# rubocop:enable Metrics/MethodLength
|
30
18
|
|
31
19
|
private
|
32
20
|
|
@@ -37,6 +25,8 @@ module HgPush
|
|
37
25
|
root: config.active['project_root_dir']
|
38
26
|
)
|
39
27
|
|
40
|
-
|
28
|
+
stdout, _, exitstatus = run_and_capture cmd_hg_push_repos
|
29
|
+
log.info stdout
|
30
|
+
exitstatus.zero?
|
41
31
|
end
|
42
32
|
end
|
@@ -9,18 +9,19 @@ module InfoStatusBar
|
|
9
9
|
log.debug 'Get status info bar'
|
10
10
|
|
11
11
|
@bar_list = []
|
12
|
+
@bar_status = true
|
12
13
|
|
13
14
|
_info_status_bar_takelage
|
14
15
|
_info_status_bar_tau
|
15
16
|
_info_status_bar_git
|
16
17
|
_info_status_bar_gopass
|
17
18
|
_info_status_bar_gpg
|
19
|
+
_info_status_bar_hg
|
18
20
|
_info_status_bar_mutagen
|
19
21
|
_info_status_bar_ssh
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
bar
|
23
|
+
say @bar_list.join(' | ')
|
24
|
+
@bar_status
|
24
25
|
end
|
25
26
|
# rubocop:enable Metrics/MethodLength
|
26
27
|
|
@@ -29,7 +30,10 @@ module InfoStatusBar
|
|
29
30
|
# Add takelage version info to bar.
|
30
31
|
def _info_status_bar_takelage
|
31
32
|
takelage_version_file = '/etc/takelage_version'
|
32
|
-
|
33
|
+
unless _file_exists? takelage_version_file
|
34
|
+
@bar_status = false
|
35
|
+
return false
|
36
|
+
end
|
33
37
|
|
34
38
|
_file_read takelage_version_file
|
35
39
|
@bar_list << "#{config.active['docker_repo']}: #{@content_file.chomp.green}"
|
@@ -43,12 +47,14 @@ module InfoStatusBar
|
|
43
47
|
# Add git status info to bar.
|
44
48
|
def _info_status_bar_git
|
45
49
|
@status_git = info_status_git
|
50
|
+
@bar_status &&= @status_git
|
46
51
|
@bar_list << ("git: #{@status_git ? 'ok'.green : 'no'.red}")
|
47
52
|
end
|
48
53
|
|
49
54
|
# Add gopass status info to bar.
|
50
55
|
def _info_status_bar_gopass
|
51
56
|
@status_gopass = info_status_gopass
|
57
|
+
@bar_status &&= @status_gopass
|
52
58
|
@bar_list << ("gopass: #{@status_gopass ? 'ok'.green : 'no'.red}")
|
53
59
|
end
|
54
60
|
|
@@ -59,17 +65,30 @@ module InfoStatusBar
|
|
59
65
|
return
|
60
66
|
end
|
61
67
|
|
62
|
-
|
68
|
+
status_gpg = info_status_gpg
|
69
|
+
@bar_status &&= status_gpg
|
70
|
+
@bar_list << ("gpg: #{status_gpg ? 'ok'.green : 'no'.red}")
|
71
|
+
end
|
72
|
+
|
73
|
+
# Add git status info to bar.
|
74
|
+
def _info_status_bar_hg
|
75
|
+
@status_hg = info_status_hg
|
76
|
+
@bar_status &&= @status_hg
|
77
|
+
@bar_list << ("hg: #{@status_hg ? 'ok'.green : 'no'.red}")
|
63
78
|
end
|
64
79
|
|
65
80
|
# Add mutagen status info to bar.
|
66
81
|
def _info_status_bar_mutagen
|
67
|
-
|
82
|
+
status_mutagen = mutagen_check_daemon
|
83
|
+
@bar_status &&= status_mutagen
|
84
|
+
@bar_list << ("mutagen: #{status_mutagen ? 'ok'.green : 'no'.red}")
|
68
85
|
end
|
69
86
|
|
70
87
|
# Add ssh status info to bar.
|
71
88
|
def _info_status_bar_ssh
|
72
|
-
|
89
|
+
status_ssh = info_status_ssh
|
90
|
+
@bar_status &&= status_ssh
|
91
|
+
@bar_list << ("ssh: #{status_ssh ? 'ok'.green : 'no'.red}")
|
73
92
|
end
|
74
93
|
end
|
75
94
|
|
@@ -16,6 +16,7 @@ module Takeltau
|
|
16
16
|
include InfoStatusGit
|
17
17
|
include InfoStatusGopass
|
18
18
|
include InfoStatusGPG
|
19
|
+
include InfoStatusHg
|
19
20
|
include InfoStatusSSH
|
20
21
|
include InfoStatusBar
|
21
22
|
include MutagenCheckDaemon
|
@@ -41,7 +42,7 @@ module Takeltau
|
|
41
42
|
LONGDESC
|
42
43
|
# Print status info bar.
|
43
44
|
def bar
|
44
|
-
|
45
|
+
exit info_status_bar
|
45
46
|
end
|
46
47
|
|
47
48
|
#
|
@@ -80,6 +81,18 @@ module Takeltau
|
|
80
81
|
exit info_status_gpg
|
81
82
|
end
|
82
83
|
|
84
|
+
#
|
85
|
+
# info status hg
|
86
|
+
#
|
87
|
+
desc 'hg', 'Check hg status info'
|
88
|
+
long_desc <<-LONGDESC.gsub("\n", "\x5")
|
89
|
+
Check hg status info
|
90
|
+
LONGDESC
|
91
|
+
# Check hg status info.
|
92
|
+
def hg
|
93
|
+
exit info_status_hg
|
94
|
+
end
|
95
|
+
|
83
96
|
#
|
84
97
|
# info status mutagen
|
85
98
|
#
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# tau info status hg
|
4
|
+
module InfoStatusHg
|
5
|
+
# Backend method for info status hg.
|
6
|
+
# @return [Boolean] has mercurial been configured?
|
7
|
+
def info_status_hg
|
8
|
+
log.debug 'Check hg status'
|
9
|
+
|
10
|
+
unless _info_status_hg_username
|
11
|
+
log.error 'hg ui.username is not configured'
|
12
|
+
return false
|
13
|
+
end
|
14
|
+
|
15
|
+
log.debug 'hg config is available'
|
16
|
+
true
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# Check hg username
|
22
|
+
def _info_status_hg_username
|
23
|
+
status_username = try config.active['cmd_info_status_hg_username']
|
24
|
+
status_username.exitstatus.zero?
|
25
|
+
end
|
26
|
+
end
|
@@ -5,14 +5,13 @@ module MutagenCheckDaemon
|
|
5
5
|
# Backend method for mutagen check daemon.
|
6
6
|
# @return [Boolean] is mutagen available?
|
7
7
|
# rubocop:disable Metrics/MethodLength
|
8
|
-
# rubocop:disable Metrics/AbcSize
|
9
8
|
def mutagen_check_daemon
|
10
9
|
return true if @mutagen_daemon_available
|
11
10
|
|
12
|
-
return false unless command_available_else_warn? config.active['cmd_mutagen']
|
13
|
-
|
14
11
|
log.debug 'Check mutagen status'
|
15
12
|
|
13
|
+
return false unless _mutagen_check_check_prerequisites
|
14
|
+
|
16
15
|
# are we outside of a takelage container?
|
17
16
|
unless _docker_container_lib_check_matrjoschka
|
18
17
|
unless _mutagen_check_daemon_version
|
@@ -25,11 +24,6 @@ module MutagenCheckDaemon
|
|
25
24
|
return true
|
26
25
|
end
|
27
26
|
|
28
|
-
unless _file_exists? config.active['mutagen_socket_path_mutagen']
|
29
|
-
log.error 'The mutagen socket is not available'
|
30
|
-
return false
|
31
|
-
end
|
32
|
-
|
33
27
|
unless _mutagen_check_daemon_host_connection
|
34
28
|
log.error 'A mutagen host connection is not available'
|
35
29
|
return false
|
@@ -39,11 +33,25 @@ module MutagenCheckDaemon
|
|
39
33
|
@mutagen_daemon_available = true
|
40
34
|
true
|
41
35
|
end
|
42
|
-
# rubocop:enable Metrics/AbcSize
|
43
36
|
# rubocop:enable Metrics/MethodLength
|
44
37
|
|
45
38
|
private
|
46
39
|
|
40
|
+
# Check mutagen prerequisites
|
41
|
+
def _mutagen_check_check_prerequisites
|
42
|
+
unless _file_exists? config.active['mutagen_socket_path_mutagen_container']
|
43
|
+
log.error 'The mutagen socket path in the container is not available'
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
|
47
|
+
unless _file_exists? config.active['mutagen_socket_path_mutagen_host']
|
48
|
+
log.error 'The mutagen socket path on the host is not available'
|
49
|
+
return false
|
50
|
+
end
|
51
|
+
|
52
|
+
command_available_else_error? config.active['cmd_mutagen']
|
53
|
+
end
|
54
|
+
|
47
55
|
# Check mutagen host connection
|
48
56
|
# rubocop:disable Metrics/MethodLength
|
49
57
|
def _mutagen_check_daemon_host_connection
|
data/lib/takeltau/version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.38.1
|
data/lib/takeltau.rb
CHANGED
@@ -70,6 +70,7 @@ require_relative 'takeltau/info/status/lib'
|
|
70
70
|
require_relative 'takeltau/info/status/git'
|
71
71
|
require_relative 'takeltau/info/status/gopass'
|
72
72
|
require_relative 'takeltau/info/status/gpg'
|
73
|
+
require_relative 'takeltau/info/status/hg'
|
73
74
|
require_relative 'takeltau/info/status/ssh'
|
74
75
|
require_relative 'takeltau/info/status/bar'
|
75
76
|
require_relative 'takeltau/info/status/cli'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: takeltau
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.38.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takelwerk
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- lib/takeltau/info/status/git.rb
|
245
245
|
- lib/takeltau/info/status/gopass.rb
|
246
246
|
- lib/takeltau/info/status/gpg.rb
|
247
|
+
- lib/takeltau/info/status/hg.rb
|
247
248
|
- lib/takeltau/info/status/lib.rb
|
248
249
|
- lib/takeltau/info/status/ssh.rb
|
249
250
|
- lib/takeltau/init/cli.rb
|