ops_team 0.8.8 → 0.9.2
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 +4 -4
- data/lib/action.rb +1 -1
- data/lib/builtin.rb +12 -0
- data/lib/builtins/background.rb +52 -0
- data/lib/builtins/background_log.rb +27 -0
- data/lib/dependencies/sshkey.rb +17 -3
- data/lib/ops.rb +10 -9
- data/lib/output.rb +2 -0
- data/ops_team.gemspec +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a168c8803f5f12ecc5ba54fc77e4a304baa300aa100e2d81d92b2f5146551d7
|
4
|
+
data.tar.gz: dec291b877b6cc0fc056feb794e676abd56f5376b8373f914b6c24dfd3d7462d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d96bea7054642ba35750f8efa59d6a6e2201dce98aaa5471dda573704ceb66f5daedf38f9cd7a68d2b31f9bd53ad17fff85790f61fe04fca8221ac9299140ddb
|
7
|
+
data.tar.gz: 86b51b059eca72ba60f30c2be14c83bc40e4e1c872c3edaa91bab6a94080eb34a59eda351ef796d42d903216ca71f1fd8059d031773fb0b1efd2e7f2b498e4f5
|
data/lib/action.rb
CHANGED
data/lib/builtin.rb
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Builtin
|
4
|
+
attr_reader :args, :config
|
5
|
+
|
4
6
|
class << self
|
5
7
|
def description
|
6
8
|
"no description"
|
7
9
|
end
|
10
|
+
|
11
|
+
def class_for(name:)
|
12
|
+
Builtins.const_get(builtin_class_name_for(name: name), false)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def builtin_class_name_for(name:)
|
18
|
+
name.capitalize.to_sym
|
19
|
+
end
|
8
20
|
end
|
9
21
|
|
10
22
|
def initialize(args, config)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'builtin'
|
4
|
+
|
5
|
+
module Builtins
|
6
|
+
class Background < Builtin
|
7
|
+
DEFAULT_SHELL = "bash"
|
8
|
+
DEFAULT_LOG_FILE_PREFIX = "/tmp/ops_bglog_"
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def description
|
12
|
+
"runs the given command in a background session"
|
13
|
+
end
|
14
|
+
|
15
|
+
def log_filename
|
16
|
+
"#{log_filename_prefix}#{Ops.project_name}"
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def log_filename_prefix
|
22
|
+
Options.get("background.log_filename_prefix") || DEFAULT_LOG_FILE_PREFIX
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
subprocess = fork do
|
28
|
+
run_ops(args)
|
29
|
+
end
|
30
|
+
|
31
|
+
Process.detach(subprocess)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def run_ops(args)
|
37
|
+
Output.notice("Running '#{args.join(' ')}' with stderr and stdout redirected to '#{Background.log_filename}'")
|
38
|
+
$stdout.sync = $stderr.sync = true
|
39
|
+
$stdout.reopen(Background.log_filename, "w")
|
40
|
+
$stderr.reopen($stdout)
|
41
|
+
|
42
|
+
Ops.new(args).run
|
43
|
+
end
|
44
|
+
|
45
|
+
def shell
|
46
|
+
Options.get("background.shell") || DEFAULT_SHELL
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
# set an alias
|
51
|
+
Bg = Background
|
52
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'builtin'
|
4
|
+
require 'builtins/background'
|
5
|
+
|
6
|
+
module Builtins
|
7
|
+
class BackgroundLog < Builtin
|
8
|
+
class << self
|
9
|
+
def description
|
10
|
+
"displays the log from the current or most recent background task from this project"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def run
|
15
|
+
unless File.exist?(Background.log_filename)
|
16
|
+
Output.warn("No background log found at '#{Background.log_filename}'.")
|
17
|
+
return 0
|
18
|
+
end
|
19
|
+
|
20
|
+
Output.notice("Displaying background log '#{Background.log_filename}'...")
|
21
|
+
exec("tail #{args.join(' ')} '#{Background.log_filename}'")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# set an alias
|
26
|
+
Bglog = BackgroundLog
|
27
|
+
end
|
data/lib/dependencies/sshkey.rb
CHANGED
@@ -35,6 +35,8 @@ module Dependencies
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def generate_key
|
38
|
+
Output.warn("\nNo passphrase set for SSH key '#{priv_key_name}'") if passphrase.nil? || passphrase.empty?
|
39
|
+
|
38
40
|
execute("ssh-keygen -b #{opt_key_size} -t #{opt_key_algo} -f #{priv_key_name} -q -N '#{passphrase}'")
|
39
41
|
end
|
40
42
|
|
@@ -55,8 +57,7 @@ module Dependencies
|
|
55
57
|
end
|
56
58
|
|
57
59
|
def key_comment
|
58
|
-
|
59
|
-
File.basename(::Dir.pwd)
|
60
|
+
Ops.project_name
|
60
61
|
end
|
61
62
|
|
62
63
|
def dir_name
|
@@ -84,7 +85,20 @@ module Dependencies
|
|
84
85
|
end
|
85
86
|
|
86
87
|
def opt_passphrase
|
87
|
-
|
88
|
+
@opt_passphrase ||= begin
|
89
|
+
return "$#{Options.get('sshkey.passphrase_var')}" if Options.get("sshkey.passphrase_var")
|
90
|
+
|
91
|
+
output_passphrase_warning if Options.get("sshkey.passphrase")
|
92
|
+
|
93
|
+
Options.get("sshkey.passphrase")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def output_passphrase_warning
|
98
|
+
Output.warn(
|
99
|
+
"\n'options.sshkey.passphrase' is deprecated and will be removed in a future release. " \
|
100
|
+
"Use 'options.sshkey.passphrase_var' instead."
|
101
|
+
)
|
88
102
|
end
|
89
103
|
|
90
104
|
def opt_add_keys?
|
data/lib/ops.rb
CHANGED
@@ -19,6 +19,12 @@ class Ops
|
|
19
19
|
INVALID_SYNTAX_EXIT_CODE = 64
|
20
20
|
UNKNOWN_ACTION_EXIT_CODE = 65
|
21
21
|
|
22
|
+
class << self
|
23
|
+
def project_name
|
24
|
+
File.basename(::Dir.pwd)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
def initialize(argv)
|
23
29
|
@action_name = argv[0]
|
24
30
|
@args = argv[1..-1]
|
@@ -27,7 +33,7 @@ class Ops
|
|
27
33
|
end
|
28
34
|
|
29
35
|
def run
|
30
|
-
exit(INVALID_SYNTAX_EXIT_CODE) unless syntax_valid?
|
36
|
+
return exit(INVALID_SYNTAX_EXIT_CODE) unless syntax_valid?
|
31
37
|
|
32
38
|
run_action
|
33
39
|
rescue UnknownActionError => e
|
@@ -39,8 +45,7 @@ class Ops
|
|
39
45
|
|
40
46
|
def syntax_valid?
|
41
47
|
if @action_name.nil?
|
42
|
-
|
43
|
-
puts "Usage: ops <action>"
|
48
|
+
Output.error("Usage: ops <action>")
|
44
49
|
false
|
45
50
|
else
|
46
51
|
true
|
@@ -53,21 +58,17 @@ class Ops
|
|
53
58
|
|
54
59
|
return builtin.run if builtin
|
55
60
|
|
56
|
-
Output.
|
61
|
+
Output.notice("Running '#{action}' from #{CONFIG_FILE} in environment '#{ENV['environment']}'...")
|
57
62
|
action.run
|
58
63
|
end
|
59
64
|
|
60
65
|
def builtin
|
61
|
-
@builtin ||=
|
66
|
+
@builtin ||= Builtin.class_for(name: @action_name).new(@args, config)
|
62
67
|
rescue NameError
|
63
68
|
# this means there isn't a builtin with that name in that module
|
64
69
|
nil
|
65
70
|
end
|
66
71
|
|
67
|
-
def builtin_class_name
|
68
|
-
@action_name.capitalize.to_sym
|
69
|
-
end
|
70
|
-
|
71
72
|
def action
|
72
73
|
return actions[@action_name] if actions[@action_name]
|
73
74
|
return aliases[@action_name] if aliases[@action_name]
|
data/lib/output.rb
CHANGED
data/ops_team.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'ops_team'
|
5
|
-
s.version = '0.
|
5
|
+
s.version = '0.9.2'
|
6
6
|
s.authors = [
|
7
7
|
'nickthecook@gmail.com'
|
8
8
|
]
|
9
|
-
s.date = '2020-
|
9
|
+
s.date = '2020-08-11'
|
10
10
|
s.summary = 'ops_team handles basic operations tasks for your project, driven by YAML config'
|
11
11
|
s.homepage = 'https://github.com/nickthecook/ops'
|
12
12
|
s.files = Dir[
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ops_team
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nickthecook@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bcrypt_pbkdf
|
@@ -148,6 +148,8 @@ files:
|
|
148
148
|
- lib/action.rb
|
149
149
|
- lib/app_config.rb
|
150
150
|
- lib/builtin.rb
|
151
|
+
- lib/builtins/background.rb
|
152
|
+
- lib/builtins/background_log.rb
|
151
153
|
- lib/builtins/down.rb
|
152
154
|
- lib/builtins/env.rb
|
153
155
|
- lib/builtins/exec.rb
|