ops_team 0.15.0 → 0.18.0
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 +22 -0
- data/lib/action_list.rb +5 -1
- data/lib/builtins/envdiff.rb +17 -5
- data/lib/builtins/help.rb +10 -4
- data/lib/environment.rb +4 -0
- data/lib/ops.rb +11 -3
- data/ops_team.gemspec +1 -1
- metadata +6 -6
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/action_list.rb
CHANGED
@@ -28,11 +28,15 @@ class ActionList
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
def actions_list
|
32
|
+
@actions_list ||= []
|
33
|
+
end
|
34
|
+
|
31
35
|
def process_action_list
|
32
36
|
@actions = {}
|
33
37
|
@aliases = {}
|
34
38
|
|
35
|
-
|
39
|
+
actions_list.each do |name, config|
|
36
40
|
action = Action.new(config, @args)
|
37
41
|
|
38
42
|
@actions[name] = action
|
data/lib/builtins/envdiff.rb
CHANGED
@@ -49,21 +49,29 @@ module Builtins
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def keys_for(env)
|
52
|
-
|
52
|
+
tagged_config_keys_for(env) + tagged_secrets_keys_for(env)
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
(
|
55
|
+
def tagged_config_keys_for(env)
|
56
|
+
config_keys_for(env).map do |key|
|
57
57
|
"[CONFIG] #{key}"
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
62
|
-
(
|
61
|
+
def tagged_secrets_keys_for(env)
|
62
|
+
secrets_keys_for(env).map do |key|
|
63
63
|
"[SECRET] #{key}"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
+
def config_keys_for(env)
|
68
|
+
(config_for(env)["environment"]&.keys || []) - ignored_keys
|
69
|
+
end
|
70
|
+
|
71
|
+
def secrets_keys_for(env)
|
72
|
+
(secrets_for(env)["environment"]&.keys || []) - ignored_keys
|
73
|
+
end
|
74
|
+
|
67
75
|
def config_for(env)
|
68
76
|
YAML.load_file(config_path_for(env))
|
69
77
|
end
|
@@ -111,6 +119,10 @@ module Builtins
|
|
111
119
|
def secrets_path_for(env)
|
112
120
|
Secrets.config_path_for(env)
|
113
121
|
end
|
122
|
+
|
123
|
+
def ignored_keys
|
124
|
+
Options.get("envdiff.ignored_keys") || []
|
125
|
+
end
|
114
126
|
end
|
115
127
|
|
116
128
|
Envdiff = EnvDiff
|
data/lib/builtins/help.rb
CHANGED
@@ -54,12 +54,18 @@ module Builtins
|
|
54
54
|
def actions
|
55
55
|
return [] unless @config["actions"]
|
56
56
|
|
57
|
-
@config["actions"].map do |name,
|
58
|
-
format("%<name>-
|
59
|
-
name: name.yellow,
|
60
|
-
desc:
|
57
|
+
@config["actions"].map do |name, action_config|
|
58
|
+
format("%<name>-40s %<desc>s",
|
59
|
+
name: "#{name.yellow} #{alias_string_for(action_config)}",
|
60
|
+
desc: action_config["description"] || action_config["command"]
|
61
61
|
)
|
62
62
|
end.sort
|
63
63
|
end
|
64
|
+
|
65
|
+
def alias_string_for(action_config)
|
66
|
+
return "[#{action_config["alias"]}]" if action_config["alias"]
|
67
|
+
|
68
|
+
""
|
69
|
+
end
|
64
70
|
end
|
65
71
|
end
|
data/lib/environment.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'version'
|
4
|
+
require 'secrets'
|
5
|
+
require 'app_config'
|
4
6
|
|
5
7
|
class Environment
|
6
8
|
class << self
|
@@ -26,6 +28,8 @@ class Environment
|
|
26
28
|
def set_ops_variables
|
27
29
|
ENV["OPS_YML_DIR"] = Dir.pwd
|
28
30
|
ENV["OPS_VERSION"] = Version.version.to_s
|
31
|
+
ENV["OPS_SECRETS_FILE"] = Secrets.config_path_for(Environment.environment)
|
32
|
+
ENV["OPS_CONFIG_FILE"] = AppConfig.config_path_for(Environment.environment)
|
29
33
|
end
|
30
34
|
|
31
35
|
def set_environment_aliases
|
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
|
@@ -161,8 +165,12 @@ class Ops
|
|
161
165
|
|
162
166
|
def config
|
163
167
|
@config ||= begin
|
164
|
-
|
165
|
-
|
168
|
+
if File.exist?(CONFIG_FILE)
|
169
|
+
YAML.load_file(CONFIG_FILE)
|
170
|
+
else
|
171
|
+
Output.warn("File '#{CONFIG_FILE}' does not exist.") unless @action_name == "init"
|
172
|
+
{}
|
173
|
+
end
|
166
174
|
rescue StandardError => e
|
167
175
|
Output.warn("Error parsing '#{CONFIG_FILE}': #{e}")
|
168
176
|
{}
|
@@ -170,7 +178,7 @@ class Ops
|
|
170
178
|
end
|
171
179
|
|
172
180
|
def env_vars
|
173
|
-
|
181
|
+
config.dig("options", "environment") || {}
|
174
182
|
end
|
175
183
|
|
176
184
|
def environment
|
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: 0.
|
4
|
+
version: 0.18.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: 2020-08-12 00:00:00.000000000 Z
|
@@ -130,8 +130,8 @@ dependencies:
|
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: 1.1.6
|
133
|
-
description:
|
134
|
-
email:
|
133
|
+
description:
|
134
|
+
email:
|
135
135
|
executables:
|
136
136
|
- ops
|
137
137
|
extensions: []
|
@@ -187,7 +187,7 @@ homepage: https://github.com/nickthecook/ops
|
|
187
187
|
licenses:
|
188
188
|
- GPL-3.0-only
|
189
189
|
metadata: {}
|
190
|
-
post_install_message:
|
190
|
+
post_install_message:
|
191
191
|
rdoc_options: []
|
192
192
|
require_paths:
|
193
193
|
- lib
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
205
|
rubygems_version: 3.0.3
|
206
|
-
signing_key:
|
206
|
+
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: ops_team handles basic operations tasks for your project, driven by YAML
|
209
209
|
config
|