takelage 0.26.3 → 0.28.5

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +38 -21
  3. data/lib/takelage.rb +13 -4
  4. data/lib/takelage/bit/check/workspace.rb +1 -1
  5. data/lib/takelage/bit/scope/cli.rb +1 -1
  6. data/lib/takelage/default.yml +7 -2
  7. data/lib/takelage/docker/container/check/existing.rb +1 -1
  8. data/lib/takelage/docker/container/check/network.rb +1 -1
  9. data/lib/takelage/docker/container/clean.rb +1 -0
  10. data/lib/takelage/docker/container/cli.rb +6 -0
  11. data/lib/takelage/docker/container/command.rb +2 -0
  12. data/lib/takelage/docker/container/daemon.rb +5 -1
  13. data/lib/takelage/docker/container/lib.rb +6 -2
  14. data/lib/takelage/docker/container/login.rb +3 -0
  15. data/lib/takelage/docker/container/prune.rb +1 -0
  16. data/lib/takelage/docker/image/tag/check.rb +2 -2
  17. data/lib/takelage/docker/socket/stop.rb +1 -1
  18. data/lib/takelage/git/check/main.rb +1 -1
  19. data/lib/takelage/git/check/workspace.rb +9 -7
  20. data/lib/takelage/info/status/bar.rb +106 -0
  21. data/lib/takelage/info/status/cli.rb +14 -13
  22. data/lib/takelage/info/status/git.rb +8 -3
  23. data/lib/takelage/info/status/gopass.rb +3 -3
  24. data/lib/takelage/info/status/lib.rb +1 -1
  25. data/lib/takelage/info/status/ssh.rb +5 -4
  26. data/lib/takelage/lib/system.rb +2 -1
  27. data/lib/takelage/mutagen/cli.rb +9 -0
  28. data/lib/takelage/mutagen/socket/check.rb +31 -0
  29. data/lib/takelage/mutagen/socket/cli.rb +89 -0
  30. data/lib/takelage/mutagen/socket/create.rb +40 -0
  31. data/lib/takelage/mutagen/socket/list.rb +31 -0
  32. data/lib/takelage/mutagen/socket/terminate.rb +33 -0
  33. data/lib/takelage/version +1 -1
  34. metadata +8 -2
  35. data/lib/takelage/info/status/header.rb +0 -106
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91da9d18bb559bbf8a1c4723d095b2b37503b76ffee8f57a7fb650976d849278
4
- data.tar.gz: 0d3b8f683ee86ebd485bf9dc9af053a8a094f03c515e12477f3ab95e201ae5b1
3
+ metadata.gz: c9cbafaa5bcc3f8d74cf010208562a6a117e2051878031c723591ab3b11ec382
4
+ data.tar.gz: '087322623aab1f24da511744d2e5f28377077593bc48e10c433ac7f8406c413b'
5
5
  SHA512:
6
- metadata.gz: a21535e16921afa69fb56a0d42b126eb6c7bd4f1bd0fba39bd60504958fb8338e22adcfa1e096805b941a1ae1bb494a7143f7d9dcc14d8550935011172faacf7
7
- data.tar.gz: 174178c3f9ee7c1157d1079ee14aac647cb20b2291fcc1fb80132b398e329f68d380a678d5a6282215d15e5de72e67427b0fb8232b4390aab3ad5218b74bed35
6
+ metadata.gz: 5998e3c792f0173950380450329100d039802219b48d7b1d88f07985a3df6f3510f30943a7becbd78a966837a93a0927ae30cc8e32b940e785952b10094e7708
7
+ data.tar.gz: 8ec3aa7a7fb9737915ee4cbbeb541483aa2cb97871423f415df66213675fc86d7ba24c45bc53d4b666360397e5265f48a896bb9506aa127ab9470e4f98fb8af5
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- ![takelage image](https://github.com/geospin-takelage/takelage-cli/actions/workflows/test_project_nightly.yml/badge.svg)
1
+ [![license](https://img.shields.io/github/license/geospin-takelage/takelage-cli?color=blueviolet)](https://github.com/geospin-takelage/takelage-cli/blob/main/LICENSE)
2
+ [![rubygems.org](https://img.shields.io/gem/v/takelage?label=rubygems.org&color=blue)](https://rubygems.org/gems/takelage)
3
+ [![deploy project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-cli/Build,%20test%20and%20deploy%20project?label=deploy%20project)](https://github.com/geospin-takelage/takelage-cli/actions/workflows/build_test_deploy_project_on_push.yml)
4
+ [![test project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-cli/Test%20project?label=test%20project)](https://github.com/geospin-takelage/takelage-cli/actions/workflows/test_project_nightly.yml)
2
5
 
3
6
  # takelage-cli
4
7
 
@@ -12,17 +15,30 @@ The *takelage-cli* executable *tau* is a
12
15
  command line script using the
13
16
  [thor](http://whatisthor.com/) toolkit.
14
17
 
15
- ## Framework
16
-
17
- The takelage devops framework consists of these projects:
18
-
19
- | App | Description |
20
- | --- | ----------- |
21
- | *[takelage-doc](https://github.com/geospin-takelage/takelage-doc)* | takelage documentation |
22
- | *[takelage-dev](https://github.com/geospin-takelage/takelage-dev)* | takelage development environment |
23
- | *[takelage-var](https://github.com/geospin-takelage/takelage-var)* | takelage test plugin |
24
- | *[takelage-cli](https://github.com/geospin-takelage/takelage-cli)* | takelage command line interface |
25
- | *[takelage-bit](https://github.com/geospin-takelage/takelage-bit)* | takelage bit server |
18
+ ## Framework Versions
19
+
20
+ | App | Artifact |
21
+ | --- | -------- |
22
+ | *[takelage-doc](https://github.com/geospin-takelage/takelage-doc)* | [![License](https://img.shields.io/github/license/geospin-takelage/takelage-doc?color=blueviolet)](https://github.com/geospin-takelage/takelage-doc/blob/main/LICENSE) |
23
+ | *[takelage-dev](https://github.com/geospin-takelage/takelage-dev)* | [![hub.docker.com](https://img.shields.io/docker/v/takelage/takelage/latest?label=hub.docker.com&sort=semver&color=blue)](https://hub.docker.com/r/takelage/takelage) |
24
+ | *[takelage-cli](https://github.com/geospin-takelage/takelage-cli)* | [![rubygems.org](https://img.shields.io/gem/v/takelage?label=rubygems.org&color=blue)](https://rubygems.org/gems/takelage) |
25
+ | *[takelage-var](https://github.com/geospin-takelage/takelage-var)* | [![pypi,org](https://img.shields.io/pypi/v/takeltest?label=pypi.org&color=blue)](https://pypi.org/project/takeltest/) |
26
+ | *[takelage-bit](https://github.com/geospin-takelage/takelage-bit)* | [![hub.docker.com](https://img.shields.io/docker/v/takelage/bitboard/latest?label=hub.docker.com&sort=semver&color=blue)](https://hub.docker.com/r/takelage/bitboard) |
27
+ | *[takelage-img-takelslim](https://github.com/geospin-takelage/takelage-img-takelslim)* | [![hub.docker.com](https://img.shields.io/docker/v/takelage/takelslim/latest?label=hub.docker.com&color=blue)](https://hub.docker.com/r/takelage/takelslim) |
28
+ | *[takelage-img-takelbase](https://github.com/geospin-takelage/takelage-img-takelbase)* | [![hub.docker.com](https://img.shields.io/docker/v/takelage/takelbase/latest?label=hub.docker.com&color=blue)](https://hub.docker.com/r/takelage/takelbase) |
29
+ | *[takelage-img-multipostgres](https://github.com/geospin-takelage/takelage-img-multipostgres)* | [![hub.docker.com](https://img.shields.io/docker/v/takelage/multipostgres/latest?label=hub.docker.com&color=blue)](https://hub.docker.com/r/takelage/multipostgres) |
30
+
31
+ ## Framework Status
32
+
33
+ | App | Deploy project | Test project | Test roles |
34
+ | --- | -------------- | ------------ | ---------- |
35
+ | *[takelage-dev](https://github.com/geospin-takelage/takelage-dev)* | [![deploy project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-dev/Build,%20test%20and%20deploy%20project?label=deploy%20project)](https://github.com/geospin-takelage/takelage-dev/actions/workflows/build_test_deploy_project_on_push.yml) | [![test project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-dev/Build%20and%20test%20project?label=test%20project)](https://github.com/geospin-takelage/takelage-dev/actions/workflows/build_test_project_nightly.yml) | [![test roles](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-dev/Test%20roles?label=test%20roles)](https://github.com/geospin-takelage/takelage-dev/actions/workflows/build_test_roles_nightly.yml) |
36
+ | *[takelage-cli](https://github.com/geospin-takelage/takelage-cli)* | [![deploy project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-cli/Build,%20test%20and%20deploy%20project?label=deploy%20project)](https://github.com/geospin-takelage/takelage-cli/actions/workflows/build_test_deploy_project_on_push.yml) | [![test project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-cli/Test%20project?label=test%20project)](https://github.com/geospin-takelage/takelage-cli/actions/workflows/test_project_nightly.yml) |
37
+ | *[takelage-var](https://github.com/geospin-takelage/takelage-var)* | [![deploy project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-var/Build,%20test%20and%20deploy%20project?label=deploy%20project)](https://github.com/geospin-takelage/takelage-var/actions/workflows/build_test_deploy_project_on_push.yml) | [![test project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-var/Build%20and%20test%20project?label=test%20project)](https://github.com/geospin-takelage/takelage-var/actions/workflows/build_test_project_nightly.yml) |
38
+ | *[takelage-bit](https://github.com/geospin-takelage/takelage-bit)* | [![deploy project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-bit/Build,%20test%20and%20deploy%20project?label=deploy%20project)](https://github.com/geospin-takelage/takelage-bit/actions/workflows/build_test_deploy_project_on_push.yml) | [![test project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-bit/Build%20and%20test%20project?label=test%20project)](https://github.com/geospin-takelage/takelage-bit/actions/workflows/build_test_project_nightly.yml) | [![test roles](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-bit/Test%20roles?label=test%20roles)](https://github.com/geospin-takelage/takelage-bit/actions/workflows/build_test_roles_nightly.yml) |
39
+ | *[takelage-img-takelslim](https://github.com/geospin-takelage/takelage-img-takelslim)* | [![deploy project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-img-takelslim/Build%20and%20deploy%20takelslim?label=deploy%20project)](https://github.com/geospin-takelage/takelage-img-takelslim/actions/workflows/build_deploy_takelslim_nightly.yml) |
40
+ | *[takelage-img-takelbase](https://github.com/geospin-takelage/takelage-img-takelbase)* | [![deploy project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-img-takelbase/Build%20and%20deploy%20takelbase?label=deploy%20project)](https://github.com/geospin-takelage/takelage-img-takelbase/actions/workflows/build_deploy_takelbase_nightly.yml) |
41
+ | *[takelage-img-multipostgres](https://github.com/geospin-takelage/takelage-img-multipostgres)* | [![deploy project](https://img.shields.io/github/workflow/status/geospin-takelage/takelage-img-multipostgres/Build%20and%20deploy%20multipostgres?label=deploy%20project)](https://github.com/geospin-takelage/takelage-img-multipostgres/actions/workflows/build_deploy_multipostgres_nightly.yml) |
26
42
 
27
43
  ## Installation
28
44
 
@@ -86,6 +102,15 @@ tau [info project active](features/cucumber/features/info/info.project.active.fe
86
102
  tau [info project dir](features/cucumber/features/info/info.project.dir.feature) | Print project root directory
87
103
  tau [info project main](features/cucumber/features/info/info.project.main.feature) | Print main project info
88
104
  tau [info project private](features/cucumber/features/info/info.project.private.feature) | Print private project info
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 ssh](features/cucumber/features/info/info.status.ssh.feature) | Check ssh status
110
+ tau [mutagen socket check](features/cucumber/features/mutagen/mutagen.socket.check.feature) [SOCKET] | Check if mutagen [SOCKET] exists
111
+ 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
112
+ tau [mutagen socket list](features/cucumber/features/mutagen/mutagen.socket.list.feature) | List mutagen sockets
113
+ tau [mutagen socket terminate](features/cucumber/features/mutagen/mutagen.socket.terminate.feature) | Terminate a mutagen socket
89
114
  tau [self config active](features/cucumber/features/self/self.config.active.feature) | Print active takelage configuration
90
115
  tau [self config default](features/cucumber/features/self/self.config.default.feature) | Print takelage default configuration
91
116
  tau [self config home](features/cucumber/features/self/self.config.home.feature) | Print takelage home config file configuration
@@ -102,6 +127,7 @@ tau project | Alias for tau [info project active](features/cucumber/features/inf
102
127
  tau prune | Alias for tau [docker container prune](features/cucumber/features/docker/docker.container.prune.feature)
103
128
  tau pull | Alias for tau [bit clipboard pull](features/cucumber/features/bit/bit.clipboard.pull.feature)
104
129
  tau push | Alias for tau [bit clipboard push](features/cucumber/features/bit/bit.clipboard.push.feature)
130
+ tau status | Alias for tau [docker info status bar](features/cucumber/features/info/info.status.bar.feature)
105
131
  tau update | Alias for tau [docker image update](features/cucumber/features/docker/docker.image.update.feature)
106
132
  tau version | Alias for tau [self version](features/cucumber/features/self/self.version.feature)
107
133
 
@@ -138,15 +164,6 @@ bit_remote: 'ssh://bit@bit.example.com:222:/bit'
138
164
  bit_ssh: 'ssh -p 222 bit@bit.example.com'
139
165
  ```
140
166
 
141
- - By default, takelage uses bright prompt colors which are best viewed on a
142
- dark background. If you prefer a light background (or want less bright colors)
143
- you can add an option to your *~/.takelage.yml*:
144
-
145
- ```yaml
146
- ---
147
- docker_daynight: 'day'
148
- ```
149
-
150
167
  - If you want to pin a specific docker tag for one of your projects
151
168
  then create an *takelage.yml* file with:
152
169
 
data/lib/takelage.rb CHANGED
@@ -59,6 +59,8 @@ require_relative 'takelage/docker/image/tag/check'
59
59
  require_relative 'takelage/docker/image/tag/cli'
60
60
  require_relative 'takelage/docker/image/update'
61
61
  require_relative 'takelage/docker/image/cli'
62
+ require_relative 'takelage/mutagen/socket/create'
63
+ require_relative 'takelage/mutagen/socket/terminate'
62
64
  require_relative 'takelage/docker/container/check/existing'
63
65
  require_relative 'takelage/docker/container/check/network'
64
66
  require_relative 'takelage/docker/container/check/orphaned'
@@ -76,10 +78,14 @@ require_relative 'takelage/info/status/git'
76
78
  require_relative 'takelage/info/status/gopass'
77
79
  require_relative 'takelage/info/status/gpg'
78
80
  require_relative 'takelage/info/status/ssh'
79
- require_relative 'takelage/info/status/header'
81
+ require_relative 'takelage/info/status/bar'
80
82
  require_relative 'takelage/info/status/cli'
81
83
  require_relative 'takelage/info/project/cli'
82
84
  require_relative 'takelage/info/cli'
85
+ require_relative 'takelage/mutagen/socket/check'
86
+ require_relative 'takelage/mutagen/socket/list'
87
+ require_relative 'takelage/mutagen/socket/cli'
88
+ require_relative 'takelage/mutagen/cli'
83
89
  require_relative 'takelage/self/config/cli'
84
90
  require_relative 'takelage/self/list'
85
91
  require_relative 'takelage/self/cli'
@@ -143,6 +149,9 @@ module Takelage
143
149
  desc 'info [COMMAND] ', 'Get information'
144
150
  subcommand 'info', Info
145
151
 
152
+ desc 'mutagen [COMMAND] ', 'Manage mutagen'
153
+ subcommand 'mutagen', Mutagen
154
+
146
155
  desc 'self [COMMAND] ', 'Manage takelage tools'
147
156
  subcommand 'self', Self
148
157
 
@@ -210,10 +219,10 @@ module Takelage
210
219
  Takelage::BitClipboard.new.push
211
220
  end
212
221
 
213
- desc 'status', 'Alias for tau info status header'
214
- # takelage status: {takelage::InfoStatus#header}
222
+ desc 'status', 'Alias for tau info status bar'
223
+ # takelage status: {takelage::InfoStatus#bar}
215
224
  def status
216
- Takelage::InfoStatus.new.header
225
+ Takelage::InfoStatus.new.bar
217
226
  end
218
227
 
219
228
  desc 'update', 'Alias for tau docker image update'
@@ -32,6 +32,6 @@ module BitCheckWorkspace
32
32
 
33
33
  stdout_str_dir = run cmd_pwd
34
34
 
35
- stdout_str_dir.strip
35
+ stdout_str_dir.chomp
36
36
  end
37
37
  end
@@ -55,7 +55,7 @@ module Takelage
55
55
  def list
56
56
  scopes = bit_scope_list
57
57
  exit false if scopes == false
58
- say scopes unless scopes.to_s.strip.empty?
58
+ say scopes unless scopes.to_s.chomp.empty?
59
59
  true
60
60
  end
61
61
 
@@ -34,7 +34,7 @@ cmd_docker_check_socat_which_socat: 'which socat'
34
34
  cmd_docker_container_check_existing_docker_ps: 'docker ps --filter name=^%{container}$ --quiet'
35
35
  cmd_docker_container_check_network_docker_network: 'docker network ls --quiet --filter name=^%{network}$'
36
36
  cmd_docker_container_check_orphaned_docker_exec: 'docker exec --interactive %{container} ps a'
37
- cmd_docker_container_create: 'docker run --detach --env TAKELAGE_PROJECT_BASE_DIR=%{workdir} --env TZ=%{timezone} --hostname %{container} --name %{container} --network %{container} --privileged --rm --shm-size %{shmsize} --tty --volume %{dockersock}:/var/run/docker.sock --volume %{homedir}:/hostdir --volume %{workdir}:/project %{volume_dev} --workdir /project %{addhost} %{docker_run_options} %{image} %{entrypoint} --gid %{gid} --home %{homedir} --uid %{uid} --username %{username} --gpg_agent_port %{gpg_agent_port} --gpg_ssh_agent_port %{gpg_ssh_agent_port} --extra=%{extra} %{entrypoint_options}'
37
+ cmd_docker_container_create: 'docker run --detach --env TAKELAGE_PROJECT_BASE_DIR=%{workdir} --env TZ=%{timezone} --hostname %{container} --name %{container} --network %{container} --rm --shm-size %{shmsize} --tty --volume %{dockersock}:/var/run/docker.sock --volume %{homedir}:/hostdir --volume %{workdir}:/project %{volume_dev} --workdir /project %{addhost} %{docker_run_options} %{image} %{entrypoint} --gid %{gid} --home %{homedir} --uid %{uid} --username %{username} --gpg_agent_port %{gpg_agent_port} --gpg_ssh_agent_port %{gpg_ssh_agent_port} --extra=%{extra} %{entrypoint_options}'
38
38
  cmd_docker_container_create_network: 'docker network create %{network}'
39
39
  cmd_docker_container_enter_container: 'docker exec --interactive --tty %{container} %{loginpoint} --username %{username}'
40
40
  cmd_docker_container_get_container_name: 'docker ps --filter id=%{container} --format "{{.Names}}"'
@@ -56,7 +56,7 @@ cmd_git_check_clean_git_unstaged: 'git diff --exit-code'
56
56
  cmd_git_check_clean_git_uncommitted: 'git diff --cached --exit-code'
57
57
  cmd_git_check_clean_git_status: 'git status --porcelain'
58
58
  cmd_git_check_main_git_branch: 'git symbolic-ref HEAD'
59
- cmd_git_check_workspace_git_repo: 'git -C . rev-parse'
59
+ cmd_git_check_workspace_git_repo: 'git -C %{dir} rev-parse'
60
60
  cmd_git_check_workspace_pwd: 'pwd'
61
61
  cmd_info_status_lib_git_name: 'git -C %{root} config user.name'
62
62
  cmd_info_status_lib_git_email: 'git -C %{root} config user.email'
@@ -66,6 +66,11 @@ 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_forward_socket_create: 'mutagen forward create --name=%{socketname} --label=%{hostlabel} --label=%{takellabel} docker://%{username}@%{container}:unix:%{containersock} unix:%{hostsock}'
70
+ cmd_mutagen_forward_socket_check: 'mutagen forward list %{socketname}'
71
+ cmd_mutagen_forward_socket_terminate: 'mutagen forward terminate %{socketname}'
72
+ cmd_mutagen_forward_socket_remove: 'rm -f ~/.mutagen/daemon/*'
73
+ cmd_mutagen_forward_socket_list: 'mutagen forward list --label-selector="%{takellabel}"'
69
74
  docker_debug: 'ansible/roles/takel-takelage/files/takelscripts'
70
75
  docker_entrypoint_extra: '.config/gcloud'
71
76
  docker_entrypoint_options: ''
@@ -11,7 +11,7 @@ module DockerContainerCheckExisting
11
11
 
12
12
  stdout_str = run _docker_container_cmd_check_existing container
13
13
 
14
- if stdout_str.to_s.strip.empty?
14
+ if stdout_str.to_s.chomp.empty?
15
15
  log.debug "Container \"#{container}\" is not existing"
16
16
  return false
17
17
  end
@@ -11,7 +11,7 @@ module DockerContainerCheckNetwork
11
11
 
12
12
  stdout_str = run _docker_container_cmd_check_network network
13
13
 
14
- if stdout_str.to_s.strip.empty?
14
+ if stdout_str.to_s.chomp.empty?
15
15
  log.debug "Network \"#{network}\" is not existing"
16
16
  return false
17
17
  end
@@ -12,6 +12,7 @@ module DockerContainerClean
12
12
 
13
13
  networks = _docker_container_clean_kill_existing_containers
14
14
  _docker_container_lib_remove_networks networks
15
+ mutagen_socket_terminate @takellabel
15
16
  end
16
17
 
17
18
  private
@@ -24,9 +24,12 @@ module Takelage
24
24
  include DockerSocketHost
25
25
  include DockerSocketScheme
26
26
  include DockerSocketStart
27
+ include MutagenSocketCreate
28
+ include MutagenSocketTerminate
27
29
 
28
30
  # Initialize docker container
29
31
  # rubocop:disable Metrics/AbcSize
32
+ # rubocop:disable Metrics/MethodLength
30
33
  def initialize(args = [], local_options = {}, configuration = {})
31
34
  # initialize thor parent class
32
35
  super args, local_options, configuration
@@ -38,9 +41,12 @@ module Takelage
38
41
  @username = ENV['USER'] || 'noname'
39
42
  @workdir = Dir.getwd
40
43
  @hostname = _docker_container_lib_hostname
44
+ @hostlabel = "hostname=#{@hostname}"
45
+ @takellabel = 'type=takelage-socket'
41
46
  @socket_host = docker_socket_host
42
47
  @sockets = docker_socket_scheme
43
48
  end
49
+ # rubocop:enable Metrics/MethodLength
44
50
  # rubocop:enable Metrics/AbcSize
45
51
 
46
52
  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 '~/.mutagen/daemon/daemon.sock', '~/.mutagen/daemon/daemon.sock'
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 '~/.mutagen/daemon/daemon.sock', '~/.mutagen/daemon/daemon.sock'
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
- return false if _docker_container_lib_check_matrjoschka
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.error 'You cannot log in to takelage from within takelage'
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 '~/.mutagen/daemon/daemon.sock', '~/.mutagen/daemon/daemon.sock'
16
+
14
17
  run_and_exit _docker_container_login_enter_container @hostname
15
18
  end
16
19
 
@@ -23,6 +23,7 @@ module DockerContainerPrune
23
23
 
24
24
  name = _docker_container_lib_get_container_name_by_id container
25
25
  _docker_container_lib_stop_container container
26
+ mutagen_socket_terminate "hostname=#{container}"
26
27
  networks << name unless networks.include? name
27
28
  end
28
29
  networks
@@ -9,7 +9,7 @@ module DockerImageTagCheck
9
9
 
10
10
  return false unless docker_check_daemon
11
11
 
12
- if tag.to_s.strip.empty?
12
+ if tag.to_s.chomp.empty?
13
13
  log.warn 'No docker image tag specified'
14
14
  return false
15
15
  end
@@ -32,7 +32,7 @@ module DockerImageTagCheck
32
32
  image: image
33
33
  )
34
34
 
35
- if (run cmd_docker_images).to_s.strip.empty?
35
+ if (run cmd_docker_images).to_s.chomp.empty?
36
36
  log.debug "No docker image \"#{image}\" found"
37
37
  return false
38
38
  end
@@ -31,7 +31,7 @@ module DockerSocketStop
31
31
  # Stop process.
32
32
  def _docker_socket_stop_kill_process(process, cmds_start_socket)
33
33
  # split processes in process id and process command
34
- pid_command = process.strip.split(/ /, 2)
34
+ pid_command = process.chomp.split(/ /, 2)
35
35
  pid = pid_command[0]
36
36
  command = pid_command[1]
37
37
 
@@ -21,6 +21,6 @@ module GitCheckMain
21
21
  def _git_check_main_get_branch
22
22
  cmd_get_branch =
23
23
  config.active['cmd_git_check_main_git_branch']
24
- (run cmd_get_branch).strip.split('/')[-1]
24
+ (run cmd_get_branch).chomp.split('/')[-1]
25
25
  end
26
26
  end
@@ -4,10 +4,9 @@
4
4
  module GitCheckWorkspace
5
5
  # Backend method for git check workspace.
6
6
  # @return [Boolean] is this a git workspace?
7
- def git_check_workspace
8
- log.debug 'Check if this is a git workspace'
9
- status_repo = _git_check_workspace_get_status_repo
10
- dir = _git_check_workspace_get_dir
7
+ def git_check_workspace(dir = _git_check_workspace_get_dir)
8
+ log.debug "Check if \"#{dir}\" is a git workspace"
9
+ status_repo = _git_check_workspace_get_status_repo(dir)
11
10
  unless status_repo.exitstatus.zero?
12
11
  log.debug "No git workspace found in \"#{dir}\""
13
12
  return false
@@ -18,8 +17,11 @@ module GitCheckWorkspace
18
17
  private
19
18
 
20
19
  # Get git repository status.
21
- def _git_check_workspace_get_status_repo
22
- cmd_git_repo = config.active['cmd_git_check_workspace_git_repo']
20
+ def _git_check_workspace_get_status_repo(dir)
21
+ cmd_git_repo = format(
22
+ config.active['cmd_git_check_workspace_git_repo'],
23
+ dir: dir
24
+ )
23
25
  try cmd_git_repo
24
26
  end
25
27
 
@@ -27,6 +29,6 @@ module GitCheckWorkspace
27
29
  def _git_check_workspace_get_dir
28
30
  cmd_pwd =
29
31
  config.active['cmd_git_check_workspace_pwd']
30
- (run cmd_pwd).strip
32
+ (run cmd_pwd).chomp
31
33
  end
32
34
  end
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage info status bar
4
+ module InfoStatusBar
5
+ # Backend method for info status bar.
6
+ # @return [String] status info bar
7
+ # rubocop:disable Metrics/MethodLength
8
+ def info_status_bar
9
+ log.debug 'Get status info bar'
10
+
11
+ @bar_list = []
12
+
13
+ _info_status_bar_takelage
14
+ _info_status_bar_tau
15
+ _info_status_bar_git
16
+ _info_status_bar_gopass
17
+ _info_status_bar_gpg
18
+ _info_status_bar_ssh
19
+
20
+ bar = @bar_list.join(' | ')
21
+ log.debug "status info bar: #{bar}"
22
+ bar
23
+ end
24
+ # rubocop:enable Metrics/MethodLength
25
+
26
+ private
27
+
28
+ # Add takelage version info to bar
29
+ def _info_status_bar_takelage
30
+ takelage_version_file = '/etc/takelage_version'
31
+ return unless _file_exists? takelage_version_file
32
+
33
+ _file_read takelage_version_file
34
+ @bar_list << "takelage: #{@content_file.chomp.green}"
35
+ end
36
+
37
+ # Add tau version info to bar
38
+ def _info_status_bar_tau
39
+ @bar_list << "tau: #{Takelage::VERSION.green}"
40
+ end
41
+
42
+ # Add git status info to bar
43
+ def _info_status_bar_git
44
+ @status_git = info_status_git
45
+ @bar_list << ("git: #{@status_git ? 'ok'.green : 'no'.red}")
46
+ end
47
+
48
+ # Add gopass status info to bar
49
+ def _info_status_bar_gopass
50
+ @status_gopass = info_status_gopass
51
+ @bar_list << ("gopass: #{@status_gopass ? 'ok'.green : 'no'.red}")
52
+ end
53
+
54
+ # Add gpg status info to bar
55
+ def _info_status_bar_gpg
56
+ if @status_git || @status_gopass
57
+ @bar_list << "gpg: #{'ok'.green}"
58
+ return
59
+ end
60
+
61
+ @bar_list << ("gpg: #{info_status_gpg ? 'ok'.green : 'no'.red}")
62
+ end
63
+
64
+ # Add ssh status info to bar
65
+ def _info_status_bar_ssh
66
+ @bar_list << ("ssh: #{info_status_ssh ? 'ok'.green : 'no'.red}")
67
+ end
68
+ end
69
+
70
+ # Amend String class with colorization
71
+ class String
72
+ # Colorize strings
73
+ def colorize(color_code)
74
+ "\e[#{color_code}m#{self}\e[0m"
75
+ end
76
+
77
+ # String color red
78
+ def red
79
+ colorize(31)
80
+ end
81
+
82
+ # String color green
83
+ def green
84
+ colorize(32)
85
+ end
86
+
87
+ # String color yellow
88
+ def yellow
89
+ colorize(33)
90
+ end
91
+
92
+ # String color blue
93
+ def blue
94
+ colorize(34)
95
+ end
96
+
97
+ # String color pink
98
+ def pink
99
+ colorize(35)
100
+ end
101
+
102
+ # String color light_blue
103
+ def light_blue
104
+ colorize(36)
105
+ end
106
+ end
@@ -7,12 +7,25 @@ module Takelage
7
7
  include SystemModule
8
8
  include ConfigModule
9
9
  include DockerSocketScheme
10
+ include GitCheckWorkspace
10
11
  include InfoStatusLib
11
12
  include InfoStatusGit
12
13
  include InfoStatusGopass
13
14
  include InfoStatusGPG
14
15
  include InfoStatusSSH
15
- include InfoStatusHeader
16
+ include InfoStatusBar
17
+
18
+ #
19
+ # info status bar
20
+ #
21
+ desc 'bar', 'Print status info bar'
22
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
23
+ Print status info bar
24
+ LONGDESC
25
+ # Print status info bar.
26
+ def bar
27
+ say info_status_bar
28
+ end
16
29
 
17
30
  #
18
31
  # info status git
@@ -50,18 +63,6 @@ module Takelage
50
63
  exit info_status_gpg
51
64
  end
52
65
 
53
- #
54
- # info status header
55
- #
56
- desc 'header', 'Print status info header'
57
- long_desc <<-LONGDESC.gsub("\n", "\x5")
58
- Print status info header
59
- LONGDESC
60
- # Print status info header.
61
- def header
62
- say info_status_header
63
- end
64
-
65
66
  #
66
67
  # info status ssh
67
68
  #
@@ -11,18 +11,23 @@ module InfoStatusGit
11
11
 
12
12
  root = config.active['project_root_dir']
13
13
 
14
- if root.strip.empty?
14
+ if root.chomp.empty?
15
15
  log.error 'Cannot determine project root directory'
16
16
  log.info 'Is there a Rakefile in the project root directory?'
17
17
  return false
18
18
  end
19
19
 
20
- if _info_status_lib_git_name(root).strip.empty?
20
+ unless git_check_workspace(root)
21
+ log.error 'Project root directory is not a git workspace'
22
+ return false
23
+ end
24
+
25
+ if _info_status_lib_git_name(root).chomp.empty?
21
26
  log.error 'git config user.name is not available'
22
27
  return false
23
28
  end
24
29
 
25
- if _info_status_lib_git_email(root).strip.empty?
30
+ if _info_status_lib_git_email(root).chomp.empty?
26
31
  log.error 'git config user.email is not available'
27
32
  return false
28
33
  end
@@ -8,9 +8,9 @@ module InfoStatusGopass
8
8
  def info_status_gopass
9
9
  log.debug 'Check gopass status'
10
10
 
11
- root = _info_status_gopass_root_store.chomp
11
+ root = _info_status_gopass_root_store
12
12
 
13
- if root.strip.empty?
13
+ if root.chomp.empty?
14
14
  log.error 'gopass root store not found'
15
15
  return false
16
16
  end
@@ -32,6 +32,6 @@ module InfoStatusGopass
32
32
  # Get gopass root store
33
33
  def _info_status_gopass_root_store
34
34
  cmd_gopass_root_store = config.active['cmd_info_status_gopass_root_store']
35
- run cmd_gopass_root_store
35
+ (run cmd_gopass_root_store).chomp
36
36
  end
37
37
  end
@@ -31,7 +31,7 @@ module InfoStatusLib
31
31
  config.active['cmd_info_status_lib_git_signingkey'],
32
32
  root: root
33
33
  )
34
- run cmd_git_signingkey
34
+ (run cmd_git_signingkey).chomp
35
35
  end
36
36
 
37
37
  # Check if git key is available
@@ -8,14 +8,15 @@ module InfoStatusSSH
8
8
  def info_status_ssh
9
9
  log.debug 'Check ssh status'
10
10
 
11
- ssh_socket_path = _socket_get_agent_ssh_socket_path
11
+ ssh_auth_sock = ENV['SSH_AUTH_SOCK']
12
+ gpg_ssh_socket = _socket_get_agent_ssh_socket_path
12
13
 
13
- unless ENV['SSH_AUTH_SOCK'] == ssh_socket_path
14
- log.error 'gpg ssh socket is misconfigured'
14
+ unless ssh_auth_sock == gpg_ssh_socket
15
+ log.error 'ssh does not use gpg ssh socket'
15
16
  return false
16
17
  end
17
18
 
18
- unless _file_exists? ssh_socket_path
19
+ unless _file_exists? gpg_ssh_socket
19
20
  log.error 'gpg ssh socket is not available'
20
21
  return false
21
22
  end
@@ -51,8 +51,9 @@ 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 = 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}\"\"\""
56
57
  stdout_str
57
58
  end
58
59
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Takelage
4
+ # takelage git
5
+ class Mutagen < SubCommandBase
6
+ desc 'socket [COMMAND]', 'Manage mutagen socket'
7
+ subcommand 'socket', MutagenSocket
8
+ end
9
+ end
@@ -0,0 +1,31 @@
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
+ socket_exists = _mutagen_socket_check_socket(socket)
11
+
12
+ unless socket_exists.exitstatus.zero?
13
+ log.debug "A mutagen socket \"#{socket}\" does not exist"
14
+ return false
15
+ end
16
+
17
+ log.debug "The mutagen socket \"#{socket}\" does exist"
18
+ true
19
+ end
20
+
21
+ private
22
+
23
+ # Get git branch.
24
+ def _mutagen_socket_check_socket(socketname)
25
+ cmd_check_socket = format(
26
+ config.active['cmd_mutagen_forward_socket_check'],
27
+ socketname: socketname
28
+ )
29
+ try cmd_check_socket
30
+ end
31
+ end
@@ -0,0 +1,89 @@
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 MutagenSocketCheck
19
+ include MutagenSocketCreate
20
+ include MutagenSocketList
21
+ include MutagenSocketTerminate
22
+
23
+ # Initialize mtagen socket
24
+ def initialize(args = [], local_options = {}, configuration = {})
25
+ # initialize thor parent class
26
+ super args, local_options, configuration
27
+
28
+ @docker_repo = config.active['docker_repo']
29
+ @username = ENV['USER'] || 'noname'
30
+ @workdir = Dir.getwd
31
+ inside = _docker_container_lib_check_matrjoschka
32
+ @hostname = inside ? ENV['HOSTNAME'] : _docker_container_lib_hostname
33
+ @hostlabel = "hostname=#{@hostname}"
34
+ @takellabel = 'type=takelage-socket'
35
+ @sockets = docker_socket_scheme
36
+ end
37
+
38
+ #
39
+ # mutagen socket check
40
+ #
41
+ desc 'check [SOCKET]', 'Check if mutagen [SOCKET] exists'
42
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
43
+ Check if mutagen [SOCKET] exists
44
+ LONGDESC
45
+ # Check if mutagen [SOCKET] exists.
46
+ def check(socket)
47
+ exit mutagen_socket_check socket
48
+ end
49
+
50
+ #
51
+ # mutagen socket create
52
+ #
53
+ desc 'create [IN] [OUT]', 'Create a mutagen socket from [IN] to [OUT] of the container'
54
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
55
+ Create a mutagen socket from [IN] to [OUT] of the container
56
+ LONGDESC
57
+ # Create a mutagen socket from [IN] to [OUT] of the container.
58
+ def create(containersock, hostsock)
59
+ exit mutagen_socket_create containersock, hostsock
60
+ end
61
+
62
+ #
63
+ # mutagen socket list
64
+ #
65
+ desc 'list', 'List mutagen sockets'
66
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
67
+ List mutagen sockets
68
+ LONGDESC
69
+ # List mutagen sockets.
70
+ def list
71
+ socket_list = mutagen_socket_list
72
+ exit false if socket_list == false
73
+ say socket_list
74
+ true
75
+ end
76
+
77
+ #
78
+ # mutagen socket terminate
79
+ #
80
+ desc 'terminate', 'Terminate a mutagen socket'
81
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
82
+ Terminate a mutagen socket
83
+ LONGDESC
84
+ # Terminate a mutagen socket.
85
+ def terminate(socket)
86
+ exit mutagen_socket_terminate socket
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,40 @@
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
+ socketname = @hostname[-11..-1]
8
+ log.debug "Create the mutagen socket \"#{socketname}\" in the container" \
9
+ "at \"#{containersock}\" pointing to the host at \"#{hostsock}\""
10
+
11
+ socket_created = _mutagen_socket_create_socket(socketname, containersock, hostsock)
12
+
13
+ unless socket_created.include? 'Created session'
14
+ log.debug "Unable to create mutagen socket \"#{socketname}\""
15
+ return false
16
+ end
17
+
18
+ log.debug "Created the mutagen socket \"#{socketname}\""
19
+ true
20
+ end
21
+
22
+ private
23
+
24
+ # Get git branch.
25
+ # rubocop:disable Metrics/MethodLength
26
+ def _mutagen_socket_create_socket(socketname, containersock, hostsock)
27
+ cmd_create_socket = format(
28
+ config.active['cmd_mutagen_forward_socket_create'],
29
+ socketname: socketname,
30
+ containersock: containersock,
31
+ hostsock: hostsock,
32
+ username: @username,
33
+ container: @hostname,
34
+ hostlabel: @hostlabel,
35
+ takellabel: @takellabel
36
+ )
37
+ run cmd_create_socket
38
+ end
39
+ # rubocop:enable Metrics/MethodLength
40
+ end
@@ -0,0 +1,31 @@
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
+ sockets = _mutagen_socket_list
11
+
12
+ if sockets.to_s.empty?
13
+ log.debug 'No mutagen takelage sockets found'
14
+ return false
15
+ end
16
+
17
+ log.debug "Found mutagen takelage sockets: \n\"\"\"\n#{sockets}\"\"\""
18
+ sockets.to_s
19
+ end
20
+
21
+ private
22
+
23
+ # Get git branch.
24
+ def _mutagen_socket_list
25
+ cmd_list_socket = format(
26
+ config.active['cmd_mutagen_forward_socket_list'],
27
+ takellabel: @takellabel
28
+ )
29
+ run cmd_list_socket
30
+ end
31
+ end
@@ -0,0 +1,33 @@
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
+ socket_terminated = _mutagen_socket_terminate_socket socket
10
+
11
+ cmd_remove = config.active['cmd_mutagen_forward_socket_remove']
12
+ docker_container_command cmd_remove if cmd_remove && socket_terminated.exitstatus.zero?
13
+
14
+ unless socket_terminated.exitstatus.zero?
15
+ log.debug "Unable to terminated mutagen socket \"#{socket}\""
16
+ return false
17
+ end
18
+
19
+ log.debug "Terminated the mutagen socket \"#{socket}\""
20
+ true
21
+ end
22
+
23
+ private
24
+
25
+ # Get git branch.
26
+ def _mutagen_socket_terminate_socket(socketname)
27
+ cmd_terminate_socket = format(
28
+ config.active['cmd_mutagen_forward_socket_terminate'],
29
+ socketname: socketname
30
+ )
31
+ try cmd_terminate_socket
32
+ end
33
+ end
data/lib/takelage/version CHANGED
@@ -1 +1 @@
1
- 0.26.3
1
+ 0.28.5
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.26.3
4
+ version: 0.28.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geospin
@@ -259,11 +259,11 @@ files:
259
259
  - lib/takelage/git/cli.rb
260
260
  - lib/takelage/info/cli.rb
261
261
  - lib/takelage/info/project/cli.rb
262
+ - lib/takelage/info/status/bar.rb
262
263
  - lib/takelage/info/status/cli.rb
263
264
  - lib/takelage/info/status/git.rb
264
265
  - lib/takelage/info/status/gopass.rb
265
266
  - lib/takelage/info/status/gpg.rb
266
- - lib/takelage/info/status/header.rb
267
267
  - lib/takelage/info/status/lib.rb
268
268
  - lib/takelage/info/status/ssh.rb
269
269
  - lib/takelage/lib/config.rb
@@ -271,6 +271,12 @@ 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/cli.rb
275
+ - lib/takelage/mutagen/socket/check.rb
276
+ - lib/takelage/mutagen/socket/cli.rb
277
+ - lib/takelage/mutagen/socket/create.rb
278
+ - lib/takelage/mutagen/socket/list.rb
279
+ - lib/takelage/mutagen/socket/terminate.rb
274
280
  - lib/takelage/self/cli.rb
275
281
  - lib/takelage/self/config/cli.rb
276
282
  - lib/takelage/self/list.rb
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # takelage info status header
4
- module InfoStatusHeader
5
- # Backend method for info status header.
6
- # @return [String] status info header
7
- # rubocop:disable Metrics/MethodLength
8
- def info_status_header
9
- log.debug 'Get status info header'
10
-
11
- @header_list = []
12
-
13
- _info_status_header_takelage
14
- _info_status_header_tau
15
- _info_status_header_git
16
- _info_status_header_gopass
17
- _info_status_header_gpg
18
- _info_status_header_ssh
19
-
20
- header = @header_list.join(' | ')
21
- log.debug "status info header: #{header}"
22
- header
23
- end
24
- # rubocop:enable Metrics/MethodLength
25
-
26
- private
27
-
28
- # Add takelage version info to header
29
- def _info_status_header_takelage
30
- takelage_version_file = '/etc/takelage_version'
31
- return unless _file_exists? takelage_version_file
32
-
33
- _file_read takelage_version_file
34
- @header_list << "takelage: #{@content_file.chomp.green}"
35
- end
36
-
37
- # Add tau version info to header
38
- def _info_status_header_tau
39
- @header_list << "tau: #{Takelage::VERSION.green}"
40
- end
41
-
42
- # Add git status info to header
43
- def _info_status_header_git
44
- @status_git = info_status_git
45
- @header_list << ("git: #{@status_git ? 'ok'.green : 'no'.red}")
46
- end
47
-
48
- # Add gopass status info to header
49
- def _info_status_header_gopass
50
- @status_gopass = info_status_gopass
51
- @header_list << ("gopass: #{@status_gopass ? 'ok'.green : 'no'.red}")
52
- end
53
-
54
- # Add gpg status info to header
55
- def _info_status_header_gpg
56
- if @status_git || @status_gopass
57
- @header_list << "gpg: #{'ok'.green}"
58
- return
59
- end
60
-
61
- @header_list << ("gpg: #{info_status_gpg ? 'ok'.green : 'no'.red}")
62
- end
63
-
64
- # Add ssh status info to header
65
- def _info_status_header_ssh
66
- @header_list << ("ssh: #{info_status_ssh ? 'ok'.green : 'no'.red}")
67
- end
68
- end
69
-
70
- # Amend String class with colorization
71
- class String
72
- # Colorize strings
73
- def colorize(color_code)
74
- "\e[#{color_code}m#{self}\e[0m"
75
- end
76
-
77
- # String color red
78
- def red
79
- colorize(31)
80
- end
81
-
82
- # String color green
83
- def green
84
- colorize(32)
85
- end
86
-
87
- # String color yellow
88
- def yellow
89
- colorize(33)
90
- end
91
-
92
- # String color blue
93
- def blue
94
- colorize(34)
95
- end
96
-
97
- # String color pink
98
- def pink
99
- colorize(35)
100
- end
101
-
102
- # String color light_blue
103
- def light_blue
104
- colorize(36)
105
- end
106
- end