ops_team 0.2.3 → 0.2.4
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/bin/print_config +4 -0
- data/lib/action.rb +1 -1
- data/lib/app_config.rb +38 -0
- data/lib/builtins/down.rb +1 -1
- data/lib/builtins/up.rb +1 -1
- data/lib/ops.rb +9 -0
- data/lib/secrets.rb +3 -23
- data/ops_team.gemspec +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb200091bd81044096f650bc1647958dd129b12b14c309516b7e7ce0324e8889
|
4
|
+
data.tar.gz: 0edf7442cd2106ac2de48b6c14d16510111fa10759fe320aaea1856f366c8703
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0379eecf548037718aebf63b722f9571f21410daafd13a6b9ae893cfe7d3fbd3c0a58c40ea10dd1ac35d52c1de580894a774859755185dd8c32eb130db6d31fc'
|
7
|
+
data.tar.gz: 6e08799eb7cf0c196c88e93ecd68f7d48beedd803291d07b362750c9d738785736e9db49ca3c02d180544efa731f7064d5b5537016db8427b826e8057e4a2210
|
data/bin/print_config
ADDED
data/lib/action.rb
CHANGED
data/lib/app_config.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class AppConfig
|
4
|
+
def initialize(filename = "")
|
5
|
+
@filename = filename.empty? ? default_filename : filename
|
6
|
+
end
|
7
|
+
|
8
|
+
def load
|
9
|
+
config['environment']&.each do |key, value|
|
10
|
+
ENV[key] = value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def default_filename
|
17
|
+
"config/#{environment}/config.json"
|
18
|
+
end
|
19
|
+
|
20
|
+
def config
|
21
|
+
@config ||= file_contents ? JSON.parse(file_contents) : {}
|
22
|
+
rescue JSON::ParserError => e
|
23
|
+
Output.error("Error parsing config data: #{e}")
|
24
|
+
{}
|
25
|
+
end
|
26
|
+
|
27
|
+
def file_contents
|
28
|
+
@file_contents ||= begin
|
29
|
+
File.open(@filename).read
|
30
|
+
rescue Errno::ENOENT
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def environment
|
36
|
+
ENV['environment']
|
37
|
+
end
|
38
|
+
end
|
data/lib/builtins/down.rb
CHANGED
data/lib/builtins/up.rb
CHANGED
data/lib/ops.rb
CHANGED
@@ -29,6 +29,7 @@ class Ops
|
|
29
29
|
exit(INVALID_SYNTAX_EXIT_CODE) unless syntax_valid?
|
30
30
|
|
31
31
|
environment.set_variables
|
32
|
+
app_config.load
|
32
33
|
|
33
34
|
return builtin.run if builtin
|
34
35
|
|
@@ -102,6 +103,14 @@ class Ops
|
|
102
103
|
def environment
|
103
104
|
@environment ||= Environment.new(env_vars)
|
104
105
|
end
|
106
|
+
|
107
|
+
def app_config_file
|
108
|
+
`echo #{@options&.dig("config", "path")}`.chomp
|
109
|
+
end
|
110
|
+
|
111
|
+
def app_config
|
112
|
+
@app_config ||= AppConfig.new(app_config_file)
|
113
|
+
end
|
105
114
|
end
|
106
115
|
|
107
116
|
Ops.new(ARGV).run if $PROGRAM_NAME == __FILE__
|
data/lib/secrets.rb
CHANGED
@@ -3,18 +3,9 @@
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
require 'output'
|
6
|
+
require 'app_config'
|
6
7
|
|
7
|
-
class Secrets
|
8
|
-
def initialize(filename = "")
|
9
|
-
@filename = filename.empty? ? default_filename : filename
|
10
|
-
end
|
11
|
-
|
12
|
-
def load
|
13
|
-
secrets['environment']&.each do |key, value|
|
14
|
-
ENV[key] = value
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
8
|
+
class Secrets < AppConfig
|
18
9
|
private
|
19
10
|
|
20
11
|
def default_filename
|
@@ -31,18 +22,7 @@ class Secrets
|
|
31
22
|
"config/#{environment}/secrets.json"
|
32
23
|
end
|
33
24
|
|
34
|
-
def secrets
|
35
|
-
@secrets ||= JSON.parse(file_contents)
|
36
|
-
rescue JSON::ParserError => e
|
37
|
-
Output.error("Error parsing secrets data: #{e}")
|
38
|
-
{}
|
39
|
-
end
|
40
|
-
|
41
25
|
def file_contents
|
42
|
-
@filename.match(/\.ejson$/) ? `ejson decrypt #{@filename}` :
|
43
|
-
end
|
44
|
-
|
45
|
-
def environment
|
46
|
-
ENV['environment']
|
26
|
+
@file_contents ||= @filename.match(/\.ejson$/) ? `ejson decrypt #{@filename}` : super
|
47
27
|
end
|
48
28
|
end
|
data/ops_team.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ops_team
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nickthecook@gmail.com
|
@@ -59,12 +59,14 @@ extra_rdoc_files: []
|
|
59
59
|
files:
|
60
60
|
- Gemfile
|
61
61
|
- bin/ops
|
62
|
+
- bin/print_config
|
62
63
|
- bin/print_secrets
|
63
64
|
- bin/tag
|
64
65
|
- etc/ops.template.yml
|
65
66
|
- etc/ruby.template.yml
|
66
67
|
- etc/terraform.template.yml
|
67
68
|
- lib/action.rb
|
69
|
+
- lib/app_config.rb
|
68
70
|
- lib/builtin.rb
|
69
71
|
- lib/builtins/down.rb
|
70
72
|
- lib/builtins/env.rb
|