ops_team 1.10.0 → 1.11.0

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: 21ea800cf1d407a6b9e372b422ac29ae6e7ace9597e55181aaef981290382dca
4
- data.tar.gz: 37f00565ecdcfa789df0022a83352966e2c54080979321d82baaa2a0e99868aa
3
+ metadata.gz: 58e624e071ff1192e4f1d53d3a76135f0cb93feb43730531012944c245109a5f
4
+ data.tar.gz: 55a945d92fc66f60ff5dce922a734d93e3ec74973d97505357efb1c57d0d7a76
5
5
  SHA512:
6
- metadata.gz: 6f5a443b2cc90a6d390a4f8f8805e1ab7236af5a04921177569ae8f64d7288295a83823606cbbc4402be419152a1ae2072e7704b846ee2653191d86bcb2be4ef
7
- data.tar.gz: af770963d44d9eca6140d033626751143de5561625fb4180906350eeb0b6c36391c0193267e7ed32c37ce0f47ccc70a332561ed011ccf126538c04badc543146
6
+ metadata.gz: a1b19fb48de6a17dc8430bd09855ae94483117562ab6c725870abcacf72df86dad737ffb4cdbfe1b0d1c1290acf27c466194c39b88f6b98b833cfe2b61a5b43b
7
+ data.tar.gz: fbae4f1f500e1d9ef96a1befc963111bfc28a32d3c7da2bc5e0c1a4a8e8e9ad2c5308eb3c3adaa58b3c55b5ce6e9f59e47482cb5e5e6c629a32dd74d35c7b14d
data/bin/ops CHANGED
@@ -28,4 +28,4 @@ end
28
28
  require_relative "../loader"
29
29
  require 'ops'
30
30
 
31
- Ops.new(ARGV, config_file: options[:file]).run
31
+ exit Ops.new(ARGV, config_file: options[:file]).run
@@ -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
@@ -25,6 +25,8 @@ module Builtins
25
25
  timer_task.shutdown if task_complete?
26
26
  end
27
27
  Output.out("\rCountdown complete after #{sleep_seconds}s.")
28
+
29
+ true
28
30
  end
29
31
 
30
32
  private
data/lib/builtins/down.rb CHANGED
@@ -3,56 +3,12 @@
3
3
  require 'require_all'
4
4
  require_rel "../dependencies"
5
5
 
6
- require 'builtin'
7
- require 'builtins/helpers/dependency_handler'
6
+ require 'builtins/common/up_down'
8
7
 
9
8
  module Builtins
10
- class Down < Builtin
11
- class << self
12
- def description
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(deps_to_meet)
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
50
- end
51
-
52
- def deps_to_meet
53
- return @config["dependencies"] if @args.empty?
54
-
55
- return @config["dependencies"].select { |dep, names| @args.include?(dep) }
9
+ class Down < Common::UpDown
10
+ def handle_dependency(dependency)
11
+ dependency.unmeet
56
12
  end
57
13
  end
58
14
  end
data/lib/builtins/env.rb CHANGED
@@ -13,6 +13,8 @@ module Builtins
13
13
 
14
14
  def run
15
15
  Output.print(environment)
16
+
17
+ true
16
18
  end
17
19
 
18
20
  def environment
@@ -20,6 +20,8 @@ module Builtins
20
20
 
21
21
  output_key_summary(source_only_keys, source_env, dest_env) if source_only_keys.any?
22
22
  output_key_summary(dest_only_keys, dest_env, source_env) if dest_only_keys.any?
23
+
24
+ true
23
25
  end
24
26
 
25
27
  private
data/lib/builtins/exec.rb CHANGED
@@ -20,6 +20,7 @@ module Builtins
20
20
  Kernel.exec(args.join(" "))
21
21
  else
22
22
  Output.error("Usage: ops exec '<command>'")
23
+ false
23
24
  end
24
25
  end
25
26
  end
data/lib/builtins/help.rb CHANGED
@@ -25,6 +25,8 @@ module Builtins
25
25
  Output.out("")
26
26
  Output.out("Actions:")
27
27
  Output.out(" #{actions.join("\n ")}")
28
+
29
+ true
28
30
  end
29
31
 
30
32
  private
data/lib/builtins/init.rb CHANGED
@@ -21,10 +21,14 @@ module Builtins
21
21
  def run
22
22
  if File.exist?(OPS_YML)
23
23
  Output.error("File '#{OPS_YML} exists; not initializing.")
24
- else
25
- Output.out("Creating '#{OPS_YML} from template...")
26
- FileUtils.cp(template_path, OPS_YML)
24
+
25
+ return false
27
26
  end
27
+
28
+ Output.out("Creating '#{OPS_YML} from template...")
29
+ FileUtils.cp(template_path, OPS_YML)
30
+
31
+ true
28
32
  rescue SystemCallError
29
33
  Output.error(template_not_found_message)
30
34
  exit 1
data/lib/builtins/up.rb CHANGED
@@ -3,57 +3,13 @@
3
3
  require 'require_all'
4
4
  require_rel "../dependencies"
5
5
 
6
- require 'builtin'
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 < Builtin
12
- class << self
13
- def description
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
@@ -13,6 +13,8 @@ module Builtins
13
13
 
14
14
  def run
15
15
  Output.out(::Version.version)
16
+
17
+ true
16
18
  end
17
19
  end
18
20
  end
@@ -39,11 +39,9 @@ module Dependencies
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
- raise CustomConfigError, "Expected custom dependency @definition '#{@definition}' " \
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
@@ -9,7 +9,9 @@ require 'environment'
9
9
 
10
10
  class Runner
11
11
  class UnknownActionError < StandardError; end
12
+
12
13
  class ActionConfigError < StandardError; end
14
+
13
15
  class NotAllowedInEnvError < StandardError; end
14
16
 
15
17
  def initialize(action_name, args, config, config_path)
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 = '1.10.0'
5
+ s.version = '1.11.0'
6
6
  s.authors = [
7
7
  'nickthecook@gmail.com'
8
8
  ]
9
- s.date = '2021-05-05'
9
+ s.date = '2021-10-25'
10
10
  s.summary = 'ops_team handles basic automation for your project, driven by self-documenting YAML config'
11
11
  s.homepage = 'https://github.com/nickthecook/ops'
12
12
  s.files = Dir[
@@ -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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ops_team
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bcrypt_pbkdf
@@ -114,22 +114,22 @@ dependencies:
114
114
  name: net-ssh
115
115
  requirement: !ruby/object:Gem::Requirement
116
116
  requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: 6.1.0
120
117
  - - "~>"
121
118
  - !ruby/object:Gem::Version
122
119
  version: '6.1'
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: 6.1.0
123
123
  type: :runtime
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
126
126
  requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- version: 6.1.0
130
127
  - - "~>"
131
128
  - !ruby/object:Gem::Version
132
129
  version: '6.1'
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: 6.1.0
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: require_all
135
135
  requirement: !ruby/object:Gem::Requirement
@@ -150,8 +150,8 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: 1.1.6
153
- description:
154
- email:
153
+ description:
154
+ email:
155
155
  executables:
156
156
  - ops
157
157
  extensions: []
@@ -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
@@ -212,7 +213,7 @@ homepage: https://github.com/nickthecook/ops
212
213
  licenses:
213
214
  - GPL-3.0-only
214
215
  metadata: {}
215
- post_install_message:
216
+ post_install_message:
216
217
  rdoc_options: []
217
218
  require_paths:
218
219
  - lib
@@ -227,8 +228,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
228
  - !ruby/object:Gem::Version
228
229
  version: '0'
229
230
  requirements: []
230
- rubygems_version: 3.0.3.1
231
- signing_key:
231
+ rubygems_version: 3.2.22
232
+ signing_key:
232
233
  specification_version: 4
233
234
  summary: ops_team handles basic automation for your project, driven by self-documenting
234
235
  YAML config