ops_team 0.17.1 → 0.18.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 +22 -0
- data/lib/ops.rb +4 -0
- data/ops_team.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fe720771051eb12c4f6786c7a9409d8e2ab01e592abb7959349ceba74f47eed
|
4
|
+
data.tar.gz: d2fdd069587db893f74d599abf875d15dcad4a09c19b94169496527ba462c77f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48f067fd6e9379a1b40830defed7652301786020310137c1be4349e8abb5ab45eae478084b6614d807e10db6738531fb1f169c44146445fed77c1b517eabdba5
|
7
|
+
data.tar.gz: 32d83b0e2cf94f4178f577b3fbc2b9d232bd10f1de3370f5d516fac9e98f86abe1401749428a486c1f436d0d4646ad332f88701e889ac75764e432978f634000
|
data/lib/action.rb
CHANGED
@@ -5,12 +5,18 @@ 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
|
+
class NotAllowedInEnvError < StandardError; end
|
9
|
+
|
8
10
|
def initialize(config, args)
|
9
11
|
@config = config
|
10
12
|
@args = args
|
11
13
|
end
|
12
14
|
|
13
15
|
def run
|
16
|
+
unless allowed_in_current_env?
|
17
|
+
raise NotAllowedInEnvError, "Action not allowed in #{Environment.environment} environment."
|
18
|
+
end
|
19
|
+
|
14
20
|
Secrets.load if load_secrets?
|
15
21
|
|
16
22
|
Kernel.exec(to_s)
|
@@ -55,4 +61,20 @@ class Action
|
|
55
61
|
def load_secrets?
|
56
62
|
@config["load_secrets"]
|
57
63
|
end
|
64
|
+
|
65
|
+
def not_in_envs
|
66
|
+
@config["not_in_envs"] || []
|
67
|
+
end
|
68
|
+
|
69
|
+
def in_envs
|
70
|
+
@config["in_envs"] || []
|
71
|
+
end
|
72
|
+
|
73
|
+
def allowed_in_current_env?
|
74
|
+
return false if not_in_envs.include?(Environment.environment)
|
75
|
+
|
76
|
+
return false if in_envs.any? && !in_envs.include?(Environment.environment)
|
77
|
+
|
78
|
+
true
|
79
|
+
end
|
58
80
|
end
|
data/lib/ops.rb
CHANGED
@@ -29,6 +29,7 @@ class Ops
|
|
29
29
|
MIN_VERSION_NOT_MET_EXIT_CODE = 67
|
30
30
|
ACTION_CONFIG_ERROR_EXIT_CODE = 68
|
31
31
|
BUILTIN_SYNTAX_ERROR_EXIT_CODE = 69
|
32
|
+
ACTION_NOT_ALLOWED_IN_ENV_EXIT_CODE = 70
|
32
33
|
|
33
34
|
RECOMMEND_HELP_TEXT = "Run 'ops help' for a list of builtins and actions."
|
34
35
|
|
@@ -115,6 +116,9 @@ class Ops
|
|
115
116
|
rescue AppConfig::ParsingError => e
|
116
117
|
Output.error("Error parsing app config: #{e}")
|
117
118
|
exit(ERROR_LOADING_APP_CONFIG_EXIT_CODE)
|
119
|
+
rescue Action::NotAllowedInEnvError => e
|
120
|
+
Output.error("Error running action #{@action_name}: #{e}")
|
121
|
+
exit(ACTION_NOT_ALLOWED_IN_ENV_EXIT_CODE)
|
118
122
|
end
|
119
123
|
|
120
124
|
def do_before_all
|
data/ops_team.gemspec
CHANGED