ops_team 1.9.0 → 1.11.0.pre.rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ops +1 -1
- data/lib/builtins/common/up_down.rb +68 -0
- data/lib/builtins/countdown.rb +2 -0
- data/lib/builtins/down.rb +4 -42
- data/lib/builtins/up.rb +4 -48
- data/lib/dependencies/custom.rb +3 -5
- data/lib/runner.rb +2 -0
- data/ops_team.gemspec +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35716d2bf91784127a89404ce9bc1a17b3a2998af4d247a96b530e05dac9ef57
|
4
|
+
data.tar.gz: 6621e93166e7a950f6ce0727ce050ef2b9bd3b71a4ea019ca8a0e57060702f78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e028c88f7c61166dde9b13bd759989563bbbbbcf6e965a231f9c3d96027699183aaf0f957bf956c8c14af3f6b8008a05cd38b47f1a743766e67b56206d22202e
|
7
|
+
data.tar.gz: '005046085d18c29d476275dbb2bef159872b495c8bfd963130b46d2d38884d26bef2929ff7340b3a948fda2fd7e666c4a4ad635dcd817082da1bb3b2dbe219a8'
|
data/bin/ops
CHANGED
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'require_all'
|
4
|
+
require_rel "../../dependencies"
|
5
|
+
|
6
|
+
require 'builtin'
|
7
|
+
require 'builtins/helpers/dependency_handler'
|
8
|
+
require 'output'
|
9
|
+
|
10
|
+
module Builtins
|
11
|
+
module Common
|
12
|
+
class UpDown < Builtin
|
13
|
+
class << self
|
14
|
+
def description
|
15
|
+
"attempts to meet dependencies listed in ops.yml"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
meet_dependencies
|
21
|
+
|
22
|
+
return true unless fail_on_error?
|
23
|
+
|
24
|
+
deps_to_meet.all?(&:success?)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def meet_dependencies
|
30
|
+
deps_to_meet.each do |dependency|
|
31
|
+
Output.status("[#{dependency.type}] #{dependency.name}")
|
32
|
+
|
33
|
+
meet_dependency(dependency)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def meet_dependency(dependency)
|
38
|
+
handle_dependency(dependency) if !dependency.met? || dependency.always_act?
|
39
|
+
|
40
|
+
if dependency.success?
|
41
|
+
Output.okay
|
42
|
+
else
|
43
|
+
Output.failed
|
44
|
+
Output.error("Error meeting #{dependency.type} dependency '#{dependency.name}':")
|
45
|
+
Output.out(dependency.output)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def deps_to_meet
|
50
|
+
@deps_to_meet ||= dependency_handler.dependencies.select(&:should_meet?)
|
51
|
+
end
|
52
|
+
|
53
|
+
def dependency_handler
|
54
|
+
Helpers::DependencyHandler.new(dependencies)
|
55
|
+
end
|
56
|
+
|
57
|
+
def dependencies
|
58
|
+
return @config["dependencies"] if @args.empty?
|
59
|
+
|
60
|
+
@config["dependencies"].select { |dep, _names| @args.include?(dep) }
|
61
|
+
end
|
62
|
+
|
63
|
+
def fail_on_error?
|
64
|
+
Options.get("up.fail_on_error") || false
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/builtins/countdown.rb
CHANGED
data/lib/builtins/down.rb
CHANGED
@@ -3,50 +3,12 @@
|
|
3
3
|
require 'require_all'
|
4
4
|
require_rel "../dependencies"
|
5
5
|
|
6
|
-
require '
|
7
|
-
require 'builtins/helpers/dependency_handler'
|
6
|
+
require 'builtins/common/up_down'
|
8
7
|
|
9
8
|
module Builtins
|
10
|
-
class Down <
|
11
|
-
|
12
|
-
|
13
|
-
"stops dependent services listed in ops.yml"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def run
|
18
|
-
# TODO: return a success/failure status to the caller
|
19
|
-
unmeet_dependencies
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def dependency_handler
|
25
|
-
Helpers::DependencyHandler.new(@config["dependencies"])
|
26
|
-
end
|
27
|
-
|
28
|
-
def unmeet_dependencies
|
29
|
-
dependency_handler.dependencies.each do |dependency|
|
30
|
-
# don't even output anything for dependencies that shouldn't be considered on this machine
|
31
|
-
next unless dependency.should_meet?
|
32
|
-
|
33
|
-
Output.status("[#{dependency.type}] #{dependency.name}")
|
34
|
-
|
35
|
-
unmeet_dependency(dependency)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def unmeet_dependency(dependency)
|
40
|
-
# TODO: make this simpler, and factor in `should_meet?` above, too
|
41
|
-
dependency.unmeet if dependency.met? || dependency.always_act?
|
42
|
-
|
43
|
-
if dependency.success?
|
44
|
-
Output.okay
|
45
|
-
else
|
46
|
-
Output.failed
|
47
|
-
Output.error("Error unmeeting #{dependency.type} dependency '#{dependency.name}':")
|
48
|
-
Output.out(dependency.output)
|
49
|
-
end
|
9
|
+
class Down < Common::UpDown
|
10
|
+
def handle_dependency(dependency)
|
11
|
+
dependency.unmeet
|
50
12
|
end
|
51
13
|
end
|
52
14
|
end
|
data/lib/builtins/up.rb
CHANGED
@@ -3,57 +3,13 @@
|
|
3
3
|
require 'require_all'
|
4
4
|
require_rel "../dependencies"
|
5
5
|
|
6
|
-
require '
|
7
|
-
require 'builtins/helpers/dependency_handler'
|
6
|
+
require 'builtins/common/up_down'
|
8
7
|
require 'output'
|
9
8
|
|
10
9
|
module Builtins
|
11
|
-
class Up <
|
12
|
-
|
13
|
-
|
14
|
-
"attempts to meet dependencies listed in ops.yml"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def run
|
19
|
-
# TODO: return a success/failure status to the caller
|
20
|
-
meet_dependencies
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def dependency_handler
|
26
|
-
Helpers::DependencyHandler.new(deps_to_meet)
|
27
|
-
end
|
28
|
-
|
29
|
-
def meet_dependencies
|
30
|
-
dependency_handler.dependencies.each do |dependency|
|
31
|
-
# don't even output anything for dependencies that shouldn't be considered on this machine
|
32
|
-
next unless dependency&.should_meet?
|
33
|
-
|
34
|
-
Output.status("[#{dependency.type}] #{dependency.name}")
|
35
|
-
|
36
|
-
meet_dependency(dependency)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def meet_dependency(dependency)
|
41
|
-
# TODO: make this simpler, and factor in `should_meet?` above, too
|
42
|
-
dependency.meet if !dependency.met? || dependency.always_act?
|
43
|
-
|
44
|
-
if dependency.success?
|
45
|
-
Output.okay
|
46
|
-
else
|
47
|
-
Output.failed
|
48
|
-
Output.error("Error meeting #{dependency.type} dependency '#{dependency.name}':")
|
49
|
-
Output.out(dependency.output)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def deps_to_meet
|
54
|
-
return @config["dependencies"] if @args.empty?
|
55
|
-
|
56
|
-
return @config["dependencies"].select { |dep, names| @args.include?(dep) }
|
10
|
+
class Up < Common::UpDown
|
11
|
+
def handle_dependency(dependency)
|
12
|
+
dependency.meet
|
57
13
|
end
|
58
14
|
end
|
59
15
|
end
|
data/lib/dependencies/custom.rb
CHANGED
@@ -31,19 +31,17 @@ module Dependencies
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def up_command
|
34
|
-
@up_command ||= @definition.is_a?(Hash) ? @config
|
34
|
+
@up_command ||= @definition.is_a?(Hash) ? @config&.dig("up") : name
|
35
35
|
end
|
36
36
|
|
37
37
|
def down_command
|
38
|
-
@down_command ||= @config
|
38
|
+
@down_command ||= @config && @config&.dig("down") || nil
|
39
39
|
end
|
40
40
|
|
41
41
|
def parse_definition
|
42
|
-
return @definition, {} if @definition.is_a?(String)
|
43
42
|
return @definition.first if @definition.is_a?(Hash)
|
44
43
|
|
45
|
-
|
46
|
-
"to be a String or a Hash; received #{@definition.class}."
|
44
|
+
[@definition.to_s, {}]
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
data/lib/runner.rb
CHANGED
data/ops_team.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'ops_team'
|
5
|
-
s.version = '1.
|
5
|
+
s.version = '1.11.0-rc2'
|
6
6
|
s.authors = [
|
7
7
|
'nickthecook@gmail.com'
|
8
8
|
]
|
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
|
|
16
16
|
'etc/*',
|
17
17
|
'lib/builtins/*',
|
18
18
|
'lib/builtins/helpers/*',
|
19
|
+
'lib/builtins/common/*',
|
19
20
|
'lib/dependencies/*',
|
20
21
|
'lib/dependencies/helpers/*',
|
21
22
|
'loader.rb',
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ops_team
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.11.0.pre.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nickthecook@gmail.com
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/builtin.rb
|
173
173
|
- lib/builtins/background.rb
|
174
174
|
- lib/builtins/background_log.rb
|
175
|
+
- lib/builtins/common/up_down.rb
|
175
176
|
- lib/builtins/countdown.rb
|
176
177
|
- lib/builtins/down.rb
|
177
178
|
- lib/builtins/env.rb
|
@@ -223,9 +224,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
224
|
version: '2.5'
|
224
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
226
|
requirements:
|
226
|
-
- - "
|
227
|
+
- - ">"
|
227
228
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
229
|
+
version: 1.3.1
|
229
230
|
requirements: []
|
230
231
|
rubygems_version: 3.0.3.1
|
231
232
|
signing_key:
|