ops_team 0.3.0 → 0.7.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/app_config.rb +18 -2
- data/lib/builtins/help.rb +4 -1
- data/lib/environment.rb +20 -5
- data/lib/ops.rb +3 -7
- data/lib/secrets.rb +11 -9
- 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: 011b0f2a12af0a58c9b48f53d2dd59b9a753eab0acd221ee2675c296c7b109d0
|
4
|
+
data.tar.gz: 157963863ac30030921804a37f57ab332502ba465ac9c4ea139b18a297f0618e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ce81eacd3adb1f7416a96adeabc38b244919ef8e8b17b349cea60e21a68535cc7aaeca57d8af1fb9fb1a03f7b94e98d423f018c2ecd2e9a4da556234ea64f65
|
7
|
+
data.tar.gz: 0e0b772bdd70841e197079c93124f53a0d61ea8558add16a4b89e2e7340a1dbeba58222a3631165c03ed3ea35c85c7c596f9834aa0ba3e0445196b27b35e3f41
|
data/lib/app_config.rb
CHANGED
@@ -1,6 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class AppConfig
|
4
|
+
class << self
|
5
|
+
def load
|
6
|
+
new(app_config_path).load
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def app_config_path
|
12
|
+
expand_path(Options.get("config.path"))
|
13
|
+
end
|
14
|
+
|
15
|
+
def expand_path(path)
|
16
|
+
`echo #{path}`.chomp
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
4
20
|
def initialize(filename = "")
|
5
21
|
@filename = filename.empty? ? default_filename : filename
|
6
22
|
end
|
@@ -18,8 +34,8 @@ class AppConfig
|
|
18
34
|
end
|
19
35
|
|
20
36
|
def config
|
21
|
-
@config ||= file_contents ?
|
22
|
-
rescue
|
37
|
+
@config ||= file_contents ? YAML.safe_load(file_contents) : {}
|
38
|
+
rescue YAML::SyntaxError => e
|
23
39
|
Output.error("Error parsing config data: #{e}")
|
24
40
|
{}
|
25
41
|
end
|
data/lib/builtins/help.rb
CHANGED
@@ -35,7 +35,10 @@ module Builtins
|
|
35
35
|
|
36
36
|
def actions
|
37
37
|
@config["actions"].map do |name, value|
|
38
|
-
format("%<name>-35s %<desc>s",
|
38
|
+
format("%<name>-35s %<desc>s",
|
39
|
+
name: name.yellow,
|
40
|
+
desc: value["description"] || value["command"]
|
41
|
+
)
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
data/lib/environment.rb
CHANGED
@@ -6,11 +6,8 @@ class Environment
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def set_variables
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
ENV['environment'] = environment
|
9
|
+
set_environment_aliases
|
10
|
+
set_configured_variables
|
14
11
|
end
|
15
12
|
|
16
13
|
def environment
|
@@ -18,4 +15,22 @@ class Environment
|
|
18
15
|
|
19
16
|
ENV['environment']
|
20
17
|
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def set_environment_aliases
|
22
|
+
environment_aliases.each do |alias_name|
|
23
|
+
ENV[alias_name] = environment
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def environment_aliases
|
28
|
+
Options.get("environment_aliases") || ['environment']
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_configured_variables
|
32
|
+
@env_hash.each do |key, value|
|
33
|
+
ENV[key] = `echo #{value}`.chomp
|
34
|
+
end
|
35
|
+
end
|
21
36
|
end
|
data/lib/ops.rb
CHANGED
@@ -49,11 +49,11 @@ class Ops
|
|
49
49
|
|
50
50
|
def run_action
|
51
51
|
environment.set_variables
|
52
|
-
|
52
|
+
AppConfig.load
|
53
53
|
|
54
54
|
return builtin.run if builtin
|
55
55
|
|
56
|
-
Output.warn("Running '#{action}' from #{CONFIG_FILE}...")
|
56
|
+
Output.warn("Running '#{action}' from #{CONFIG_FILE} in environment '#{ENV['environment']}'...")
|
57
57
|
action.run
|
58
58
|
end
|
59
59
|
|
@@ -106,12 +106,8 @@ class Ops
|
|
106
106
|
@environment ||= Environment.new(env_vars)
|
107
107
|
end
|
108
108
|
|
109
|
-
def app_config_file
|
110
|
-
`echo #{Options.get("config.path")}`.chomp
|
111
|
-
end
|
112
|
-
|
113
109
|
def app_config
|
114
|
-
@app_config ||= AppConfig.new
|
110
|
+
@app_config ||= AppConfig.new
|
115
111
|
end
|
116
112
|
end
|
117
113
|
|
data/lib/secrets.rb
CHANGED
@@ -8,23 +8,21 @@ require 'options'
|
|
8
8
|
|
9
9
|
class Secrets < AppConfig
|
10
10
|
class << self
|
11
|
-
def load
|
12
|
-
Secrets.new(expand_path(Options.get("secrets.path"))).load
|
13
|
-
end
|
14
|
-
|
15
11
|
private
|
16
12
|
|
17
|
-
def
|
18
|
-
|
13
|
+
def app_config_path
|
14
|
+
expand_path(Options.get("secrets.path"))
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
18
|
+
def initialize(filename = "")
|
19
|
+
@filename = filename.empty? ? default_filename : actual_filename_for(filename)
|
20
|
+
end
|
21
|
+
|
22
22
|
private
|
23
23
|
|
24
24
|
def default_filename
|
25
|
-
|
26
|
-
|
27
|
-
default_json_filename
|
25
|
+
File.exist?(default_ejson_filename) ? default_ejson_filename : default_json_filename
|
28
26
|
end
|
29
27
|
|
30
28
|
def default_ejson_filename
|
@@ -35,6 +33,10 @@ class Secrets < AppConfig
|
|
35
33
|
"config/#{environment}/secrets.json"
|
36
34
|
end
|
37
35
|
|
36
|
+
def actual_filename_for(filename)
|
37
|
+
File.exist?(filename) ? filename : filename.sub(".ejson", ".json")
|
38
|
+
end
|
39
|
+
|
38
40
|
def file_contents
|
39
41
|
@file_contents ||= @filename.match(/\.ejson$/) ? `ejson decrypt #{@filename}` : super
|
40
42
|
end
|
data/ops_team.gemspec
CHANGED