ops_team 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/action.rb +17 -12
- data/lib/action_list.rb +1 -1
- data/lib/ops.rb +1 -1
- data/lib/runner.rb +17 -2
- data/ops_team.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf24d85630158410b50202a7ccae33b7faecdd649a4a259aa3a69e5b4d245d1a
|
4
|
+
data.tar.gz: 494af1f1ba4e0e75544be49cb0adba5b8178dcb17aaeb9fae878cb67b2ac7b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31e68329d30149ce528c43f12a1eca82312dc9032b8a4c55d7321cbac32f093b193f87505bbd56f1d09e08e02b93aa274e3b6c7f880293cae70d33c4289e8e09
|
7
|
+
data.tar.gz: 3d0c41e1a1dd6f36d53a5d020cfd318abfc50405bea0ae9781e82a264d82bc6c2a3e64a4b9abf952e20485b57e9a45e0a417abaceab14adad9c3ef1ed836196d
|
data/lib/action.rb
CHANGED
@@ -5,18 +5,15 @@ require 'secrets'
|
|
5
5
|
# represents one action to be performed in the shell
|
6
6
|
# can assemble a command line from a command and args
|
7
7
|
class Action
|
8
|
-
|
8
|
+
attr_reader :name
|
9
9
|
|
10
|
-
def initialize(config, args)
|
10
|
+
def initialize(name, config, args)
|
11
|
+
@name = name
|
11
12
|
@config = config
|
12
13
|
@args = args
|
13
14
|
end
|
14
15
|
|
15
16
|
def run
|
16
|
-
unless allowed_in_current_env?
|
17
|
-
raise NotAllowedInEnvError, "Action not allowed in #{Environment.environment} environment."
|
18
|
-
end
|
19
|
-
|
20
17
|
if perform_shell_expansion?
|
21
18
|
Kernel.exec(to_s)
|
22
19
|
else
|
@@ -62,6 +59,18 @@ class Action
|
|
62
59
|
@config["load_secrets"].nil? ? false : @config["load_secrets"]
|
63
60
|
end
|
64
61
|
|
62
|
+
def execute_in_env?(env)
|
63
|
+
!skip_in_envs.include?(env)
|
64
|
+
end
|
65
|
+
|
66
|
+
def allowed_in_env?(env)
|
67
|
+
return false if not_in_envs.include?(env)
|
68
|
+
|
69
|
+
return false if in_envs.any? && !in_envs.include?(env)
|
70
|
+
|
71
|
+
true
|
72
|
+
end
|
73
|
+
|
65
74
|
private
|
66
75
|
|
67
76
|
def to_a
|
@@ -76,12 +85,8 @@ class Action
|
|
76
85
|
@config["in_envs"] || []
|
77
86
|
end
|
78
87
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
return false if in_envs.any? && !in_envs.include?(Environment.environment)
|
83
|
-
|
84
|
-
true
|
88
|
+
def skip_in_envs
|
89
|
+
@config["skip_in_envs"] || []
|
85
90
|
end
|
86
91
|
|
87
92
|
def perform_shell_expansion?
|
data/lib/action_list.rb
CHANGED
data/lib/ops.rb
CHANGED
@@ -59,7 +59,7 @@ class Ops
|
|
59
59
|
rescue AppConfig::ParsingError => e
|
60
60
|
Output.error("Error parsing app config: #{e}")
|
61
61
|
exit(ERROR_LOADING_APP_CONFIG_EXIT_CODE)
|
62
|
-
rescue
|
62
|
+
rescue Runner::NotAllowedInEnvError => e
|
63
63
|
Output.error("Error running action #{@action_name}: #{e}")
|
64
64
|
exit(ACTION_NOT_ALLOWED_IN_ENV_EXIT_CODE)
|
65
65
|
end
|
data/lib/runner.rb
CHANGED
@@ -10,6 +10,7 @@ require 'environment'
|
|
10
10
|
class Runner
|
11
11
|
class UnknownActionError < StandardError; end
|
12
12
|
class ActionConfigError < StandardError; end
|
13
|
+
class NotAllowedInEnvError < StandardError; end
|
13
14
|
|
14
15
|
def initialize(action_name, args, config, config_path)
|
15
16
|
@action_name = action_name
|
@@ -29,8 +30,8 @@ class Runner
|
|
29
30
|
raise ActionConfigError, action.config_errors.join("; ") unless action.config_valid?
|
30
31
|
|
31
32
|
do_before_action
|
32
|
-
|
33
|
-
|
33
|
+
|
34
|
+
run_action
|
34
35
|
end
|
35
36
|
|
36
37
|
def suggestions
|
@@ -72,6 +73,20 @@ class Runner
|
|
72
73
|
@forward ||= Forwards.new(@config, @args).get(@action_name)
|
73
74
|
end
|
74
75
|
|
76
|
+
def run_action
|
77
|
+
unless action.allowed_in_env?(Environment.environment)
|
78
|
+
raise NotAllowedInEnvError, "Action not allowed in #{Environment.environment} environment."
|
79
|
+
end
|
80
|
+
|
81
|
+
unless action.execute_in_env?(Environment.environment)
|
82
|
+
Output.warn("Skipping action '#{action.name}' in environment #{Environment.environment}.")
|
83
|
+
return true
|
84
|
+
end
|
85
|
+
|
86
|
+
Output.notice("Running '#{action}' in environment '#{ENV['environment']}'...")
|
87
|
+
action.run
|
88
|
+
end
|
89
|
+
|
75
90
|
def action
|
76
91
|
return action_list.get(@action_name) if action_list.get(@action_name)
|
77
92
|
return action_list.get_by_alias(@action_name) if action_list.get_by_alias(@action_name)
|
data/ops_team.gemspec
CHANGED
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ops_team
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.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
11
|
date: 2021-05-05 00:00:00.000000000 Z
|
@@ -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: []
|
@@ -212,7 +212,7 @@ homepage: https://github.com/nickthecook/ops
|
|
212
212
|
licenses:
|
213
213
|
- GPL-3.0-only
|
214
214
|
metadata: {}
|
215
|
-
post_install_message:
|
215
|
+
post_install_message:
|
216
216
|
rdoc_options: []
|
217
217
|
require_paths:
|
218
218
|
- lib
|
@@ -227,8 +227,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
229
|
requirements: []
|
230
|
-
rubygems_version: 3.2.
|
231
|
-
signing_key:
|
230
|
+
rubygems_version: 3.2.22
|
231
|
+
signing_key:
|
232
232
|
specification_version: 4
|
233
233
|
summary: ops_team handles basic automation for your project, driven by self-documenting
|
234
234
|
YAML config
|