ops_team 0.2.4 → 0.2.5

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: fb200091bd81044096f650bc1647958dd129b12b14c309516b7e7ce0324e8889
4
- data.tar.gz: 0edf7442cd2106ac2de48b6c14d16510111fa10759fe320aaea1856f366c8703
3
+ metadata.gz: 825a1361283396d68558e9584c6a3b550bbd44965c38829890c0ba2610eb7c55
4
+ data.tar.gz: b553774400887ee8e22882aa9cccff57e4f5168cb0eccecbe7ad5673ff09c6a6
5
5
  SHA512:
6
- metadata.gz: '0379eecf548037718aebf63b722f9571f21410daafd13a6b9ae893cfe7d3fbd3c0a58c40ea10dd1ac35d52c1de580894a774859755185dd8c32eb130db6d31fc'
7
- data.tar.gz: 6e08799eb7cf0c196c88e93ecd68f7d48beedd803291d07b362750c9d738785736e9db49ca3c02d180544efa731f7064d5b5537016db8427b826e8057e4a2210
6
+ metadata.gz: 0665d5cfbb51391ec40775e219c60c2fc01548bc803c19f048dba5352d3f1c327f2bc150658dbcedbfa35f6e28d8dd3b9108935b460905f2a5cdcc3b1a6570f7
7
+ data.tar.gz: 0aa5809debd1fa918e9f5b223d37fd2bfe38d7d7abb50e81cbc176e5490bcb5d8a1323c1a536837d90902e753edad2b9770063cf41f92a1e41edba72e7de7ffe
@@ -5,14 +5,13 @@ require 'secrets'
5
5
  # represents one action to be performed in the shell
6
6
  # can assemble a command line from a command and args
7
7
  class Action
8
- def initialize(config, args, options)
8
+ def initialize(config, args)
9
9
  @config = config
10
10
  @args = args
11
- @options = options
12
11
  end
13
12
 
14
13
  def run
15
- load_secrets if load_secrets?
14
+ Secrets.load if load_secrets?
16
15
 
17
16
  Kernel.exec(to_s)
18
17
  end
@@ -38,12 +37,4 @@ class Action
38
37
  def load_secrets?
39
38
  @config["load_secrets"]
40
39
  end
41
-
42
- def load_secrets
43
- Secrets.new(secrets_file).load
44
- end
45
-
46
- def secrets_file
47
- `echo #{@options&.dig("secrets", "path")}`.chomp
48
- end
49
40
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'builtin'
4
+ require 'output'
5
+ require 'secrets'
6
+ require 'options'
7
+
8
+ module Builtins
9
+ class Exec < Builtin
10
+ class << self
11
+ def description
12
+ "executes the given command in the `ops` environment, i.e. with environment variables set"
13
+ end
14
+ end
15
+
16
+ def run
17
+ Secrets.load if Options.get("exec.load_secrets")
18
+ Kernel.exec(@args.join(" "))
19
+ end
20
+ end
21
+ end
data/lib/ops.rb CHANGED
@@ -71,7 +71,7 @@ class Ops
71
71
 
72
72
  def actions
73
73
  config["actions"].transform_values do |config|
74
- Action.new(config, @args, action_options)
74
+ Action.new(config, @args)
75
75
  end
76
76
  end
77
77
 
@@ -92,10 +92,6 @@ class Ops
92
92
  end
93
93
  end
94
94
 
95
- def action_options
96
- @action_options ||= @config.dig("options", "actions")
97
- end
98
-
99
95
  def env_vars
100
96
  @config.dig("options", "environment") || {}
101
97
  end
@@ -105,7 +101,7 @@ class Ops
105
101
  end
106
102
 
107
103
  def app_config_file
108
- `echo #{@options&.dig("config", "path")}`.chomp
104
+ `echo #{Options.get("config.path")}`.chomp
109
105
  end
110
106
 
111
107
  def app_config
@@ -4,8 +4,21 @@ require 'json'
4
4
 
5
5
  require 'output'
6
6
  require 'app_config'
7
+ require 'Options'
7
8
 
8
9
  class Secrets < AppConfig
10
+ class << self
11
+ def load
12
+ Secrets.new(expand_path(Options.get("secrets.path"))).load
13
+ end
14
+
15
+ private
16
+
17
+ def expand_path(path)
18
+ `echo #{path}`.chomp
19
+ end
20
+ end
21
+
9
22
  private
10
23
 
11
24
  def default_filename
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'ops_team'
5
- s.version = '0.2.4'
5
+ s.version = '0.2.5'
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.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - nickthecook@gmail.com
@@ -70,6 +70,7 @@ files:
70
70
  - lib/builtin.rb
71
71
  - lib/builtins/down.rb
72
72
  - lib/builtins/env.rb
73
+ - lib/builtins/exec.rb
73
74
  - lib/builtins/help.rb
74
75
  - lib/builtins/helpers/dependency_handler.rb
75
76
  - lib/builtins/init.rb