ops_team 1.0.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ops +25 -2
- data/lib/action.rb +13 -1
- data/lib/ops.rb +6 -7
- data/ops_team.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57af38c44173187c829e4f07a894dac672b86dd3033564591804b693afa87fc8
|
4
|
+
data.tar.gz: bb9c475b0959e8d81d491406d533307a2276252ae99a2d27bb8bd91d1b65d302
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0ce89fe185230286256475fc1ada7d0fdf9d4aec5d31e0a6b2b735ea7f38d1d31a02c2dcdb65d99918cf4a47b745eb9953f60b8803b0fb739b38aabf4818984
|
7
|
+
data.tar.gz: a44717efc73eac86671f942322c9ca51e83403236c7897b854a86a32876e5c2e8179b50fb1b3cdb1e47d7c12342d7e4c29c39b0f9ddc9674a9fb7325db26842b
|
data/bin/ops
CHANGED
@@ -1,8 +1,31 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
|
7
|
+
def usage
|
8
|
+
puts "ops [-f|--file <ops_yml>] action [<action args>"
|
9
|
+
puts " ops_yml: the config file to load instead of './ops.yml'"
|
10
|
+
puts " action_args: arguments to the action loaded from the config file; depends on the action"
|
11
|
+
|
12
|
+
exit(1)
|
13
|
+
end
|
5
14
|
|
15
|
+
options = {}
|
16
|
+
while ARGV[0]&.match(/^-/)
|
17
|
+
opt = ARGV.shift
|
18
|
+
case opt
|
19
|
+
when '-f', '--file'
|
20
|
+
usage unless ARGV.length >= 1
|
21
|
+
|
22
|
+
options[:file] = ARGV.shift
|
23
|
+
else
|
24
|
+
usage
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
require_relative "../loader"
|
6
29
|
require 'ops'
|
7
30
|
|
8
|
-
Ops.new(ARGV).run
|
31
|
+
Ops.new(ARGV, config_file: options[:file]).run
|
data/lib/action.rb
CHANGED
@@ -17,7 +17,11 @@ class Action
|
|
17
17
|
raise NotAllowedInEnvError, "Action not allowed in #{Environment.environment} environment."
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
if perform_shell_expansion?
|
21
|
+
Kernel.exec(to_s)
|
22
|
+
else
|
23
|
+
Kernel.exec(*to_a)
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
def to_s
|
@@ -60,6 +64,10 @@ class Action
|
|
60
64
|
|
61
65
|
private
|
62
66
|
|
67
|
+
def to_a
|
68
|
+
command.split(" ").reject(&:nil?) | @args
|
69
|
+
end
|
70
|
+
|
63
71
|
def not_in_envs
|
64
72
|
@config["not_in_envs"] || []
|
65
73
|
end
|
@@ -75,4 +83,8 @@ class Action
|
|
75
83
|
|
76
84
|
true
|
77
85
|
end
|
86
|
+
|
87
|
+
def perform_shell_expansion?
|
88
|
+
@config["shell_expansion"].nil? ? true : @config["shell_expansion"]
|
89
|
+
end
|
78
90
|
end
|
data/lib/ops.rb
CHANGED
@@ -14,8 +14,6 @@ require_rel "builtins"
|
|
14
14
|
|
15
15
|
# executes commands based on local `ops.yml`
|
16
16
|
class Ops
|
17
|
-
CONFIG_FILE = "ops.yml"
|
18
|
-
|
19
17
|
INVALID_SYNTAX_EXIT_CODE = 64
|
20
18
|
UNKNOWN_ACTION_EXIT_CODE = 65
|
21
19
|
ERROR_LOADING_APP_CONFIG_EXIT_CODE = 66
|
@@ -32,9 +30,10 @@ class Ops
|
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
|
-
def initialize(argv)
|
33
|
+
def initialize(argv, config_file: nil)
|
36
34
|
@action_name = argv[0]
|
37
35
|
@args = argv[1..-1]
|
36
|
+
@config_file = config_file || "ops.yml"
|
38
37
|
|
39
38
|
Options.set(config["options"] || {})
|
40
39
|
end
|
@@ -106,21 +105,21 @@ class Ops
|
|
106
105
|
if config_file_exists?
|
107
106
|
parsed_config_contents
|
108
107
|
else
|
109
|
-
Output.warn("File '#{
|
108
|
+
Output.warn("File '#{@config_file}' does not exist.") unless @action_name == "init"
|
110
109
|
{}
|
111
110
|
end
|
112
111
|
end
|
113
112
|
end
|
114
113
|
|
115
114
|
def parsed_config_contents
|
116
|
-
YAML.load_file(
|
115
|
+
YAML.load_file(@config_file)
|
117
116
|
rescue StandardError => e
|
118
|
-
Output.warn("Error parsing '#{
|
117
|
+
Output.warn("Error parsing '#{@config_file}': #{e}")
|
119
118
|
{}
|
120
119
|
end
|
121
120
|
|
122
121
|
def config_file_exists?
|
123
|
-
File.exist?(
|
122
|
+
File.exist?(@config_file)
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
data/ops_team.gemspec
CHANGED