takelage 0.24.0 → 0.26.4

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: c41543ac3d5b7a93fce0807339107b6f2016524b17ff3c7a8dbfc9bb227e003f
4
- data.tar.gz: 12a43bf57f55d6e2bb41530eb3f71c4c1f1a99003700845bc8b150072689d464
3
+ metadata.gz: 8bf925e231daeab5d3930c78e761cafef36cf9ae428938df47d32459f0d4b001
4
+ data.tar.gz: 3485b85dfdeba7f4da4a67426c2a7ad61a14f9b81118e1305d163880757f5436
5
5
  SHA512:
6
- metadata.gz: 35a1911ec6a0c7191e500968902be2cf92904906d8cff2af47d0bff8f30c60a3f5b7049cbcb512ac05ce65f21fe71de30987a7de77f63d222f7c0bf1ef1b8d9b
7
- data.tar.gz: 9fdd8888975db08c2941f9774c0c28a4a4fa97aca800385bd600d69b3e020374f4d0867a6d7a8710935dec663b746eb18d7f6721049623aa908cfd409f72f4dc
6
+ metadata.gz: 3b6804918d7e81e8d93412b162168bc0617e6bf89443aa86476bfbcf152b33a292f4bf9388848a4390bf5968049d092ca01608048c1b0020e2d270905c20a7d5
7
+ data.tar.gz: aafc982404aceecd7f241991dbcb67194ddacda3d088849acfa0f56f7604d03b20c0a07360f5f3581d3d702f1ea4b1de0ece0afef95f3e39d3d4839f60e57852
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![takelage image](https://github.com/geospin-takelage/takelage-cli/actions/workflows/test_project_nightly.yml/badge.svg)
2
+
1
3
  # takelage-cli
2
4
 
3
5
  *takelage-cli* is a command line interface
@@ -84,6 +86,11 @@ tau [info project active](features/cucumber/features/info/info.project.active.fe
84
86
  tau [info project dir](features/cucumber/features/info/info.project.dir.feature) | Print project root directory
85
87
  tau [info project main](features/cucumber/features/info/info.project.main.feature) | Print main project info
86
88
  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
87
94
  tau [self config active](features/cucumber/features/self/self.config.active.feature) | Print active takelage configuration
88
95
  tau [self config default](features/cucumber/features/self/self.config.default.feature) | Print takelage default configuration
89
96
  tau [self config home](features/cucumber/features/self/self.config.home.feature) | Print takelage home config file configuration
@@ -100,6 +107,7 @@ tau project | Alias for tau [info project active](features/cucumber/features/inf
100
107
  tau prune | Alias for tau [docker container prune](features/cucumber/features/docker/docker.container.prune.feature)
101
108
  tau pull | Alias for tau [bit clipboard pull](features/cucumber/features/bit/bit.clipboard.pull.feature)
102
109
  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)
103
111
  tau update | Alias for tau [docker image update](features/cucumber/features/docker/docker.image.update.feature)
104
112
  tau version | Alias for tau [self version](features/cucumber/features/self/self.version.feature)
105
113
 
data/lib/takelage.rb CHANGED
@@ -71,6 +71,13 @@ require_relative 'takelage/docker/container/clean'
71
71
  require_relative 'takelage/docker/container/prune'
72
72
  require_relative 'takelage/docker/container/cli'
73
73
  require_relative 'takelage/docker/cli'
74
+ require_relative 'takelage/info/status/lib'
75
+ require_relative 'takelage/info/status/git'
76
+ require_relative 'takelage/info/status/gopass'
77
+ require_relative 'takelage/info/status/gpg'
78
+ require_relative 'takelage/info/status/ssh'
79
+ require_relative 'takelage/info/status/header'
80
+ require_relative 'takelage/info/status/cli'
74
81
  require_relative 'takelage/info/project/cli'
75
82
  require_relative 'takelage/info/cli'
76
83
  require_relative 'takelage/self/config/cli'
@@ -203,6 +210,12 @@ module Takelage
203
210
  Takelage::BitClipboard.new.push
204
211
  end
205
212
 
213
+ desc 'status', 'Alias for tau info status header'
214
+ # takelage status: {takelage::InfoStatus#header}
215
+ def status
216
+ Takelage::InfoStatus.new.header
217
+ end
218
+
206
219
  desc 'update', 'Alias for tau docker image update'
207
220
  # takelage update: {takelage::DockerImage#update}
208
221
  def update
@@ -58,6 +58,14 @@ cmd_git_check_clean_git_status: 'git status --porcelain'
58
58
  cmd_git_check_main_git_branch: 'git symbolic-ref HEAD'
59
59
  cmd_git_check_workspace_git_repo: 'git -C . rev-parse'
60
60
  cmd_git_check_workspace_pwd: 'pwd'
61
+ cmd_info_status_lib_git_name: 'git -C %{root} config user.name'
62
+ cmd_info_status_lib_git_email: 'git -C %{root} config user.email'
63
+ cmd_info_status_lib_git_signingkey: 'git -C %{root} config user.signingKey'
64
+ cmd_info_status_lib_git_key_available: 'gpg --list-key %{key}'
65
+ cmd_info_status_gopass_root_store: 'gopass config | grep "path" | cut -d " " -f 2'
66
+ cmd_info_status_gpg_agent: 'gpg-connect-agent /bye'
67
+ cmd_info_status_gpg_keys: 'gpg --list-keys'
68
+ cmd_info_status_ssh_keys: 'ssh-add -l'
61
69
  docker_debug: 'ansible/roles/takel-takelage/files/takelscripts'
62
70
  docker_entrypoint_extra: '.config/gcloud'
63
71
  docker_entrypoint_options: ''
@@ -118,6 +118,10 @@ module DockerContainerLib
118
118
  return false unless ENV.keys.include? 'TAKELAGE_PROJECT_BASE_DIR'
119
119
 
120
120
  log.error 'You cannot log in to takelage from within takelage'
121
+
122
+ # wait or the github workflow will fail
123
+ sleep 1
124
+
121
125
  true
122
126
  end
123
127
 
@@ -19,8 +19,7 @@ module GitCheckWorkspace
19
19
 
20
20
  # Get git repository status.
21
21
  def _git_check_workspace_get_status_repo
22
- cmd_git_repo =
23
- config.active['cmd_git_check_workspace_git_repo']
22
+ cmd_git_repo = config.active['cmd_git_check_workspace_git_repo']
24
23
  try cmd_git_repo
25
24
  end
26
25
 
@@ -5,5 +5,8 @@ module Takelage
5
5
  class Info < SubCommandBase
6
6
  desc 'project [COMMAND]', 'Get project info'
7
7
  subcommand 'project', InfoProject
8
+
9
+ desc 'status [COMMAND]', 'Get status info'
10
+ subcommand 'status', InfoStatus
8
11
  end
9
12
  end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Takelage
4
+ # takelage info status
5
+ class InfoStatus < SubCommandBase
6
+ include LoggingModule
7
+ include SystemModule
8
+ include ConfigModule
9
+ include DockerSocketScheme
10
+ include InfoStatusLib
11
+ include InfoStatusGit
12
+ include InfoStatusGopass
13
+ include InfoStatusGPG
14
+ include InfoStatusSSH
15
+ include InfoStatusHeader
16
+
17
+ #
18
+ # info status git
19
+ #
20
+ desc 'git', 'Check git status info'
21
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
22
+ Check git status info
23
+ LONGDESC
24
+ # Check git status info.
25
+ def git
26
+ exit info_status_git
27
+ end
28
+
29
+ #
30
+ # info status gopass
31
+ #
32
+ desc 'gopass', 'Check gopass status info'
33
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
34
+ Check gopass status info
35
+ LONGDESC
36
+ # Check gopass status info.
37
+ def gopass
38
+ exit info_status_gopass
39
+ end
40
+
41
+ #
42
+ # info status gpg
43
+ #
44
+ desc 'gpg', 'Check gpg status info'
45
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
46
+ Check gpg status info
47
+ LONGDESC
48
+ # Check gpg status info.
49
+ def gpg
50
+ exit info_status_gpg
51
+ end
52
+
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
+ # info status ssh
67
+ #
68
+ desc 'ssh', 'Check ssh status info'
69
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
70
+ Check ssh status info
71
+ LONGDESC
72
+ # Check ssh status info.
73
+ def ssh
74
+ exit info_status_ssh
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage info status git
4
+ module InfoStatusGit
5
+ # Backend method for info status git.
6
+ # @return [Boolean] is the git gpg signing key available?
7
+ # rubocop:disable Metrics/MethodLength
8
+ # rubocop:disable Metrics/AbcSize
9
+ def info_status_git
10
+ log.debug 'Check git status'
11
+
12
+ root = config.active['project_root_dir']
13
+
14
+ if root.strip.empty?
15
+ log.error 'Cannot determine project root directory'
16
+ log.info 'Is there a Rakefile in the project root directory?'
17
+ return false
18
+ end
19
+
20
+ if _info_status_lib_git_name(root).strip.empty?
21
+ log.error 'git config user.name is not available'
22
+ return false
23
+ end
24
+
25
+ if _info_status_lib_git_email(root).strip.empty?
26
+ log.error 'git config user.email is not available'
27
+ return false
28
+ end
29
+
30
+ key = _info_status_lib_git_signingkey(root)
31
+
32
+ unless _info_status_lib_git_key_available(key).exitstatus.zero?
33
+ log.error 'git config user.signingkey is not available'
34
+ return false
35
+ end
36
+
37
+ log.debug 'git config is available'
38
+ true
39
+ end
40
+ # rubocop:enable Metrics/AbcSize
41
+ # rubocop:enable Metrics/MethodLength
42
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage info status gopass
4
+ module InfoStatusGopass
5
+ # Backend method for info status gopass.
6
+ # @return [Boolean] is gopass available?
7
+ # rubocop:disable Metrics/MethodLength
8
+ def info_status_gopass
9
+ log.debug 'Check gopass status'
10
+
11
+ root = _info_status_gopass_root_store.chomp
12
+
13
+ if root.strip.empty?
14
+ log.error 'gopass root store not found'
15
+ return false
16
+ end
17
+
18
+ key = _info_status_lib_git_signingkey(root)
19
+
20
+ unless _info_status_lib_git_key_available(key).exitstatus.zero?
21
+ log.error 'gopass root store gpg key is not available'
22
+ return false
23
+ end
24
+
25
+ log.debug 'gopass is available'
26
+ true
27
+ end
28
+ # rubocop:enable Metrics/MethodLength
29
+
30
+ private
31
+
32
+ # Get gopass root store
33
+ def _info_status_gopass_root_store
34
+ cmd_gopass_root_store = config.active['cmd_info_status_gopass_root_store']
35
+ run cmd_gopass_root_store
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage info status gpg
4
+ module InfoStatusGPG
5
+ # Backend method for info status gpg.
6
+ # @return [Boolean] is GPG available?
7
+ # rubocop:disable Metrics/MethodLength
8
+ def info_status_gpg
9
+ log.debug 'Check gpg status'
10
+
11
+ unless _info_status_gpg_keys
12
+ log.error 'gpg keys are not available'
13
+ return false
14
+ end
15
+
16
+ unless _info_status_gpg_agent
17
+ log.error 'gpg agent is not available'
18
+ return false
19
+ end
20
+
21
+ log.debug 'gpg is available'
22
+ true
23
+ end
24
+ # rubocop:enable Metrics/MethodLength
25
+
26
+ private
27
+
28
+ # Check gpg keys
29
+ def _info_status_gpg_keys
30
+ status_keys = try config.active['cmd_info_status_gpg_keys']
31
+ status_keys.exitstatus.zero?
32
+ end
33
+
34
+ # Check gpg agent
35
+ def _info_status_gpg_agent
36
+ status_agent = try config.active['cmd_info_status_gpg_agent']
37
+ status_agent.exitstatus.zero?
38
+ end
39
+ end
@@ -0,0 +1,106 @@
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
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage info status lib
4
+ module InfoStatusLib
5
+ private
6
+
7
+ # Get git config user name
8
+ def _info_status_lib_git_name(root)
9
+ cmd_git_name =
10
+ format(
11
+ config.active['cmd_info_status_lib_git_name'],
12
+ root: root
13
+ )
14
+ run cmd_git_name
15
+ end
16
+
17
+ # Get git config user email
18
+ def _info_status_lib_git_email(root)
19
+ cmd_git_email =
20
+ format(
21
+ config.active['cmd_info_status_lib_git_email'],
22
+ root: root
23
+ )
24
+ run cmd_git_email
25
+ end
26
+
27
+ # Get git config user signingkey
28
+ def _info_status_lib_git_signingkey(root)
29
+ cmd_git_signingkey =
30
+ format(
31
+ config.active['cmd_info_status_lib_git_signingkey'],
32
+ root: root
33
+ )
34
+ run cmd_git_signingkey
35
+ end
36
+
37
+ # Check if git key is available
38
+ def _info_status_lib_git_key_available(key)
39
+ cmd_git_key_available =
40
+ format(
41
+ config.active['cmd_info_status_lib_git_key_available'],
42
+ key: key
43
+ )
44
+ try cmd_git_key_available
45
+ end
46
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takelage info status ssh
4
+ module InfoStatusSSH
5
+ # Backend method for info status ssh.
6
+ # @return [Boolean] is ssh available?
7
+ # rubocop:disable Metrics/MethodLength
8
+ def info_status_ssh
9
+ log.debug 'Check ssh status'
10
+
11
+ unless _file_exists? _socket_get_agent_ssh_socket_path
12
+ log.error 'gpg ssh socket is not available'
13
+ return false
14
+ end
15
+
16
+ unless _info_status_ssh_keys
17
+ log.error 'ssh keys are not available'
18
+ return false
19
+ end
20
+
21
+ log.debug 'ssh is available'
22
+ true
23
+ end
24
+ # rubocop:enable Metrics/MethodLength
25
+
26
+ private
27
+
28
+ # Check ssh keys
29
+ def _info_status_ssh_keys
30
+ status_keys = try config.active['cmd_info_status_ssh_keys']
31
+ status_keys.exitstatus.zero?
32
+ end
33
+ end
data/lib/takelage/version CHANGED
@@ -1 +1 @@
1
- 0.24.0
1
+ 0.26.4
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.24.0
4
+ version: 0.26.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geospin
@@ -259,6 +259,13 @@ 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/cli.rb
263
+ - lib/takelage/info/status/git.rb
264
+ - lib/takelage/info/status/gopass.rb
265
+ - lib/takelage/info/status/gpg.rb
266
+ - lib/takelage/info/status/header.rb
267
+ - lib/takelage/info/status/lib.rb
268
+ - lib/takelage/info/status/ssh.rb
262
269
  - lib/takelage/lib/config.rb
263
270
  - lib/takelage/lib/logging.rb
264
271
  - lib/takelage/lib/project.rb
@@ -288,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
295
  - !ruby/object:Gem::Version
289
296
  version: '0'
290
297
  requirements: []
291
- rubygems_version: 3.0.8
298
+ rubygems_version: 3.2.3
292
299
  signing_key:
293
300
  specification_version: 4
294
301
  summary: takelage devops workflow cli