ops_team 0.2.9 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5c2fa7f06155a753554402aa2063aec1bf192aa171a6c2e601619ee6f80e148
4
- data.tar.gz: ca9c1bcde247a55ad469e423f5bde3a1ba3a85ad51694b519622e6a572304afc
3
+ metadata.gz: c66d41a99b01b2cb8a491c3fcc21c81914cf6981ffe757965940ad125f7d4721
4
+ data.tar.gz: edb9c00bdef96370a79586638fc1541c5ad1e0ae301fe14053bc30004f149333
5
5
  SHA512:
6
- metadata.gz: 7baea51515c766fd4409382b91560dd21948b95470d62fad73a6f23c3b58d92a0a0030d55c95dd7de6dfeb0fed73f6b35f7728419da1ca9962598873440cccf3
7
- data.tar.gz: c544f035850f131ff02882cf88196f4fc62ab91dc4142ce292cf10531f685415ad349aeaabd52e26f988932eba9fc02888a820502e7efff6fde8478cecfc1941
6
+ metadata.gz: 1f1bbbd85e768c5f20b0d1fb70c28db11875aabadaf3fc647a2dc8c590be470cdab990c2fa9a657c02b7f6a2798eb5c2a94623d05aa9bb5ef95dd1706d742a6b
7
+ data.tar.gz: 056d36e1c94f72709568d95e5eb2608a0804e9b322491cf1ff0a9fa4d17cefe5862e508aaf0d73bac5949dafbba8d2fcc8e6d6028235e2beb2b87410fa1cd5e3
@@ -18,8 +18,8 @@ class AppConfig
18
18
  end
19
19
 
20
20
  def config
21
- @config ||= file_contents ? JSON.parse(file_contents) : {}
22
- rescue JSON::ParserError => e
21
+ @config ||= file_contents ? YAML.safe_load(file_contents) : {}
22
+ rescue YAML::SyntaxError => e
23
23
  Output.error("Error parsing config data: #{e}")
24
24
  {}
25
25
  end
@@ -14,7 +14,7 @@ module Builtins
14
14
  end
15
15
  end
16
16
 
17
- def run
17
+ def run
18
18
  unless gemspec
19
19
  Output.error("Unable to load gemspec at '#{GEMSPEC_FILE}")
20
20
  return false
@@ -9,7 +9,7 @@ module Dependencies
9
9
  end
10
10
 
11
11
  def meet
12
- execute("apt-get install -y #{name}")
12
+ execute("#{sudo_string}#{meet_command}")
13
13
  end
14
14
 
15
15
  def unmeet
@@ -20,5 +20,17 @@ module Dependencies
20
20
  def should_meet?
21
21
  `uname`.chomp == "Linux"
22
22
  end
23
+
24
+ private
25
+
26
+ def sudo_string
27
+ return "" if ENV['USER'] == "root" || Options.get("apt.use_sudo") == false
28
+
29
+ "sudo "
30
+ end
31
+
32
+ def meet_command
33
+ "apt-get install -y #{name}"
34
+ end
23
35
  end
24
36
  end
@@ -6,11 +6,8 @@ class Environment
6
6
  end
7
7
 
8
8
  def set_variables
9
- @env_hash.each do |key, value|
10
- ENV[key] = value
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] = value.to_s
34
+ end
35
+ end
21
36
  end
data/lib/ops.rb CHANGED
@@ -53,7 +53,7 @@ class Ops
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
 
@@ -3,7 +3,7 @@
3
3
  class Options
4
4
  class << self
5
5
  def get(path)
6
- @options.dig(*path.split('.'))
6
+ @options&.dig(*path.split('.'))
7
7
  end
8
8
 
9
9
  def set(options)
@@ -9,22 +9,28 @@ require 'options'
9
9
  class Secrets < AppConfig
10
10
  class << self
11
11
  def load
12
- Secrets.new(expand_path(Options.get("secrets.path"))).load
12
+ Secrets.new(secrets_path).load
13
13
  end
14
14
 
15
15
  private
16
16
 
17
+ def secrets_path
18
+ expand_path(Options.get("secrets.path"))
19
+ end
20
+
17
21
  def expand_path(path)
18
22
  `echo #{path}`.chomp
19
23
  end
20
24
  end
21
25
 
26
+ def initialize(filename = "")
27
+ @filename = filename.empty? ? default_filename : actual_filename_for(filename)
28
+ end
29
+
22
30
  private
23
31
 
24
32
  def default_filename
25
- return default_ejson_filename if File.exist?(default_ejson_filename)
26
-
27
- default_json_filename
33
+ File.exist?(default_ejson_filename) ? default_ejson_filename : default_json_filename
28
34
  end
29
35
 
30
36
  def default_ejson_filename
@@ -35,6 +41,10 @@ class Secrets < AppConfig
35
41
  "config/#{environment}/secrets.json"
36
42
  end
37
43
 
44
+ def actual_filename_for(filename)
45
+ File.exist?(filename) ? filename : filename.sub(".ejson", ".json")
46
+ end
47
+
38
48
  def file_contents
39
49
  @file_contents ||= @filename.match(/\.ejson$/) ? `ejson decrypt #{@filename}` : super
40
50
  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.9'
5
+ s.version = '0.6.0'
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.9
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com