ops_team 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3df06362d31ad96870848712991804c147d63f780395587ea7237eacabfbb683
4
- data.tar.gz: d125dfaa4423fa07eae13672f5c045f064b084f2c7c05db3e76ab5088b92f410
3
+ metadata.gz: fb200091bd81044096f650bc1647958dd129b12b14c309516b7e7ce0324e8889
4
+ data.tar.gz: 0edf7442cd2106ac2de48b6c14d16510111fa10759fe320aaea1856f366c8703
5
5
  SHA512:
6
- metadata.gz: 8e7f27173645a685d1146c9a8e73565c9cee017e0bdeb834db0258f17b4e9d655d2f19949b386f4b401818ef37d45e4c3552c31b19571c580de0f6c60b3d4638
7
- data.tar.gz: 6f5e9398f184381b503cf579b7e8468db32a5ce9707b6f6818b9f55b6fba94054a96fbfa6d99fc7b0bce0159f63fbf92f53506712fafebe925622753b143eae1
6
+ metadata.gz: '0379eecf548037718aebf63b722f9571f21410daafd13a6b9ae893cfe7d3fbd3c0a58c40ea10dd1ac35d52c1de580894a774859755185dd8c32eb130db6d31fc'
7
+ data.tar.gz: 6e08799eb7cf0c196c88e93ecd68f7d48beedd803291d07b362750c9d738785736e9db49ca3c02d180544efa731f7064d5b5537016db8427b826e8057e4a2210
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ echo $KEY1
4
+ echo $KEY2
@@ -44,6 +44,6 @@ class Action
44
44
  end
45
45
 
46
46
  def secrets_file
47
- `echo -n #{@options&.dig("secrets", "path")}`
47
+ `echo #{@options&.dig("secrets", "path")}`.chomp
48
48
  end
49
49
  end
@@ -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
@@ -45,7 +45,7 @@ module Builtins
45
45
  else
46
46
  Output.failed
47
47
  Output.error("Error unmeeting #{dependency.type} dependency '#{dependency.name}':")
48
- puts(dependency.output)
48
+ Output.out(dependency.output)
49
49
  end
50
50
  end
51
51
  end
@@ -46,7 +46,7 @@ module Builtins
46
46
  else
47
47
  Output.failed
48
48
  Output.error("Error meeting #{dependency.type} dependency '#{dependency.name}':")
49
- puts(dependency.output)
49
+ Output.out(dependency.output)
50
50
  end
51
51
  end
52
52
  end
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__
@@ -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}` : File.open(@filename).read
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '0.2.3'
5
+ s.version = '0.2.4'
6
6
  s.authors = [
7
7
  'nickthecook@gmail.com'
8
8
  ]
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.3
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