takeltau 0.34.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +674 -0
  3. data/README.md +235 -0
  4. data/bin/tau +6 -0
  5. data/lib/Thorfile +3 -0
  6. data/lib/takeltau.rb +257 -0
  7. data/lib/takeltau/bit/check/cli.rb +23 -0
  8. data/lib/takeltau/bit/check/workspace.rb +37 -0
  9. data/lib/takeltau/bit/cli.rb +18 -0
  10. data/lib/takeltau/bit/clipboard/cli.rb +73 -0
  11. data/lib/takeltau/bit/clipboard/copy.rb +142 -0
  12. data/lib/takeltau/bit/clipboard/lib.rb +143 -0
  13. data/lib/takeltau/bit/clipboard/paste.rb +60 -0
  14. data/lib/takeltau/bit/clipboard/pull.rb +37 -0
  15. data/lib/takeltau/bit/clipboard/push.rb +37 -0
  16. data/lib/takeltau/bit/require/cli.rb +57 -0
  17. data/lib/takeltau/bit/require/export.rb +34 -0
  18. data/lib/takeltau/bit/require/import.rb +133 -0
  19. data/lib/takeltau/bit/require/lib.rb +19 -0
  20. data/lib/takeltau/bit/scope/add.rb +55 -0
  21. data/lib/takeltau/bit/scope/cli.rb +74 -0
  22. data/lib/takeltau/bit/scope/list.rb +41 -0
  23. data/lib/takeltau/bit/scope/new.rb +44 -0
  24. data/lib/takeltau/bit/scope/ssh.rb +13 -0
  25. data/lib/takeltau/completion/cli.rb +24 -0
  26. data/lib/takeltau/default.yml +95 -0
  27. data/lib/takeltau/docker/check/cli.rb +23 -0
  28. data/lib/takeltau/docker/check/daemon.rb +27 -0
  29. data/lib/takeltau/docker/cli.rb +15 -0
  30. data/lib/takeltau/docker/container/check/cli.rb +57 -0
  31. data/lib/takeltau/docker/container/check/existing.rb +32 -0
  32. data/lib/takeltau/docker/container/check/network.rb +32 -0
  33. data/lib/takeltau/docker/container/check/orphaned.rb +32 -0
  34. data/lib/takeltau/docker/container/clean.rb +40 -0
  35. data/lib/takeltau/docker/container/cli.rb +118 -0
  36. data/lib/takeltau/docker/container/command.rb +38 -0
  37. data/lib/takeltau/docker/container/daemon.rb +17 -0
  38. data/lib/takeltau/docker/container/lib.rb +181 -0
  39. data/lib/takeltau/docker/container/login.rb +58 -0
  40. data/lib/takeltau/docker/container/prune.rb +31 -0
  41. data/lib/takeltau/docker/image/cli.rb +39 -0
  42. data/lib/takeltau/docker/image/tag/check.rb +42 -0
  43. data/lib/takeltau/docker/image/tag/cli.rb +68 -0
  44. data/lib/takeltau/docker/image/tag/latest.rb +24 -0
  45. data/lib/takeltau/docker/image/tag/list.rb +19 -0
  46. data/lib/takeltau/docker/image/update.rb +27 -0
  47. data/lib/takeltau/git/check/bit.rb +26 -0
  48. data/lib/takeltau/git/check/clean.rb +46 -0
  49. data/lib/takeltau/git/check/cli.rb +49 -0
  50. data/lib/takeltau/git/check/workspace.rb +34 -0
  51. data/lib/takeltau/git/cli.rb +9 -0
  52. data/lib/takeltau/info/cli.rb +12 -0
  53. data/lib/takeltau/info/project/cli.rb +69 -0
  54. data/lib/takeltau/info/status/bar.rb +112 -0
  55. data/lib/takeltau/info/status/cli.rb +107 -0
  56. data/lib/takeltau/info/status/git.rb +47 -0
  57. data/lib/takeltau/info/status/gopass.rb +37 -0
  58. data/lib/takeltau/info/status/gpg.rb +39 -0
  59. data/lib/takeltau/info/status/lib.rb +46 -0
  60. data/lib/takeltau/info/status/ssh.rb +46 -0
  61. data/lib/takeltau/init/cli.rb +12 -0
  62. data/lib/takeltau/init/lib.rb +86 -0
  63. data/lib/takeltau/init/packer/cli.rb +82 -0
  64. data/lib/takeltau/init/packer/docker.rb +64 -0
  65. data/lib/takeltau/init/packer/templates/ansiblelint.tt +3 -0
  66. data/lib/takeltau/init/packer/templates/bitrequireyml.tt +13 -0
  67. data/lib/takeltau/init/packer/templates/groupvarsprojectyml.tt +2 -0
  68. data/lib/takeltau/init/packer/templates/playbooksiteyml.tt +6 -0
  69. data/lib/takeltau/init/packer/templates/projectyml.tt +19 -0
  70. data/lib/takeltau/init/takelage/cli.rb +70 -0
  71. data/lib/takeltau/init/takelage/rake.rb +61 -0
  72. data/lib/takeltau/init/takelage/templates/bitrequireyml.tt +5 -0
  73. data/lib/takeltau/init/takelage/templates/projectyml.tt +3 -0
  74. data/lib/takeltau/init/templates/Rakefile.tt +3 -0
  75. data/lib/takeltau/init/templates/gitignore.tt +16 -0
  76. data/lib/takeltau/lib/config.rb +130 -0
  77. data/lib/takeltau/lib/logging.rb +49 -0
  78. data/lib/takeltau/lib/project.rb +72 -0
  79. data/lib/takeltau/lib/subcmd.rb +18 -0
  80. data/lib/takeltau/lib/system.rb +194 -0
  81. data/lib/takeltau/mutagen/check/cli.rb +40 -0
  82. data/lib/takeltau/mutagen/check/daemon.rb +76 -0
  83. data/lib/takeltau/mutagen/cli.rb +12 -0
  84. data/lib/takeltau/mutagen/socket/check.rb +33 -0
  85. data/lib/takeltau/mutagen/socket/cli.rb +103 -0
  86. data/lib/takeltau/mutagen/socket/create.rb +47 -0
  87. data/lib/takeltau/mutagen/socket/list.rb +33 -0
  88. data/lib/takeltau/mutagen/socket/terminate.rb +32 -0
  89. data/lib/takeltau/mutagen/socket/tidy.rb +21 -0
  90. data/lib/takeltau/self/cli.rb +43 -0
  91. data/lib/takeltau/self/config/cli.rb +82 -0
  92. data/lib/takeltau/self/list.rb +35 -0
  93. data/lib/takeltau/version +1 -0
  94. metadata +319 -0
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Takeltau
4
+ # takeltau info project
5
+ class InfoProject < SubCommandBase
6
+ include LoggingModule
7
+ include SystemModule
8
+ include ConfigModule
9
+ include ProjectModule
10
+
11
+ #
12
+ # info project active
13
+ #
14
+ desc 'active', 'Print active project info'
15
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
16
+ Print active project info
17
+ LONGDESC
18
+ # Print active project info.
19
+ def active
20
+ project_active_yaml = hash_to_yaml(project.active)
21
+ exit false if project_active_yaml == false
22
+ say project_active_yaml
23
+ true
24
+ end
25
+
26
+ #
27
+ # info project private
28
+ #
29
+ desc 'private', 'Print private project info'
30
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
31
+ Print private project info
32
+ LONGDESC
33
+ # Print private project info.
34
+ def private
35
+ project_private_yaml = hash_to_yaml(project.private)
36
+ exit false if project_private_yaml == false
37
+ say project_private_yaml
38
+ true
39
+ end
40
+
41
+ #
42
+ # info project main
43
+ #
44
+ desc 'main', 'Print main project info'
45
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
46
+ Print main project info
47
+ LONGDESC
48
+ # Print main project info.
49
+ def main
50
+ project_main_yaml = hash_to_yaml(project.main)
51
+ exit false if project_main_yaml == false
52
+ say project_main_yaml
53
+ true
54
+ end
55
+
56
+ #
57
+ # info project dir
58
+ #
59
+ desc 'dir', 'Print project root directory'
60
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
61
+ Print project root directory
62
+ LONGDESC
63
+ # Print project root directory.
64
+ def dir
65
+ say project.dir
66
+ true
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takeltau 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_mutagen
19
+ _info_status_bar_ssh
20
+
21
+ bar = @bar_list.join(' | ')
22
+ log.debug "status info bar: #{bar}"
23
+ bar
24
+ end
25
+ # rubocop:enable Metrics/MethodLength
26
+
27
+ private
28
+
29
+ # Add takelage version info to bar.
30
+ def _info_status_bar_takelage
31
+ takelage_version_file = '/etc/takelage_version'
32
+ return unless _file_exists? takelage_version_file
33
+
34
+ _file_read takelage_version_file
35
+ @bar_list << "#{config.active['docker_repo']}: #{@content_file.chomp.green}"
36
+ end
37
+
38
+ # Add tau version info to bar.
39
+ def _info_status_bar_tau
40
+ @bar_list << "tau: #{Takeltau::VERSION.green}"
41
+ end
42
+
43
+ # Add git status info to bar.
44
+ def _info_status_bar_git
45
+ @status_git = info_status_git
46
+ @bar_list << ("git: #{@status_git ? 'ok'.green : 'no'.red}")
47
+ end
48
+
49
+ # Add gopass status info to bar.
50
+ def _info_status_bar_gopass
51
+ @status_gopass = info_status_gopass
52
+ @bar_list << ("gopass: #{@status_gopass ? 'ok'.green : 'no'.red}")
53
+ end
54
+
55
+ # Add gpg status info to bar.
56
+ def _info_status_bar_gpg
57
+ if @status_git || @status_gopass
58
+ @bar_list << "gpg: #{'ok'.green}"
59
+ return
60
+ end
61
+
62
+ @bar_list << ("gpg: #{info_status_gpg ? 'ok'.green : 'no'.red}")
63
+ end
64
+
65
+ # Add mutagen status info to bar.
66
+ def _info_status_bar_mutagen
67
+ @bar_list << ("mutagen: #{mutagen_check_daemon ? 'ok'.green : 'no'.red}")
68
+ end
69
+
70
+ # Add ssh status info to bar.
71
+ def _info_status_bar_ssh
72
+ @bar_list << ("ssh: #{info_status_ssh ? 'ok'.green : 'no'.red}")
73
+ end
74
+ end
75
+
76
+ # Amend String class with colorization.
77
+ class String
78
+ # Colorize strings
79
+ def colorize(color_code)
80
+ "\e[#{color_code}m#{self}\e[0m"
81
+ end
82
+
83
+ # String color red
84
+ def red
85
+ colorize(31)
86
+ end
87
+
88
+ # String color green
89
+ def green
90
+ colorize(32)
91
+ end
92
+
93
+ # String color yellow
94
+ def yellow
95
+ colorize(33)
96
+ end
97
+
98
+ # String color blue
99
+ def blue
100
+ colorize(34)
101
+ end
102
+
103
+ # String color pink
104
+ def pink
105
+ colorize(35)
106
+ end
107
+
108
+ # String color light_blue
109
+ def light_blue
110
+ colorize(36)
111
+ end
112
+ end
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Takeltau
4
+ # takeltau info status
5
+ class InfoStatus < SubCommandBase
6
+ include LoggingModule
7
+ include SystemModule
8
+ include ConfigModule
9
+ include DockerCheckDaemon
10
+ include DockerContainerCheckExisting
11
+ include DockerContainerCheckNetwork
12
+ include DockerContainerCommand
13
+ include DockerContainerLib
14
+ include GitCheckWorkspace
15
+ include InfoStatusLib
16
+ include InfoStatusGit
17
+ include InfoStatusGopass
18
+ include InfoStatusGPG
19
+ include InfoStatusSSH
20
+ include InfoStatusBar
21
+ include MutagenCheckDaemon
22
+
23
+ # Initialize info status
24
+ def initialize(args = [], local_options = {}, configuration = {})
25
+ # initialize thor parent class
26
+ super args, local_options, configuration
27
+
28
+ @workdir = Dir.getwd
29
+
30
+ inside = _docker_container_lib_check_matrjoschka
31
+ @hostname = inside ? ENV['HOSTNAME'] : _docker_container_lib_hostname
32
+ @hostlabel = "hostname=#{@hostname}"
33
+ end
34
+
35
+ #
36
+ # info status bar
37
+ #
38
+ desc 'bar', 'Print status info bar'
39
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
40
+ Print status info bar
41
+ LONGDESC
42
+ # Print status info bar.
43
+ def bar
44
+ say info_status_bar
45
+ end
46
+
47
+ #
48
+ # info status git
49
+ #
50
+ desc 'git', 'Check git status info'
51
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
52
+ Check git status info
53
+ LONGDESC
54
+ # Check git status info.
55
+ def git
56
+ exit info_status_git
57
+ end
58
+
59
+ #
60
+ # info status gopass
61
+ #
62
+ desc 'gopass', 'Check gopass status info'
63
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
64
+ Check gopass status info
65
+ LONGDESC
66
+ # Check gopass status info.
67
+ def gopass
68
+ exit info_status_gopass
69
+ end
70
+
71
+ #
72
+ # info status gpg
73
+ #
74
+ desc 'gpg', 'Check gpg status info'
75
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
76
+ Check gpg status info
77
+ LONGDESC
78
+ # Check gpg status info.
79
+ def gpg
80
+ exit info_status_gpg
81
+ end
82
+
83
+ #
84
+ # info status mutagen
85
+ #
86
+ desc 'mutagen', 'Check mutagen status info'
87
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
88
+ Check mutagen status info
89
+ LONGDESC
90
+ # Check mutagen status info.
91
+ def mutagen
92
+ exit mutagen_check_daemon
93
+ end
94
+
95
+ #
96
+ # info status ssh
97
+ #
98
+ desc 'ssh', 'Check ssh status info'
99
+ long_desc <<-LONGDESC.gsub("\n", "\x5")
100
+ Check ssh status info
101
+ LONGDESC
102
+ # Check ssh status info.
103
+ def ssh
104
+ exit info_status_ssh
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takeltau 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.chomp.empty?
15
+ log.error 'Cannot determine project root directory'
16
+ log.warn 'Is there a Rakefile in the project root directory?'
17
+ return false
18
+ end
19
+
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?
26
+ log.error 'git config user.name is not available'
27
+ return false
28
+ end
29
+
30
+ if _info_status_lib_git_email(root).chomp.empty?
31
+ log.error 'git config user.email is not available'
32
+ return false
33
+ end
34
+
35
+ key = _info_status_lib_git_signingkey(root)
36
+
37
+ unless _info_status_lib_git_key_available(key).exitstatus.zero?
38
+ log.error 'git config user.signingkey is not available'
39
+ return false
40
+ end
41
+
42
+ log.debug 'git config is available'
43
+ true
44
+ end
45
+ # rubocop:enable Metrics/AbcSize
46
+ # rubocop:enable Metrics/MethodLength
47
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takeltau 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
12
+
13
+ if root.chomp.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).chomp
36
+ end
37
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takeltau 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,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ # takeltau 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).chomp
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