hotdog 0.23.1 → 0.24.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 +4 -4
- data/lib/hotdog/application.rb +18 -3
- data/lib/hotdog/commands.rb +2 -2
- data/lib/hotdog/commands/scp.rb +6 -0
- data/lib/hotdog/commands/tag.rb +12 -2
- data/lib/hotdog/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8498a1d399ef913b9d29a76bb4dcd3b934383d3a
|
4
|
+
data.tar.gz: 306372f50dbf1bb056f4668dab2e4877a10b5023
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f1c40c00c9ac3d1893eeeee77cf4be3b1ce7d10713a2336cf8a74a6a62e3823f4bebacec432737533984971bf279a1dea15f1f3be6c0c7ff13ddce7d496c16
|
7
|
+
data.tar.gz: 57f0780c11d1d3e2822f68adee9918ea630b153b9f1d33ad56bb6350323f92e9779fafbe69ddc93a25f1bd5d028a8b6d65e15b124a2083fd6ff4aa746a191237
|
data/lib/hotdog/application.rb
CHANGED
@@ -260,7 +260,12 @@ module Hotdog
|
|
260
260
|
def update_api_key!()
|
261
261
|
if options[:api_key_command]
|
262
262
|
logger.info("api_key_command> #{options[:api_key_command]}")
|
263
|
-
options[:api_key] = IO.popen(options[:api_key_command])
|
263
|
+
options[:api_key] = IO.popen(options[:api_key_command]) do |io|
|
264
|
+
io.read.strip
|
265
|
+
end
|
266
|
+
unless $?.success?
|
267
|
+
raise("failed: #{options[:api_key_command]}")
|
268
|
+
end
|
264
269
|
else
|
265
270
|
update_keys!
|
266
271
|
end
|
@@ -269,7 +274,12 @@ module Hotdog
|
|
269
274
|
def update_application_key!()
|
270
275
|
if options[:application_key_command]
|
271
276
|
logger.info("application_key_command> #{options[:application_key_command]}")
|
272
|
-
options[:application_key] = IO.popen(options[:application_key_command])
|
277
|
+
options[:application_key] = IO.popen(options[:application_key_command]) do |io|
|
278
|
+
io.read.strip
|
279
|
+
end
|
280
|
+
unless $?.success?
|
281
|
+
raise("failed: #{options[:application_key_command]}")
|
282
|
+
end
|
273
283
|
else
|
274
284
|
update_keys!
|
275
285
|
end
|
@@ -278,7 +288,12 @@ module Hotdog
|
|
278
288
|
def update_keys!()
|
279
289
|
if options[:key_command]
|
280
290
|
logger.info("key_command> #{options[:key_command]}")
|
281
|
-
options[:api_key], options[:application_key] = IO.popen(options[:key_command])
|
291
|
+
options[:api_key], options[:application_key] = IO.popen(options[:key_command]) do |io|
|
292
|
+
io.read.strip.split(":", 2)
|
293
|
+
end
|
294
|
+
unless $?.success?
|
295
|
+
raise("failed: #{options[:key_command]}")
|
296
|
+
end
|
282
297
|
end
|
283
298
|
end
|
284
299
|
end
|
data/lib/hotdog/commands.rb
CHANGED
@@ -417,7 +417,7 @@ module Hotdog
|
|
417
417
|
end
|
418
418
|
|
419
419
|
def with_retry(options={}, &block)
|
420
|
-
(options[:retry] ||
|
420
|
+
(options[:retry] || 10).times do |i|
|
421
421
|
begin
|
422
422
|
return yield
|
423
423
|
rescue => error
|
@@ -428,7 +428,7 @@ module Hotdog
|
|
428
428
|
error.backtrace.each do |frame|
|
429
429
|
logger.info("\t#{frame}")
|
430
430
|
end
|
431
|
-
wait = [options[:retry_delay] || (
|
431
|
+
wait = [options[:retry_delay] || (1<<i), options[:retry_max_delay] || 60].min
|
432
432
|
logger.info("will retry after #{wait} seconds....")
|
433
433
|
sleep(wait)
|
434
434
|
end
|
data/lib/hotdog/commands/scp.rb
CHANGED
@@ -7,6 +7,12 @@ require "hotdog/commands/ssh"
|
|
7
7
|
module Hotdog
|
8
8
|
module Commands
|
9
9
|
class Scp < SingularSshAlike
|
10
|
+
def define_options(optparse, options={})
|
11
|
+
program_name = File.basename($0, '.*')
|
12
|
+
optparse.banner = "Usage: #{program_name} scp [options] pattern -- src @:dst"
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
10
16
|
private
|
11
17
|
def build_command_string(host, command=nil, options={})
|
12
18
|
# replace "@:" by actual hostname
|
data/lib/hotdog/commands/tag.rb
CHANGED
@@ -33,14 +33,16 @@ module Hotdog
|
|
33
33
|
@db.transaction do
|
34
34
|
create_tags(@db, options[:tags])
|
35
35
|
options[:tags].each do |tag|
|
36
|
-
|
36
|
+
associate_tag_hosts(@db, tag, hosts)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
hosts.each do |host|
|
42
42
|
if options[:tags].empty?
|
43
|
-
# nop
|
43
|
+
# nop; just show current tags
|
44
|
+
host_tags = with_retry { host_tags(host, source=options[:tag_source]) }
|
45
|
+
STDOUT.puts host_tags['tags'].inspect
|
44
46
|
else
|
45
47
|
# add all as user tags
|
46
48
|
with_retry(options) do
|
@@ -58,6 +60,14 @@ module Hotdog
|
|
58
60
|
end
|
59
61
|
resp
|
60
62
|
end
|
63
|
+
|
64
|
+
def host_tags(host_name, options={})
|
65
|
+
code, host_tags = dog.host_tags(host_name, options)
|
66
|
+
if code.to_i / 100 != 2
|
67
|
+
raise("dog.host_tags(#{host_name.inspect}, #{options.inspect}) returns [#{code.inspect}, #{host_tags.inspect}]")
|
68
|
+
end
|
69
|
+
host_tags
|
70
|
+
end
|
61
71
|
end
|
62
72
|
end
|
63
73
|
end
|
data/lib/hotdog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotdog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
221
221
|
version: '0'
|
222
222
|
requirements: []
|
223
223
|
rubyforge_project:
|
224
|
-
rubygems_version: 2.6.
|
224
|
+
rubygems_version: 2.6.11
|
225
225
|
signing_key:
|
226
226
|
specification_version: 4
|
227
227
|
summary: Yet another command-line tool for Datadog
|