takelage 0.26.7 → 0.28.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c85358aee84b4ad7e8e67c54f106705fa7a81738b800e060472ec27989ea8a33
4
- data.tar.gz: 1712ed57e584a5a9c6eb3cb30583f9c908abbd9a42a462aa770720a91b0be819
3
+ metadata.gz: 1d001b2320ee31a8a1418fa2148f2b57e188161a77462d743664ba65fee9f9c9
4
+ data.tar.gz: 1029b8f87e5a2ca62dabb569393b9882728555c36a3a474a8c4d8a07284aab00
5
5
  SHA512:
6
- metadata.gz: 1724194bc930b8d23c5e5e6395dbc493dde90440752bb3ea0a39539bd705876943b82d12524d8f23b9f682e56a3c0b7b18948d4d8efb6d827b8ec361148c9572
7
- data.tar.gz: 617b075ad7581e80d3f3ec30c704d24333658d7daa94b893943f98315aeabfbef207cdbe02abf8ea3b0b281a65b4baa03ad89b29036d59e86873bbbd047a5a3b
6
+ metadata.gz: 9edf2460fba247d5cca26952aba78c223c86b13a796dfc88e2cf586e910e3d2b451ac920d5ea1f597d1ba282b1a65c90e19d89e5e2bb2ded707916db908b4368
7
+ data.tar.gz: e6678614002f51c2e712aaa0a9a4578fb6ace913de6d6c0561728a21ae53f048140ef9bbe58439c1da9791b1a86f73bfaa957fe39ce45ff875f37d5f0c1b8df6
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,11 +102,17 @@ 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
89
- tau [info status git](features/cucumber/features/info/info.status.git.feature) | Check git status info
90
- tau [info status gopass](features/cucumber/features/info/info.status.gopass.feature) | Check gopass status info
91
- tau [info status gpg](features/cucumber/features/info/info.status.gpg.feature) | Check gpg status info
92
- tau [info status header](features/cucumber/features/info/info.status.header.feature) | Print status info header
93
- tau [info status ssh](features/cucumber/features/info/info.status.ssh.feature) | Check ssh status 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 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 terminate](features/cucumber/features/mutagen/mutagen.socket.terminate.feature) | Terminate a mutagen socket
94
116
  tau [self config active](features/cucumber/features/self/self.config.active.feature) | Print active takelage configuration
95
117
  tau [self config default](features/cucumber/features/self/self.config.default.feature) | Print takelage default configuration
96
118
  tau [self config home](features/cucumber/features/self/self.config.home.feature) | Print takelage home config file configuration
@@ -107,7 +129,7 @@ tau project | Alias for tau [info project active](features/cucumber/features/inf
107
129
  tau prune | Alias for tau [docker container prune](features/cucumber/features/docker/docker.container.prune.feature)
108
130
  tau pull | Alias for tau [bit clipboard pull](features/cucumber/features/bit/bit.clipboard.pull.feature)
109
131
  tau push | Alias for tau [bit clipboard push](features/cucumber/features/bit/bit.clipboard.push.feature)
110
- tau status | Alias for tau [docker info status header](features/cucumber/features/info/info.status.header.feature)
132
+ tau status | Alias for tau [docker info status bar](features/cucumber/features/info/info.status.bar.feature)
111
133
  tau update | Alias for tau [docker image update](features/cucumber/features/docker/docker.image.update.feature)
112
134
  tau version | Alias for tau [self version](features/cucumber/features/self/self.version.feature)
113
135
 
@@ -144,15 +166,6 @@ bit_remote: 'ssh://bit@bit.example.com:222:/bit'
144
166
  bit_ssh: 'ssh -p 222 bit@bit.example.com'
145
167
  ```
146
168
 
147
- - By default, takelage uses bright prompt colors which are best viewed on a
148
- dark background. If you prefer a light background (or want less bright colors)
149
- you can add an option to your *~/.takelage.yml*:
150
-
151
- ```yaml
152
- ---
153
- docker_daynight: 'day'
154
- ```
155
-
156
169
  - If you want to pin a specific docker tag for one of your projects
157
170
  then create an *takelage.yml* file with:
158
171
 
data/lib/takelage.rb CHANGED
@@ -44,6 +44,8 @@ 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/socket/create'
48
+ require_relative 'takelage/mutagen/socket/terminate'
47
49
  require_relative 'takelage/docker/check/daemon'
48
50
  require_relative 'takelage/docker/check/socat'
49
51
  require_relative 'takelage/docker/check/cli'
@@ -71,12 +73,18 @@ require_relative 'takelage/docker/container/clean'
71
73
  require_relative 'takelage/docker/container/prune'
72
74
  require_relative 'takelage/docker/container/cli'
73
75
  require_relative 'takelage/docker/cli'
76
+ require_relative 'takelage/mutagen/check/daemon'
77
+ require_relative 'takelage/mutagen/check/cli'
78
+ require_relative 'takelage/mutagen/socket/check'
79
+ require_relative 'takelage/mutagen/socket/list'
80
+ require_relative 'takelage/mutagen/socket/cli'
81
+ require_relative 'takelage/mutagen/cli'
74
82
  require_relative 'takelage/info/status/lib'
75
83
  require_relative 'takelage/info/status/git'
76
84
  require_relative 'takelage/info/status/gopass'
77
85
  require_relative 'takelage/info/status/gpg'
78
86
  require_relative 'takelage/info/status/ssh'
79
- require_relative 'takelage/info/status/header'
87
+ require_relative 'takelage/info/status/bar'
80
88
  require_relative 'takelage/info/status/cli'
81
89
  require_relative 'takelage/info/project/cli'
82
90
  require_relative 'takelage/info/cli'
@@ -143,6 +151,9 @@ module Takelage
143
151
  desc 'info [COMMAND] ', 'Get information'
144
152
  subcommand 'info', Info
145
153
 
154
+ desc 'mutagen [COMMAND] ', 'Manage mutagen'
155
+ subcommand 'mutagen', Mutagen
156
+
146
157
  desc 'self [COMMAND] ', 'Manage takelage tools'
147
158
  subcommand 'self', Self
148
159
 
@@ -210,10 +221,10 @@ module Takelage
210
221
  Takelage::BitClipboard.new.push
211
222
  end
212
223
 
213
- desc 'status', 'Alias for tau info status header'
214
- # takelage status: {takelage::InfoStatus#header}
224
+ desc 'status', 'Alias for tau info status bar'
225
+ # takelage status: {takelage::InfoStatus#bar}
215
226
  def status
216
- Takelage::InfoStatus.new.header
227
+ Takelage::InfoStatus.new.bar
217
228
  end
218
229
 
219
230
  desc 'update', 'Alias for tau docker image update'
@@ -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}}"'
@@ -66,6 +66,12 @@ 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_forward_socket_create: 'mutagen forward create --name=%{socketname} --label=%{hostlabel} --label=%{takellabel} docker://%{username}@%{container}:unix:%{containersock} unix:%{hostsock}'
71
+ cmd_mutagen_forward_socket_check: 'mutagen forward list %{socketname}'
72
+ cmd_mutagen_forward_socket_terminate: 'mutagen forward terminate %{socketname}'
73
+ cmd_mutagen_forward_socket_remove: 'rm -f ~/.mutagen/daemon/*'
74
+ cmd_mutagen_forward_socket_list: 'mutagen forward list --label-selector="%{takellabel}"'
69
75
  docker_debug: 'ansible/roles/takel-takelage/files/takelscripts'
70
76
  docker_entrypoint_extra: '.config/gcloud'
71
77
  docker_entrypoint_options: ''
@@ -80,3 +86,5 @@ docker_user: 'takelage'
80
86
  git_main_branch: 'main'
81
87
  info_project_main: 'project.yml'
82
88
  info_project_private: 'private/project.yml'
89
+ mutagen_socket_path: '~/.mutagen/daemon/daemon.sock'
90
+ mutagen_socket_takelage_label: 'type=takelage-socket'
@@ -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 "--label-selector='#{@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,13 @@ 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 = config.active['mutagen_socket_takelage_label']
41
46
  @socket_host = docker_socket_host
42
47
  @sockets = docker_socket_scheme
48
+ @mutagensock = config.active['mutagen_socket_path']
43
49
  end
50
+ # rubocop:enable Metrics/MethodLength
44
51
  # rubocop:enable Metrics/AbcSize
45
52
 
46
53
  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
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
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 @mutagensock, @mutagensock
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
@@ -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
@@ -6,14 +6,45 @@ 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
13
21
  include InfoStatusGopass
14
22
  include InfoStatusGPG
15
23
  include InfoStatusSSH
16
- include InfoStatusHeader
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
+ inside = _docker_container_lib_check_matrjoschka
33
+ @hostname = inside ? ENV['HOSTNAME'] : _docker_container_lib_hostname
34
+ @hostlabel = "hostname=#{@hostname}"
35
+ end
36
+
37
+ #
38
+ # info status bar
39
+ #
40
+ desc 'bar', 'Print status info bar'
41
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
42
+ Print status info bar
43
+ LONGDESC
44
+ # Print status info bar.
45
+ def bar
46
+ say info_status_bar
47
+ end
17
48
 
18
49
  #
19
50
  # info status git
@@ -52,15 +83,15 @@ module Takelage
52
83
  end
53
84
 
54
85
  #
55
- # info status header
86
+ # info status mutagen
56
87
  #
57
- desc 'header', 'Print status info header'
88
+ desc 'mutagen', 'Check mutagen status info'
58
89
  long_desc <<-LONGDESC.gsub("\n", "\x5")
59
- Print status info header
90
+ Check mutagen status info
60
91
  LONGDESC
61
- # Print status info header.
62
- def header
63
- say info_status_header
92
+ # Check mutagen status info.
93
+ def mutagen
94
+ exit mutagen_check_daemon
64
95
  end
65
96
 
66
97
  #
@@ -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
 
@@ -84,7 +85,7 @@ module SystemModule
84
85
 
85
86
  # Check if file exists.
86
87
  def _file_exists?(file)
87
- unless File.exist? file
88
+ unless File.exist? File.expand_path(file)
88
89
  log.debug "File \"#{file}\" doesn't exist"
89
90
  return false
90
91
  end
@@ -94,7 +95,7 @@ module SystemModule
94
95
  # Read yaml file.
95
96
  def _file_read(file)
96
97
  begin
97
- @content_file = File.read file
98
+ @content_file = File.read File.expand_path(file)
98
99
  rescue SystemCallError
99
100
  log.debug "Unable to read file \"#{file}\""
100
101
  return false
@@ -0,0 +1,42 @@
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
+ inside = _docker_container_lib_check_matrjoschka
26
+ @hostname = inside ? ENV['HOSTNAME'] : _docker_container_lib_hostname
27
+ @hostlabel = "hostname=#{@hostname}"
28
+ end
29
+
30
+ #
31
+ # mutagen check daemon
32
+ #
33
+ desc 'daemon', 'Check if mutagen host conenction is available'
34
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
35
+ Check if mutagen host conenction is available
36
+ LONGDESC
37
+ # Check if mutagen host conenction is available.
38
+ def daemon
39
+ exit mutagen_check_daemon
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,37 @@
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
+ def mutagen_check_daemon
9
+ log.debug 'Check mutagen status'
10
+
11
+ unless _file_exists? config.active['mutagen_socket_path']
12
+ log.error 'mutagen socket is not available'
13
+ return false
14
+ end
15
+
16
+ unless _mutagen_check_daemon_host_connection
17
+ log.error 'mutagen host connection is not available'
18
+ return false
19
+ end
20
+
21
+ log.debug 'mutagen is available'
22
+ true
23
+ end
24
+ # rubocop:enable Metrics/MethodLength
25
+
26
+ private
27
+
28
+ # Check mutagen host connection
29
+ def _mutagen_check_daemon_host_connection
30
+ check_host_connection = format(
31
+ config.active['cmd_mutagen_check_daemon_host_connection'],
32
+ hostlabel: @hostlabel
33
+ )
34
+ host_connection = try check_host_connection
35
+ host_connection.exitstatus.zero?
36
+ end
37
+ 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,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,94 @@
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 mutagen 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
+
32
+ inside = _docker_container_lib_check_matrjoschka
33
+ @hostname = inside ? ENV['HOSTNAME'] : _docker_container_lib_hostname
34
+ # See DockerContainerLib::_docker_container_lib_hostname
35
+ @socketname = @hostname[-11..-1]
36
+
37
+ @hostlabel = "hostname=#{@hostname}"
38
+ @takellabel = config.active['mutagen_socket_takelage_label']
39
+
40
+ @sockets = docker_socket_scheme
41
+ end
42
+
43
+ #
44
+ # mutagen socket check
45
+ #
46
+ desc 'check [SOCKET]', 'Check if mutagen [SOCKET] exists'
47
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
48
+ Check if mutagen [SOCKET] exists
49
+ LONGDESC
50
+ # Check if mutagen [SOCKET] exists.
51
+ def check(socket)
52
+ exit mutagen_socket_check socket
53
+ end
54
+
55
+ #
56
+ # mutagen socket create
57
+ #
58
+ desc 'create [IN] [OUT]', 'Create a mutagen socket from [IN] to [OUT] of the container'
59
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
60
+ Create a mutagen socket from [IN] to [OUT] of the container
61
+ LONGDESC
62
+ # Create a mutagen socket from [IN] to [OUT] of the container.
63
+ def create(containersock, hostsock)
64
+ exit mutagen_socket_create containersock, hostsock
65
+ end
66
+
67
+ #
68
+ # mutagen socket list
69
+ #
70
+ desc 'list', 'List mutagen sockets'
71
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
72
+ List mutagen sockets
73
+ LONGDESC
74
+ # List mutagen sockets.
75
+ def list
76
+ socket_list = mutagen_socket_list
77
+ exit false if socket_list == false
78
+ say socket_list
79
+ true
80
+ end
81
+
82
+ #
83
+ # mutagen socket terminate
84
+ #
85
+ desc 'terminate', 'Terminate a mutagen socket'
86
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
87
+ Terminate a mutagen socket
88
+ LONGDESC
89
+ # Terminate a mutagen socket.
90
+ def terminate(socket)
91
+ exit mutagen_socket_terminate socket
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,39 @@
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
+ socket_created = _mutagen_socket_create_socket(containersock, hostsock)
11
+
12
+ unless socket_created.include? 'Created session'
13
+ log.debug "Unable to create mutagen socket \"#{@socketname}\""
14
+ return false
15
+ end
16
+
17
+ log.debug "Created the mutagen socket \"#{@socketname}\""
18
+ true
19
+ end
20
+
21
+ private
22
+
23
+ # Get git branch.
24
+ # rubocop:disable Metrics/MethodLength
25
+ def _mutagen_socket_create_socket(containersock, hostsock)
26
+ cmd_create_socket = format(
27
+ config.active['cmd_mutagen_forward_socket_create'],
28
+ socketname: @socketname,
29
+ containersock: containersock,
30
+ hostsock: hostsock,
31
+ username: @username,
32
+ container: @hostname,
33
+ hostlabel: @hostlabel,
34
+ takellabel: @takellabel
35
+ )
36
+ run cmd_create_socket
37
+ end
38
+ # rubocop:enable Metrics/MethodLength
39
+ 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.7
1
+ 0.28.8
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.7
4
+ version: 0.28.8
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,14 @@ 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
274
282
  - lib/takelage/self/cli.rb
275
283
  - lib/takelage/self/config/cli.rb
276
284
  - 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