ops_team 0.2.5 → 0.3.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: 825a1361283396d68558e9584c6a3b550bbd44965c38829890c0ba2610eb7c55
4
- data.tar.gz: b553774400887ee8e22882aa9cccff57e4f5168cb0eccecbe7ad5673ff09c6a6
3
+ metadata.gz: ff1832331084939d3f2b4d0b58fa2e50715051bdff1c82e984dfb289aee64a15
4
+ data.tar.gz: e2ecb1f387ce50d5c81500c29f0c67e727d105c66007dc090f67400c1617a4a5
5
5
  SHA512:
6
- metadata.gz: 0665d5cfbb51391ec40775e219c60c2fc01548bc803c19f048dba5352d3f1c327f2bc150658dbcedbfa35f6e28d8dd3b9108935b460905f2a5cdcc3b1a6570f7
7
- data.tar.gz: 0aa5809debd1fa918e9f5b223d37fd2bfe38d7d7abb50e81cbc176e5490bcb5d8a1323c1a536837d90902e753edad2b9770063cf41f92a1e41edba72e7de7ffe
6
+ metadata.gz: cac44a0b4576375fac4210493292537c84b7ef0be6d3c38a16cf17f854058026184f0e96d3a61d4d6a54c226db4b90256844980f5d746120b5e0c3530610c0c0
7
+ data.tar.gz: b9d1c6be114864c3890b9a391f0f82f481c1bd556349500e8787fbfe960c30604ce04d8f5f5d94f5445c0912cf941798b414343e3f6a55d56c13ff14c0df8488
@@ -11,7 +11,7 @@ actions:
11
11
  alias: a
12
12
  description: runs 'terraform apply'
13
13
  apply-auto-approve:
14
- command: terraform apply --auto-approve
14
+ command: ops apply --auto-approve
15
15
  alias: aa
16
16
  description: runs 'terraform apply' with auto-approve
17
17
  destroy:
@@ -19,7 +19,7 @@ actions:
19
19
  alias: d
20
20
  description: runs 'terraform destroy'
21
21
  destroy-auto-approve:
22
- command: terraform destroy --auto-approve
22
+ command: ops destroy --auto-approve
23
23
  alias: dd
24
24
  description: runs 'terraform destroy' with auto-approve
25
25
  plan:
@@ -7,7 +7,7 @@ class AppConfig
7
7
 
8
8
  def load
9
9
  config['environment']&.each do |key, value|
10
- ENV[key] = value
10
+ ENV[key] = value.to_s
11
11
  end
12
12
  end
13
13
 
@@ -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
data/lib/ops.rb CHANGED
@@ -16,7 +16,8 @@ class Ops
16
16
 
17
17
  CONFIG_FILE = "ops.yml"
18
18
 
19
- INVALID_SYNTAX_EXIT_CODE = 1
19
+ INVALID_SYNTAX_EXIT_CODE = 64
20
+ UNKNOWN_ACTION_EXIT_CODE = 65
20
21
 
21
22
  def initialize(argv)
22
23
  @action_name = argv[0]
@@ -28,15 +29,10 @@ class Ops
28
29
  def run
29
30
  exit(INVALID_SYNTAX_EXIT_CODE) unless syntax_valid?
30
31
 
31
- environment.set_variables
32
- app_config.load
33
-
34
- return builtin.run if builtin
35
-
36
- Output.warn("Running '#{action}' from #{CONFIG_FILE}...")
37
- action.run
32
+ run_action
38
33
  rescue UnknownActionError => e
39
34
  Output.error("Error: #{e}")
35
+ exit(UNKNOWN_ACTION_EXIT_CODE)
40
36
  end
41
37
 
42
38
  private
@@ -51,6 +47,16 @@ class Ops
51
47
  end
52
48
  end
53
49
 
50
+ def run_action
51
+ environment.set_variables
52
+ app_config.load
53
+
54
+ return builtin.run if builtin
55
+
56
+ Output.warn("Running '#{action}' from #{CONFIG_FILE}...")
57
+ action.run
58
+ end
59
+
54
60
  def builtin
55
61
  @builtin ||= Builtins.const_get(builtin_class_name, false).new(@args, config)
56
62
  rescue NameError
@@ -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)
@@ -4,7 +4,7 @@ require 'json'
4
4
 
5
5
  require 'output'
6
6
  require 'app_config'
7
- require 'Options'
7
+ require 'options'
8
8
 
9
9
  class Secrets < AppConfig
10
10
  class << self
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '0.2.5'
5
+ s.version = '0.3.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.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com
@@ -84,7 +84,6 @@ files:
84
84
  - lib/dependencies/dir.rb
85
85
  - lib/dependencies/docker.rb
86
86
  - lib/dependencies/gem.rb
87
- - lib/dependencies/terraform.rb
88
87
  - lib/dependency.rb
89
88
  - lib/environment.rb
90
89
  - lib/ops.rb
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'dependency'
4
-
5
- module Dependencies
6
- class Terraform < Dependency
7
- def met?
8
- false
9
- end
10
-
11
- def always_act?
12
- true
13
- end
14
-
15
- def meet
16
- execute("cd #{name} && terraform init && terraform apply -input=false --auto-approve")
17
- end
18
-
19
- def unmeet
20
- execute("cd #{name} && terraform destroy -input=false --auto-approve")
21
- end
22
- end
23
- end