hotdog 0.18.3 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/lib/hotdog/application.rb +1 -1
- data/lib/hotdog/commands/down.rb +2 -2
- data/lib/hotdog/commands/scp.rb +1 -1
- data/lib/hotdog/commands/sftp.rb +1 -1
- data/lib/hotdog/commands/ssh.rb +1 -1
- data/lib/hotdog/commands/untag.rb +1 -1
- data/lib/hotdog/commands/up.rb +1 -1
- data/lib/hotdog/commands.rb +60 -54
- data/lib/hotdog/expression/semantics.rb +5 -5
- data/lib/hotdog/version.rb +1 -1
- data/spec/core/commands_spec.rb +9 -12
- 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: 872d3fc9b9a8db571e76a8ecd479302eb3320182
|
4
|
+
data.tar.gz: e5f2a0a7fca123a5895cbb6b0938588e3fb82383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12b4a016471a39f25e02214122d5a4baed9c57f40dd1527a5823cf32650cafce216bfa45d6d2680dda0885775851fec40944faf815d84444cc5184a994d9777c
|
7
|
+
data.tar.gz: fe92243179aa734f40a63a06848e026ba6cc9b315db6aa0cd5efd8ad8cfda4331af8af9f58bb64ee0453f0a2b91347e2d861f77008e62f1ad354129d79adeeeb
|
data/.travis.yml
CHANGED
data/lib/hotdog/application.rb
CHANGED
data/lib/hotdog/commands/down.rb
CHANGED
@@ -39,8 +39,8 @@ module Hotdog
|
|
39
39
|
with_retry do
|
40
40
|
@db.transaction do
|
41
41
|
hosts.each_slice(SQLITE_LIMIT_COMPOUND_SELECT) do |hosts|
|
42
|
-
execute_db(@db, "DELETE FROM hosts_tags WHERE host_id IN ( SELECT id FROM hosts WHERE name IN (%s) )" % hosts.map { "?" }.join(", "), hosts)
|
43
|
-
execute_db(@db, "DELETE FROM hosts WHERE name IN (%s)" % hosts.map { "?" }.join(", "), hosts)
|
42
|
+
execute_db(@db, "DELETE FROM hosts_tags WHERE host_id IN ( SELECT id FROM hosts WHERE name IN (%s) );" % hosts.map { "?" }.join(", "), hosts)
|
43
|
+
execute_db(@db, "DELETE FROM hosts WHERE name IN (%s);" % hosts.map { "?" }.join(", "), hosts)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/hotdog/commands/scp.rb
CHANGED
@@ -10,7 +10,7 @@ module Hotdog
|
|
10
10
|
private
|
11
11
|
def build_command_string(host, command=nil, options={})
|
12
12
|
# replace "@:" by actual hostname
|
13
|
-
cmdline =
|
13
|
+
cmdline = Shellwords.shellsplit(options.fetch(:scp_command, "scp")) + build_command_options(options) + Shellwords.split(command).map { |token| token.gsub(/@(?=:)/, host) }
|
14
14
|
Shellwords.join(cmdline)
|
15
15
|
end
|
16
16
|
end
|
data/lib/hotdog/commands/sftp.rb
CHANGED
@@ -9,7 +9,7 @@ module Hotdog
|
|
9
9
|
class Sftp < SingularSshAlike
|
10
10
|
private
|
11
11
|
def build_command_string(host, command=nil, options={})
|
12
|
-
cmdline =
|
12
|
+
cmdline = Shellwords.shellsplit(options.fetch(:sftp_command, "sftp")) + build_command_options(options) + [host]
|
13
13
|
if command
|
14
14
|
logger.warn("ignore remote command: #{command}")
|
15
15
|
end
|
data/lib/hotdog/commands/ssh.rb
CHANGED
@@ -132,7 +132,7 @@ module Hotdog
|
|
132
132
|
|
133
133
|
def build_command_string(host, command=nil, options={})
|
134
134
|
# build ssh command
|
135
|
-
cmdline =
|
135
|
+
cmdline = Shellwords.shellsplit(options.fetch(:ssh_command, "ssh")) + build_command_options(options) + [host]
|
136
136
|
if command
|
137
137
|
cmdline << "--" << command
|
138
138
|
end
|
data/lib/hotdog/commands/up.rb
CHANGED
data/lib/hotdog/commands.rb
CHANGED
@@ -119,7 +119,7 @@ module Hotdog
|
|
119
119
|
host_ids.each_slice(SQLITE_LIMIT_COMPOUND_SELECT).flat_map { |host_ids|
|
120
120
|
q = "SELECT DISTINCT tags.name FROM hosts_tags " \
|
121
121
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
122
|
-
"WHERE hosts_tags.host_id IN (%s);" % host_ids.map { "?" }.join(", ")
|
122
|
+
"WHERE hosts_tags.host_id IN (%s) ORDER BY hosts_tags.host_id;" % host_ids.map { "?" }.join(", ")
|
123
123
|
execute(q, host_ids).map { |row| row.first }
|
124
124
|
}.uniq
|
125
125
|
end
|
@@ -131,20 +131,13 @@ module Hotdog
|
|
131
131
|
when 1
|
132
132
|
get_hosts_field(host_ids, fields.first, options)
|
133
133
|
else
|
134
|
-
|
135
|
-
host_names = Hash[execute("SELECT id, name FROM hosts WHERE id IN (%s);" % host_ids.map { "?" }.join(", "), host_ids).map { |row| row.to_a }]
|
136
|
-
else
|
137
|
-
host_names = {}
|
138
|
-
end
|
139
|
-
|
140
|
-
[host_ids.map { |host_id| get_host_fields(host_id, fields, options.merge(host_names: host_names)) }.map { |result, fields| result }, fields]
|
134
|
+
[host_ids.map { |host_id| get_host_fields(host_id, fields, options) }.map { |result, fields| result }, fields]
|
141
135
|
end
|
142
136
|
end
|
143
137
|
|
144
138
|
def get_host_fields(host_id, fields, options={})
|
145
|
-
field_values = {
|
146
|
-
|
147
|
-
fields.reject { |field| /\Ahost\z/i =~ field }.uniq.each_slice(SQLITE_LIMIT_COMPOUND_SELECT - 1).each do |fields|
|
139
|
+
field_values = {}
|
140
|
+
fields.uniq.each_slice(SQLITE_LIMIT_COMPOUND_SELECT - 1).each do |fields|
|
148
141
|
q = "SELECT LOWER(tags.name), GROUP_CONCAT(tags.value, ',') FROM hosts_tags " \
|
149
142
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
150
143
|
"WHERE hosts_tags.host_id = ? AND tags.name IN (%s) " \
|
@@ -164,14 +157,14 @@ module Hotdog
|
|
164
157
|
def get_hosts_field(host_ids, field, options={})
|
165
158
|
if /\Ahost\z/i =~ field
|
166
159
|
result = host_ids.each_slice(SQLITE_LIMIT_COMPOUND_SELECT).flat_map { |host_ids|
|
167
|
-
execute("SELECT name FROM hosts WHERE id IN (%s)" % host_ids.map { "?" }.join(", "), host_ids).map { |row| row.to_a }
|
160
|
+
execute("SELECT name FROM hosts WHERE id IN (%s) ORDER BY id;" % host_ids.map { "?" }.join(", "), host_ids).map { |row| row.to_a }
|
168
161
|
}
|
169
162
|
else
|
170
163
|
result = host_ids.each_slice(SQLITE_LIMIT_COMPOUND_SELECT - 1).flat_map { |host_ids|
|
171
164
|
q = "SELECT LOWER(tags.name), GROUP_CONCAT(tags.value, ',') FROM hosts_tags " \
|
172
165
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id " \
|
173
166
|
"WHERE hosts_tags.host_id IN (%s) AND tags.name = ? " \
|
174
|
-
"GROUP BY hosts_tags.host_id, tags.name;" % host_ids.map { "?" }.join(", ")
|
167
|
+
"GROUP BY hosts_tags.host_id, tags.name ORDER BY hosts_tags.host_id;" % host_ids.map { "?" }.join(", ")
|
175
168
|
r = execute(q, host_ids + [field]).map { |tag_name, tag_value|
|
176
169
|
[display_tag(tag_name, tag_value)]
|
177
170
|
}
|
@@ -211,12 +204,10 @@ module Hotdog
|
|
211
204
|
if @db
|
212
205
|
@db
|
213
206
|
else
|
214
|
-
FileUtils.mkdir_p(
|
215
|
-
|
216
|
-
|
217
|
-
if (not options[:force] and File.exist?(persistent) and Time.new < File.mtime(persistent) + options[:expiry]) or options[:offline]
|
207
|
+
FileUtils.mkdir_p(File.dirname(persistent_db_path))
|
208
|
+
if not options[:force] or options[:offline] or (File.exist?(persistent_db_path) and Time.new < (File.mtime(persistent_db_path) + options[:expiry]))
|
218
209
|
begin
|
219
|
-
persistent_db = SQLite3::Database.new(
|
210
|
+
persistent_db = SQLite3::Database.new(persistent_db_path)
|
220
211
|
persistent_db.execute("SELECT hosts_tags.host_id FROM hosts_tags INNER JOIN hosts ON hosts_tags.host_id = hosts.id INNER JOIN tags ON hosts_tags.tag_id = tags.id LIMIT 1;")
|
221
212
|
@db = persistent_db
|
222
213
|
rescue SQLite3::BusyException
|
@@ -239,45 +230,50 @@ module Hotdog
|
|
239
230
|
if open_db(options)
|
240
231
|
@db
|
241
232
|
else
|
242
|
-
memory_db = SQLite3::Database.new(":memory:")
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
233
|
+
memory_db = create_db(SQLite3::Database.new(":memory:"), options)
|
234
|
+
# backup in-memory db to file
|
235
|
+
FileUtils.mkdir_p(File.dirname(persistent_db_path))
|
236
|
+
persistent_db = SQLite3::Database.new(persistent_db_path)
|
237
|
+
copy_db(memory_db, persistent_db)
|
238
|
+
close_db(memory_db)
|
239
|
+
@db = persistent_db
|
240
|
+
end
|
241
|
+
end
|
249
242
|
|
250
|
-
|
243
|
+
def create_db(db, options={})
|
244
|
+
options = @options.merge(options)
|
245
|
+
execute_db(db, "CREATE TABLE IF NOT EXISTS hosts (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(255) NOT NULL COLLATE NOCASE);")
|
246
|
+
execute_db(db, "CREATE UNIQUE INDEX IF NOT EXISTS hosts_name ON hosts (name);")
|
247
|
+
execute_db(db, "CREATE TABLE IF NOT EXISTS tags (id INTEGER PRIMARY KEY AUTOINCREMENT, name VARCHAR(200) NOT NULL COLLATE NOCASE, value VARCHAR(200) NOT NULL COLLATE NOCASE);")
|
248
|
+
execute_db(db, "CREATE UNIQUE INDEX IF NOT EXISTS tags_name_value ON tags (name, value);")
|
249
|
+
execute_db(db, "CREATE TABLE IF NOT EXISTS hosts_tags (host_id INTEGER NOT NULL, tag_id INTEGER NOT NULL);")
|
250
|
+
execute_db(db, "CREATE UNIQUE INDEX IF NOT EXISTS hosts_tags_host_id_tag_id ON hosts_tags (host_id, tag_id);")
|
251
251
|
|
252
|
-
|
253
|
-
known_tags = all_tags.keys.map { |tag| split_tag(tag) }.uniq
|
254
|
-
create_tags(memory_db, known_tags)
|
252
|
+
all_tags = get_all_tags()
|
255
253
|
|
256
|
-
|
257
|
-
|
254
|
+
db.transaction do
|
255
|
+
known_tags = all_tags.keys.map { |tag| split_tag(tag) }.uniq
|
256
|
+
create_tags(db, known_tags)
|
258
257
|
|
259
|
-
|
260
|
-
|
261
|
-
end
|
262
|
-
end
|
258
|
+
known_hosts = all_tags.values.reduce(:+).uniq
|
259
|
+
create_hosts(db, known_hosts)
|
263
260
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
FileUtils.rm_f(persistent)
|
268
|
-
persistent_db = SQLite3::Database.new(persistent)
|
269
|
-
copy_db(memory_db, persistent_db)
|
270
|
-
close_db(memory_db)
|
271
|
-
@db = persistent_db
|
261
|
+
all_tags.each do |tag, hosts|
|
262
|
+
associate_tag_hosts(db, tag, hosts)
|
263
|
+
end
|
272
264
|
end
|
265
|
+
|
266
|
+
db
|
273
267
|
end
|
274
268
|
|
275
|
-
def remove_db(options={})
|
269
|
+
def remove_db(db, options={})
|
276
270
|
options = @options.merge(options)
|
277
|
-
if
|
278
|
-
close_db(
|
271
|
+
if db
|
272
|
+
close_db(db)
|
273
|
+
end
|
274
|
+
if File.exist?(persistent_db_path)
|
275
|
+
FileUtils.touch(persistent_db_path, mtime: Time.new - options[:expiry])
|
279
276
|
end
|
280
|
-
FileUtils.rm_f(File.join(options[:confdir], PERSISTENT_DB))
|
281
277
|
end
|
282
278
|
|
283
279
|
def execute_db(db, q, args=[])
|
@@ -329,22 +325,29 @@ module Hotdog
|
|
329
325
|
q = "INSERT OR IGNORE INTO hosts (name) VALUES %s" % hosts.map { "(?)" }.join(", ")
|
330
326
|
execute_db(db, q, hosts)
|
331
327
|
end
|
328
|
+
# create virtual `host` tag
|
329
|
+
execute_db(db, "INSERT OR IGNORE INTO tags (name, value) SELECT 'host', hosts.name FROM hosts;")
|
330
|
+
q = "INSERT OR REPLACE INTO hosts_tags (host_id, tag_id) " \
|
331
|
+
"SELECT hosts.id, tags.id FROM hosts " \
|
332
|
+
"INNER JOIN ( SELECT * FROM tags WHERE name = 'host' ) AS tags " \
|
333
|
+
"ON hosts.name = tags.value;"
|
334
|
+
execute_db(db, q)
|
332
335
|
end
|
333
336
|
|
334
337
|
def create_tags(db, tags)
|
335
338
|
tags.each_slice(SQLITE_LIMIT_COMPOUND_SELECT / 2) do |tags|
|
336
|
-
q = "INSERT OR IGNORE INTO tags (name, value) VALUES %s" % tags.map { "(?, ?)" }.join(", ")
|
339
|
+
q = "INSERT OR IGNORE INTO tags (name, value) VALUES %s;" % tags.map { "(?, ?)" }.join(", ")
|
337
340
|
execute_db(db, q, tags)
|
338
341
|
end
|
339
342
|
end
|
340
343
|
|
341
344
|
def associate_tag_hosts(db, tag, hosts)
|
342
345
|
hosts.each_slice(SQLITE_LIMIT_COMPOUND_SELECT - 2) do |hosts|
|
343
|
-
q = "INSERT OR REPLACE INTO hosts_tags (host_id, tag_id) " \
|
344
|
-
"SELECT host.id, tag.id FROM " \
|
345
|
-
"( SELECT id FROM hosts WHERE name IN (%s) ) AS host, " \
|
346
|
-
"( SELECT id FROM tags WHERE name = ? AND value = ? LIMIT 1 ) AS tag;" % hosts.map { "?" }.join(", ")
|
347
346
|
begin
|
347
|
+
q = "INSERT OR REPLACE INTO hosts_tags (host_id, tag_id) " \
|
348
|
+
"SELECT host.id, tag.id FROM " \
|
349
|
+
"( SELECT id FROM hosts WHERE name IN (%s) ) AS host, " \
|
350
|
+
"( SELECT id FROM tags WHERE name = ? AND value = ? LIMIT 1 ) AS tag;" % hosts.map { "?" }.join(", ")
|
348
351
|
execute_db(db, q, (hosts + split_tag(tag)))
|
349
352
|
rescue SQLite3::RangeException => error
|
350
353
|
# FIXME: bulk insert occationally fails even if there are no errors in bind parameters
|
@@ -364,8 +367,7 @@ module Hotdog
|
|
364
367
|
def disassociate_tag_hosts(db, tag, hosts)
|
365
368
|
hosts.each_slice(SQLITE_LIMIT_COMPOUND_SELECT - 2) do |hosts|
|
366
369
|
q = "DELETE FROM hosts_tags " \
|
367
|
-
"WHERE tag_id IN ( SELECT id FROM tags WHERE name = ? AND value = ? LIMIT 1 );"
|
368
|
-
"AND host_id IN ( SELECT id FROM hosts WHERE name IN (%s) ) " % hosts.map { "?" }.join(", ")
|
370
|
+
"WHERE tag_id IN ( SELECT id FROM tags WHERE name = ? AND value = ? LIMIT 1 ) AND host_id IN ( SELECT id FROM hosts WHERE name IN (%s) );" % hosts.map { "?" }.join(", ")
|
369
371
|
execute_db(db, q, split_tag(tag) + hosts)
|
370
372
|
end
|
371
373
|
end
|
@@ -404,6 +406,10 @@ module Hotdog
|
|
404
406
|
end
|
405
407
|
raise("retry count exceeded")
|
406
408
|
end
|
409
|
+
|
410
|
+
def persistent_db_path()
|
411
|
+
File.join(options[:confdir], PERSISTENT_DB)
|
412
|
+
end
|
407
413
|
end
|
408
414
|
end
|
409
415
|
end
|
@@ -41,7 +41,7 @@ module Hotdog
|
|
41
41
|
end
|
42
42
|
else
|
43
43
|
# workaround for "too many terms in compound SELECT"
|
44
|
-
min, max = environment.execute("SELECT MIN(id), MAX(id) FROM hosts
|
44
|
+
min, max = environment.execute("SELECT MIN(id), MAX(id) FROM hosts LIMIT 1;").first.to_a
|
45
45
|
(min / (SQLITE_LIMIT_COMPOUND_SELECT - 2)).upto(max / (SQLITE_LIMIT_COMPOUND_SELECT - 2)).flat_map { |i|
|
46
46
|
range = ((SQLITE_LIMIT_COMPOUND_SELECT - 2) * i)...((SQLITE_LIMIT_COMPOUND_SELECT - 2) * (i + 1))
|
47
47
|
selected = values.select { |n| range === n }
|
@@ -150,7 +150,7 @@ module Hotdog
|
|
150
150
|
[]
|
151
151
|
else
|
152
152
|
# workaround for "too many terms in compound SELECT"
|
153
|
-
min, max = environment.execute("SELECT MIN(id), MAX(id) FROM hosts
|
153
|
+
min, max = environment.execute("SELECT MIN(id), MAX(id) FROM hosts LIMIT 1;").first.to_a
|
154
154
|
(min / ((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 2)).upto(max / ((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 2)).flat_map { |i|
|
155
155
|
range = (((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 2) * i)...(((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 2) * (i + 1))
|
156
156
|
left_selected = left_values.select { |n| range === n }
|
@@ -177,7 +177,7 @@ module Hotdog
|
|
177
177
|
[]
|
178
178
|
else
|
179
179
|
# workaround for "too many terms in compound SELECT"
|
180
|
-
min, max = environment.execute("SELECT MIN(id), MAX(id) FROM hosts
|
180
|
+
min, max = environment.execute("SELECT MIN(id), MAX(id) FROM hosts LIMIT 1;").first.to_a
|
181
181
|
(min / ((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 2)).upto(max / ((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 2)).flat_map { |i|
|
182
182
|
range = (((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 2) * i)...(((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 2) * (i + 1))
|
183
183
|
left_selected = left_values.select { |n| range === n }
|
@@ -204,7 +204,7 @@ module Hotdog
|
|
204
204
|
[]
|
205
205
|
else
|
206
206
|
# workaround for "too many terms in compound SELECT"
|
207
|
-
min, max = environment.execute("SELECT MIN(id), MAX(id) FROM hosts
|
207
|
+
min, max = environment.execute("SELECT MIN(id), MAX(id) FROM hosts LIMIT 1;").first.to_a
|
208
208
|
(min / ((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 4)).upto(max / ((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 4)).flat_map { |i|
|
209
209
|
range = (((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 4) * i)...(((SQLITE_LIMIT_COMPOUND_SELECT - 2) / 4) * (i + 1))
|
210
210
|
left_selected = left_values.select { |n| range === n }
|
@@ -529,7 +529,7 @@ module Hotdog
|
|
529
529
|
|
530
530
|
class EverythingNode < QueryExpressionNode
|
531
531
|
def initialize(options={})
|
532
|
-
super("SELECT id AS host_id FROM hosts", [], options)
|
532
|
+
super("SELECT id AS host_id FROM hosts;", [], options)
|
533
533
|
end
|
534
534
|
end
|
535
535
|
|
data/lib/hotdog/version.rb
CHANGED
data/spec/core/commands_spec.rb
CHANGED
@@ -51,7 +51,7 @@ describe "commands" do
|
|
51
51
|
q1 = [
|
52
52
|
"SELECT DISTINCT tags.name FROM hosts_tags",
|
53
53
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
54
|
-
"WHERE hosts_tags.host_id IN (?, ?, ?);",
|
54
|
+
"WHERE hosts_tags.host_id IN (?, ?, ?) ORDER BY hosts_tags.host_id;",
|
55
55
|
]
|
56
56
|
allow(cmd).to receive(:execute).with(q1.join(" "), [1, 2, 3]) {
|
57
57
|
[["foo"], ["bar"], ["baz"]]
|
@@ -67,7 +67,7 @@ describe "commands" do
|
|
67
67
|
q1 = [
|
68
68
|
"SELECT DISTINCT tags.name FROM hosts_tags",
|
69
69
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
70
|
-
"WHERE hosts_tags.host_id IN (?, ?, ?);",
|
70
|
+
"WHERE hosts_tags.host_id IN (?, ?, ?) ORDER BY hosts_tags.host_id;",
|
71
71
|
]
|
72
72
|
allow(cmd).to receive(:execute).with(q1.join(" "), [1, 2, 3]) {
|
73
73
|
[["foo"], ["bar"], ["baz"]]
|
@@ -100,23 +100,20 @@ describe "commands" do
|
|
100
100
|
end
|
101
101
|
|
102
102
|
it "get host fields with host" do
|
103
|
-
allow(cmd).to receive(:execute).with("SELECT id, name FROM hosts WHERE id IN (?, ?, ?);", [1, 2, 3]) {
|
104
|
-
[[1, "host1"], [2, "host2"], [3, "host3"]]
|
105
|
-
}
|
106
103
|
q1 = [
|
107
104
|
"SELECT LOWER(tags.name), GROUP_CONCAT(tags.value, ',') FROM hosts_tags",
|
108
105
|
"INNER JOIN tags ON hosts_tags.tag_id = tags.id",
|
109
|
-
"WHERE hosts_tags.host_id = ? AND tags.name IN (?, ?)",
|
106
|
+
"WHERE hosts_tags.host_id = ? AND tags.name IN (?, ?, ?)",
|
110
107
|
"GROUP BY tags.name;",
|
111
108
|
]
|
112
|
-
allow(cmd).to receive(:execute).with(q1.join(" "), [1, "foo", "bar"]) {
|
113
|
-
[["foo", "foo1"], ["bar", "bar1"]]
|
109
|
+
allow(cmd).to receive(:execute).with(q1.join(" "), [1, "foo", "bar", "host"]) {
|
110
|
+
[["foo", "foo1"], ["bar", "bar1"], ["host", "host1"]]
|
114
111
|
}
|
115
|
-
allow(cmd).to receive(:execute).with(q1.join(" "), [2, "foo", "bar"]) {
|
116
|
-
[["foo", "foo2"], ["bar", "bar2"]]
|
112
|
+
allow(cmd).to receive(:execute).with(q1.join(" "), [2, "foo", "bar", "host"]) {
|
113
|
+
[["foo", "foo2"], ["bar", "bar2"], ["host", "host2"]]
|
117
114
|
}
|
118
|
-
allow(cmd).to receive(:execute).with(q1.join(" "), [3, "foo", "bar"]) {
|
119
|
-
[["foo", "foo3"], ["bar", "bar3"]]
|
115
|
+
allow(cmd).to receive(:execute).with(q1.join(" "), [3, "foo", "bar", "host"]) {
|
116
|
+
[["foo", "foo3"], ["bar", "bar3"], ["host", "host3"]]
|
120
117
|
}
|
121
118
|
expect(cmd.__send__(:get_hosts_fields, [1, 2, 3], ["foo", "bar", "host"])).to eq([[["foo1", "bar1", "host1"], ["foo2", "bar2", "host2"], ["foo3", "bar3", "host3"]], ["foo", "bar", "host"]])
|
122
119
|
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.
|
4
|
+
version: 0.19.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: 2016-12-
|
11
|
+
date: 2016-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
237
|
version: '0'
|
238
238
|
requirements: []
|
239
239
|
rubyforge_project:
|
240
|
-
rubygems_version: 2.5.
|
240
|
+
rubygems_version: 2.5.2
|
241
241
|
signing_key:
|
242
242
|
specification_version: 4
|
243
243
|
summary: Yet another command-line tool for Datadog
|