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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7cef7e3cd868e55667e5640709b2588c34b334c6
4
- data.tar.gz: fb0420b231f90085e19fe1d8adab49232ebd8bd4
3
+ metadata.gz: 8498a1d399ef913b9d29a76bb4dcd3b934383d3a
4
+ data.tar.gz: 306372f50dbf1bb056f4668dab2e4877a10b5023
5
5
  SHA512:
6
- metadata.gz: e9a76b4791ce74de74fad77873e1590b1ee12a516a13a746de5c4b35ad3569981675b74393cf0e7dac95845d05d5e97f7fad949e0daac150d451fb58fee43680
7
- data.tar.gz: 21b9c513abdc8a3509f31cace6db57a6bae7e0cb8fa5406308ddf5c298e4ad6ff80a7cd31881f23360403295c6a6f3b649926320c0237002a423656b920b0bed
6
+ metadata.gz: 77f1c40c00c9ac3d1893eeeee77cf4be3b1ce7d10713a2336cf8a74a6a62e3823f4bebacec432737533984971bf279a1dea15f1f3be6c0c7ff13ddce7d496c16
7
+ data.tar.gz: 57f0780c11d1d3e2822f68adee9918ea630b153b9f1d33ad56bb6350323f92e9779fafbe69ddc93a25f1bd5d028a8b6d65e15b124a2083fd6ff4aa746a191237
@@ -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]).read.strip
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]).read.strip
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]).read.strip.split(":", 2)
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
@@ -417,7 +417,7 @@ module Hotdog
417
417
  end
418
418
 
419
419
  def with_retry(options={}, &block)
420
- (options[:retry] || 5).times do |i|
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] || (2<<i), options[:retry_max_delay] || 60].min
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
@@ -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
@@ -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
- associae_tag_hosts(@db, tag, hosts)
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
@@ -1,3 +1,3 @@
1
1
  module Hotdog
2
- VERSION = "0.23.1"
2
+ VERSION = "0.24.0"
3
3
  end
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.23.1
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-03-08 00:00:00.000000000 Z
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.8
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