ops_team 1.2.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/bin/ops +1 -1
- data/lib/builtins/countdown.rb +74 -0
- data/lib/dependencies/cask.rb +2 -2
- data/lib/environment.rb +3 -2
- data/lib/ops.rb +5 -1
- data/lib/runner.rb +3 -2
- data/ops_team.gemspec +2 -1
- metadata +29 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46bf39d607b3fb8f62433b114abb5c9e217d1960883e832fbb4ef2d660385707
|
4
|
+
data.tar.gz: 17341778ab4e0a9d54553ba0cc0785fcc80b55e4513aacecfe5f92e8aa7cd177
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 511d16e71f072bc617a3af9839398ea5fe500556a216cb91d381b732a4f2bc34730a09dd8237bc9c98e526eeb044f54b97f4faacdaaae7e4ff778cb2e0214552
|
7
|
+
data.tar.gz: a5e2ecd49da9859fd856cd8ee62cccfc32e9e28dac75c26ce115ddc09adcc50c8d46de8fda10bfb9443071984e7f7477ac962c27dd123c100ba826140b0e0b61
|
data/Gemfile
CHANGED
data/bin/ops
CHANGED
@@ -5,7 +5,7 @@ require 'optparse'
|
|
5
5
|
|
6
6
|
|
7
7
|
def usage
|
8
|
-
puts "ops [-f|--file <ops_yml>] action [<action args>"
|
8
|
+
puts "Usage: ops [-f|--file <ops_yml>] action [<action args>"
|
9
9
|
puts " ops_yml: the config file to load instead of './ops.yml'"
|
10
10
|
puts " action_args: arguments to the action loaded from the config file; depends on the action"
|
11
11
|
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'concurrent'
|
4
|
+
|
5
|
+
require 'builtin'
|
6
|
+
require 'output'
|
7
|
+
|
8
|
+
module Builtins
|
9
|
+
class Countdown < Builtin
|
10
|
+
USAGE_STRING = "Usage: ops countdown <seconds>"
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def description
|
14
|
+
"Like `sleep`, but displays time remaining in terminal."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def run
|
19
|
+
check_args
|
20
|
+
|
21
|
+
timer_task.execute
|
22
|
+
|
23
|
+
while timer_task.running?
|
24
|
+
sleep(1)
|
25
|
+
timer_task.shutdown if task_complete?
|
26
|
+
end
|
27
|
+
Output.out("\rCountdown complete after #{sleep_seconds}s.")
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def check_args
|
33
|
+
check_arg_count
|
34
|
+
check_arg_is_positive_int
|
35
|
+
end
|
36
|
+
|
37
|
+
def check_arg_count
|
38
|
+
raise Builtin::ArgumentError, USAGE_STRING unless args.length == 1
|
39
|
+
end
|
40
|
+
|
41
|
+
def check_arg_is_positive_int
|
42
|
+
raise Builtin::ArgumentError, USAGE_STRING unless sleep_seconds.positive?
|
43
|
+
# raised when the arg is not an int
|
44
|
+
rescue ::ArgumentError
|
45
|
+
raise Builtin::ArgumentError, USAGE_STRING
|
46
|
+
end
|
47
|
+
|
48
|
+
def timer_task
|
49
|
+
@timer_task ||= Concurrent::TimerTask.new(run_now: true, execution_interval: 1) do
|
50
|
+
Output.print("\r \r#{seconds_left}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def sleep_seconds
|
55
|
+
Integer(args.first)
|
56
|
+
end
|
57
|
+
|
58
|
+
def task_start_time
|
59
|
+
@task_start_time ||= Time.now
|
60
|
+
end
|
61
|
+
|
62
|
+
def task_end_time
|
63
|
+
@task_end_time ||= task_start_time + sleep_seconds
|
64
|
+
end
|
65
|
+
|
66
|
+
def task_complete?
|
67
|
+
Time.now > task_end_time
|
68
|
+
end
|
69
|
+
|
70
|
+
def seconds_left
|
71
|
+
Integer(task_end_time - Time.now + 1)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/dependencies/cask.rb
CHANGED
@@ -5,11 +5,11 @@ require 'dependencies/brew'
|
|
5
5
|
module Dependencies
|
6
6
|
class Cask < Brew
|
7
7
|
def met?
|
8
|
-
execute("brew cask
|
8
|
+
execute("brew list --cask #{name}")
|
9
9
|
end
|
10
10
|
|
11
11
|
def meet
|
12
|
-
execute("brew cask
|
12
|
+
execute("brew install --cask #{name}")
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/environment.rb
CHANGED
@@ -13,8 +13,9 @@ class Environment
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def initialize(env_hash)
|
16
|
+
def initialize(env_hash, config_path)
|
17
17
|
@env_hash = env_hash
|
18
|
+
@config_path = config_path
|
18
19
|
end
|
19
20
|
|
20
21
|
def set_variables
|
@@ -26,7 +27,7 @@ class Environment
|
|
26
27
|
private
|
27
28
|
|
28
29
|
def set_ops_variables
|
29
|
-
ENV["OPS_YML_DIR"] =
|
30
|
+
ENV["OPS_YML_DIR"] = File.dirname(@config_path)
|
30
31
|
ENV["OPS_VERSION"] = Version.version.to_s
|
31
32
|
ENV["OPS_SECRETS_FILE"] = Secrets.config_path_for(Environment.environment)
|
32
33
|
ENV["OPS_CONFIG_FILE"] = AppConfig.config_path_for(Environment.environment)
|
data/lib/ops.rb
CHANGED
@@ -97,7 +97,7 @@ class Ops
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def runner
|
100
|
-
@runner ||= Runner.new(@action_name, @args, config)
|
100
|
+
@runner ||= Runner.new(@action_name, @args, config, config_file_absolute_path)
|
101
101
|
end
|
102
102
|
|
103
103
|
def config
|
@@ -121,6 +121,10 @@ class Ops
|
|
121
121
|
def config_file_exists?
|
122
122
|
File.exist?(@config_file)
|
123
123
|
end
|
124
|
+
|
125
|
+
def config_file_absolute_path
|
126
|
+
File.expand_path(@config_file)
|
127
|
+
end
|
124
128
|
end
|
125
129
|
|
126
130
|
Ops.new(ARGV).run if $PROGRAM_NAME == __FILE__
|
data/lib/runner.rb
CHANGED
@@ -11,10 +11,11 @@ class Runner
|
|
11
11
|
class UnknownActionError < StandardError; end
|
12
12
|
class ActionConfigError < StandardError; end
|
13
13
|
|
14
|
-
def initialize(action_name, args, config)
|
14
|
+
def initialize(action_name, args, config, config_path)
|
15
15
|
@action_name = action_name
|
16
16
|
@args = args
|
17
17
|
@config = config
|
18
|
+
@config_path = config_path
|
18
19
|
end
|
19
20
|
|
20
21
|
def run
|
@@ -89,6 +90,6 @@ class Runner
|
|
89
90
|
end
|
90
91
|
|
91
92
|
def environment
|
92
|
-
@environment ||= Environment.new(env_vars)
|
93
|
+
@environment ||= Environment.new(env_vars, @config_path)
|
93
94
|
end
|
94
95
|
end
|
data/ops_team.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'ops_team'
|
5
|
-
s.version = '1.2
|
5
|
+
s.version = '1.3.2'
|
6
6
|
s.authors = [
|
7
7
|
'nickthecook@gmail.com'
|
8
8
|
]
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.required_ruby_version = '~> 2.5'
|
26
26
|
s.add_runtime_dependency 'bcrypt_pbkdf', '~> 1.0', '>= 1.0.1'
|
27
27
|
s.add_runtime_dependency 'colorize', '~> 0.8', '>= 0.8.1'
|
28
|
+
s.add_runtime_dependency 'concurrent-ruby', '~> 1.1', '>= 1.1.7'
|
28
29
|
s.add_runtime_dependency 'ed25519', '~> 1.2', '>= 1.2.4'
|
29
30
|
s.add_runtime_dependency 'ejson', '~> 1.2', '>= 1.2.1'
|
30
31
|
s.add_runtime_dependency 'net-ssh', '~> 6.1', '>= 6.1.0'
|
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: 1.2
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- nickthecook@gmail.com
|
@@ -50,6 +50,26 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 0.8.1
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: concurrent-ruby
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.1'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.1.7
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '1.1'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.1.7
|
53
73
|
- !ruby/object:Gem::Dependency
|
54
74
|
name: ed25519
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,22 +114,22 @@ dependencies:
|
|
94
114
|
name: net-ssh
|
95
115
|
requirement: !ruby/object:Gem::Requirement
|
96
116
|
requirements:
|
97
|
-
- - ">="
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
version: 6.1.0
|
100
117
|
- - "~>"
|
101
118
|
- !ruby/object:Gem::Version
|
102
119
|
version: '6.1'
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 6.1.0
|
103
123
|
type: :runtime
|
104
124
|
prerelease: false
|
105
125
|
version_requirements: !ruby/object:Gem::Requirement
|
106
126
|
requirements:
|
107
|
-
- - ">="
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: 6.1.0
|
110
127
|
- - "~>"
|
111
128
|
- !ruby/object:Gem::Version
|
112
129
|
version: '6.1'
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: 6.1.0
|
113
133
|
- !ruby/object:Gem::Dependency
|
114
134
|
name: require_all
|
115
135
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,6 +172,7 @@ files:
|
|
152
172
|
- lib/builtin.rb
|
153
173
|
- lib/builtins/background.rb
|
154
174
|
- lib/builtins/background_log.rb
|
175
|
+
- lib/builtins/countdown.rb
|
155
176
|
- lib/builtins/down.rb
|
156
177
|
- lib/builtins/env.rb
|
157
178
|
- lib/builtins/envdiff.rb
|
@@ -205,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
226
|
- !ruby/object:Gem::Version
|
206
227
|
version: '0'
|
207
228
|
requirements: []
|
208
|
-
rubygems_version: 3.
|
229
|
+
rubygems_version: 3.1.2
|
209
230
|
signing_key:
|
210
231
|
specification_version: 4
|
211
232
|
summary: ops_team handles basic operations tasks for your project, driven by YAML
|