takelage 0.25.10 → 0.26.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e946f65c7d82b399bff9b24ad38f5f35692b1984fb3b24a746b9a79d949ff68
4
- data.tar.gz: 22ca88e0d4c57564caafe1fbabd6fb2ec18fe85da30b78edec4286d0f807555f
3
+ metadata.gz: 98366dc05dd33f98b17be99056fcac490af4d5d94b7f6ff6e4b26b76aeb641b7
4
+ data.tar.gz: 236580e61eeb4820c76aa1c685ffa4e0b84d1dd438d5decbb80af3957ac195da
5
5
  SHA512:
6
- metadata.gz: 321defb1e6c775e1fdf69d85fba71f2265602be4db53705b204b4e10096d73c517762e71e910af09cf717bb112f736c1705802ccdfc44a1289ab9e5183f2fbe2
7
- data.tar.gz: 58ab87995c99d0ff2059b9d7def178b3489276e18787c8744c66d43c2bc4d82f80ba959f19e31b3a3084e14c04d99515324ba69ec5b743fc267eb6bb091a8a65
6
+ metadata.gz: d30c5477ca06ff1dad259ff2b6c03bb5f62b63227307981efafac6f74a6ee6f0e298d1191efe87ac9b0e777c3b2758e1fd537734f77dd5c9b825e695d8a94ab9
7
+ data.tar.gz: febee8477c3168f2e23e588077fecfe43df4a8557d7927067eb572065e65e5591fccba41227582f75a20853de24127137bbfdb97dd1645a04ab62bcf35668946
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: ''
@@ -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,40 @@
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
+ ssh_socket_path = _socket_get_agent_ssh_socket_path
12
+
13
+ unless ENV['SSH_AUTH_SOCK'] == ssh_socket_path
14
+ log.error 'gpg ssh socket is misconfigured'
15
+ return false
16
+ end
17
+
18
+ unless _file_exists? ssh_socket_path
19
+ log.error 'gpg ssh socket is not available'
20
+ return false
21
+ end
22
+
23
+ unless _info_status_ssh_keys
24
+ log.error 'ssh keys are not available'
25
+ return false
26
+ end
27
+
28
+ log.debug 'ssh is available'
29
+ true
30
+ end
31
+ # rubocop:enable Metrics/MethodLength
32
+
33
+ private
34
+
35
+ # Check ssh keys
36
+ def _info_status_ssh_keys
37
+ status_keys = try config.active['cmd_info_status_ssh_keys']
38
+ status_keys.exitstatus.zero?
39
+ end
40
+ end
data/lib/takelage/version CHANGED
@@ -1 +1 @@
1
- 0.25.10
1
+ 0.26.2
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.25.10
4
+ version: 0.26.2
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