td 0.15.6 → 0.15.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aeea977d9b1b808bebfbd473065044eb5cc1461a
4
- data.tar.gz: cedb2ab5d9018f730218378cd64ed8970be0ead2
3
+ metadata.gz: 7bb4903ebbe92100825f6fb8c768a4b43135e32e
4
+ data.tar.gz: 6c2fce67432e0d56d536971b5b75e164d88a8bc4
5
5
  SHA512:
6
- metadata.gz: 31ef757d8f8d902f7ba41eacedfb604a48178e456386ece4e13a21db375015d48d58e4eada1e5d09497492d021cc51357152685e68d292f720ce4af66194b9a3
7
- data.tar.gz: 120425e60e43c3de310c8033039296d7ff5c1ad1c51e4b6ed811174ccf5ab2dcfb70b5a8970e6fdd31a54d6f85b13df314ad8930457c0413de1ad9f32e00f75c
6
+ metadata.gz: 39f2f0b420f772c670990e1303a037f626bf989c208a75103724fbc24359755335d68fc1623b1c8aaadbcca964280164aea34636cbde90eb653c298274bf6462
7
+ data.tar.gz: 0c4b3cc6037493a693d8d283160136bd2b7bda2f701aaab7705895322285bc388df348646245d96e214c5f338298904fbacca113bed86477945dccf9a7ae1126
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ == 2017-10-24 version 0.15.7
2
+
3
+ * Support workflow on aws tokyo #94
4
+
1
5
  == 2017-09-21 version 0.15.6
2
6
 
3
7
  * Update td-client gem dependency to 1.0.4
@@ -26,13 +26,18 @@ module TreasureData
26
26
  env = {}
27
27
  digdag_config_path = File.join(wd, 'config')
28
28
  FileUtils.touch(digdag_config_path)
29
- if Config.cl_apikey
29
+ workflow_endpoint = Config.workflow_endpoint
30
+
31
+ # In the future passing config to digdag should use environment variables
32
+ if Config.cl_apikey || workflow_endpoint != 'https://api-workflow.treasuredata.com'
30
33
  # If the user passes the apikey on the command line we cannot use the digdag td.conf plugin.
31
34
  # Instead, create a digdag configuration file with the endpoint and the specified apikey.
32
- env['TD_CONFIG_PATH'] = nil
33
35
  apikey = TreasureData::Config.apikey
36
+ env['TD_CONFIG_PATH'] = nil
37
+ env['TREASURE_DATA_WORKFLOW_ENDPOINT'] = workflow_endpoint
38
+ env['TD_API_KEY'] = apikey
34
39
  File.write(digdag_config_path, [
35
- 'client.http.endpoint = https://api-workflow.treasuredata.com',
40
+ "client.http.endpoint = #{workflow_endpoint}",
36
41
  "client.http.headers.authorization = TD1 #{apikey}",
37
42
  "secrets.td.apikey = #{apikey}"
38
43
  ].join($/) + $/)
data/lib/td/config.rb CHANGED
@@ -160,6 +160,21 @@ class Config
160
160
  @@cl_endpoint = flag
161
161
  end
162
162
 
163
+ def self.workflow_endpoint
164
+ case self.endpoint.to_s.sub(%r[https?://], '')
165
+ when '', 'api.treasuredata.com'
166
+ 'https://api-workflow.treasuredata.com'
167
+ when 'api-staging.treasuredata.com'
168
+ 'https://api-staging-workflow.treasuredata.com'
169
+ when 'api.treasuredata.co.jp'
170
+ 'https://api-workflow.treasuredata.co.jp'
171
+ when 'api-staging.treasuredata.co.jp'
172
+ 'https://api-staging-workflow.treasuredata.co.jp'
173
+ else
174
+ raise ConfigError, "Workflow is not supported for '#{self.endpoint}'"
175
+ end
176
+ end
177
+
163
178
  # renders the apikey and endpoint options as a string for the helper commands
164
179
  def self.cl_options_string
165
180
  string = ""
data/lib/td/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TreasureData
2
- TOOLBELT_VERSION = '0.15.6'
2
+ TOOLBELT_VERSION = '0.15.7'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -21,6 +21,15 @@ unless ENV['APPVEYOR']
21
21
  Coveralls.wear!('rails')
22
22
  end
23
23
 
24
+ RSpec.configure do |config|
25
+ # This allows you to limit a spec run to individual examples or groups
26
+ # you care about by tagging them with `:focus` metadata. When nothing
27
+ # is tagged with `:focus`, all examples get run. RSpec also provides
28
+ # aliases for `it`, `describe`, and `context` that include `:focus`
29
+ # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
30
+ config.filter_run_when_matching :focus
31
+ end
32
+
24
33
  require 'td/command/runner'
25
34
 
26
35
  def execute_td(command_line)
@@ -325,4 +325,84 @@ EOF
325
325
  end
326
326
  end
327
327
  end
328
+
329
+ describe 'verify argument with mock' do
330
+ let(:command) { Class.new { include TreasureData::Command }.new }
331
+ let(:empty_option) { List::CommandParser.new("workflow", [], [], nil, [], true) }
332
+ let(:td_config){ TreasureData::Config.new }
333
+ let(:workflow_config){ Hash.new }
334
+ let(:digdag_env){ Hash.new }
335
+ let(:config_path){ nil }
336
+ let(:apikey){ nil }
337
+ let(:endpoint){ nil }
338
+ before do
339
+ # TreasureData::Command::Runner#run
340
+ if config_path
341
+ TreasureData::Config.path = config_path
342
+ end
343
+ if apikey
344
+ TreasureData::Config.apikey = apikey
345
+ TreasureData::Config.cl_apikey = true
346
+ end
347
+ if endpoint
348
+ TreasureData::Config.endpoint = endpoint
349
+ TreasureData::Config.cl_endpoint = true
350
+ end
351
+
352
+ allow(Kernel).to receive(:system) do |env, *cmd|
353
+ digdag_env.replace env
354
+ cmd = cmd.dup
355
+ args = {nil => []}
356
+ while x = cmd.shift
357
+ case x
358
+ when /\A--\w+\z/
359
+ args[x] = cmd.shift
360
+ when /\A-[a-z]+\z/
361
+ args[x] = cmd.shift
362
+ when /\A(-[A-Z][^=]*)(?:=(.*))?\z/
363
+ args[$1] = $2
364
+ else
365
+ args[nil] << x
366
+ end
367
+ end
368
+ if args['--config']
369
+ File.foreach(args['--config']) do |line|
370
+ k, v = line.strip.split(/\s*=\s*/, 2)
371
+ workflow_config[k] = v
372
+ end
373
+ end
374
+ td_config_path =
375
+ env['TREASURE_DATA_CONFIG_PATH'] ||
376
+ env['TD_CONFIG_PATH'] ||
377
+ "#{Dir.home}/.config/.td/td.conf"
378
+ if File.exist?(td_config_path) && args['-Dio.digdag.standards.td.secrets.enabled'] != 'false'
379
+ td_config.read(td_config_path)
380
+ end
381
+ 0
382
+ end
383
+ end
384
+ context 'endpoint: https://api.treasuredata.com' do
385
+ let (:endpoint){ 'https://api.treasuredata.com' }
386
+ it 'uses td.conf' do
387
+ apikey = '1/deadbeaf'
388
+ TreasureData::Config.apikey = apikey # emulate to load from config file
389
+ op = List::CommandParser.new("workflow", [], [], nil, ['version'], true)
390
+ command.workflow(op, false, false)
391
+ expect(workflow_config).to eq({})
392
+ expect(digdag_env['TREASURE_DATA_WORKFLOW_ENDPOINT']).to be_nil
393
+ end
394
+ end
395
+ context 'endpoint: https://api.treasuredata.co.jp' do
396
+ let(:apikey){ '1/deadbeaf' }
397
+ let (:endpoint){ 'https://api.treasuredata.co.jp' }
398
+ it 'writes temporary workflow conf' do
399
+ op = List::CommandParser.new("workflow", [], [], nil, ['version'], true)
400
+ command.workflow(op, false, false)
401
+ expect(workflow_config['client.http.endpoint']).to eq 'https://api-workflow.treasuredata.co.jp'
402
+ expect(workflow_config['client.http.headers.authorization']).to eq "TD1 #{apikey}"
403
+ expect(workflow_config['secrets.td.apikey']).to eq apikey
404
+ expect(digdag_env['TREASURE_DATA_WORKFLOW_ENDPOINT']).to eq 'https://api-workflow.treasuredata.co.jp'
405
+ end
406
+ end
407
+ end
328
408
  end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'td/config'
3
+
4
+ describe TreasureData::Config do
5
+ context 'workflow_endpoint' do
6
+ before { TreasureData::Config.endpoint = api_endpoint }
7
+ subject { TreasureData::Config.workflow_endpoint }
8
+ context 'api.treasuredata.com' do
9
+ context 'works without http schema' do
10
+ let(:api_endpoint){ 'api.treasuredata.com' }
11
+ it { is_expected.to eq 'https://api-workflow.treasuredata.com' }
12
+ end
13
+ context 'works with http schema' do
14
+ let(:api_endpoint){ 'http://api.treasuredata.com' }
15
+ it { is_expected.to eq 'https://api-workflow.treasuredata.com' }
16
+ end
17
+ context 'works with https schema' do
18
+ let(:api_endpoint){ 'https://api.treasuredata.com' }
19
+ it { is_expected.to eq 'https://api-workflow.treasuredata.com' }
20
+ end
21
+ end
22
+ context 'api.treasuredata.co.jp' do
23
+ let(:api_endpoint){ 'api.treasuredata.co.jp' }
24
+ it { is_expected.to eq 'https://api-workflow.treasuredata.co.jp' }
25
+ end
26
+ context 'api-staging.treasuredata.com' do
27
+ let(:api_endpoint){ 'api-staging.treasuredata.com' }
28
+ it { is_expected.to eq 'https://api-staging-workflow.treasuredata.com' }
29
+ end
30
+ context 'api-staging.treasuredata.co.jp' do
31
+ let(:api_endpoint){ 'api-staging.treasuredata.co.jp' }
32
+ it { is_expected.to eq 'https://api-staging-workflow.treasuredata.co.jp' }
33
+ end
34
+ context 'ybi.jp-east.idcfcloud.com' do
35
+ let(:api_endpoint){ 'ybi.jp-east.idcfcloud.com' }
36
+ it 'raise error' do
37
+ expect { subject }.to raise_error(TreasureData::ConfigError)
38
+ end
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.6
4
+ version: 0.15.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Treasure Data, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-21 00:00:00.000000000 Z
11
+ date: 2017-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -280,6 +280,7 @@ files:
280
280
  - spec/td/command/workflow_spec.rb
281
281
  - spec/td/common_spec.rb
282
282
  - spec/td/compact_format_yamler_spec.rb
283
+ - spec/td/config_spec.rb
283
284
  - spec/td/connector_config_normalizer_spec.rb
284
285
  - spec/td/fixture/bulk_load.yml
285
286
  - spec/td/fixture/ca.cert
@@ -332,6 +333,7 @@ test_files:
332
333
  - spec/td/command/workflow_spec.rb
333
334
  - spec/td/common_spec.rb
334
335
  - spec/td/compact_format_yamler_spec.rb
336
+ - spec/td/config_spec.rb
335
337
  - spec/td/connector_config_normalizer_spec.rb
336
338
  - spec/td/fixture/bulk_load.yml
337
339
  - spec/td/fixture/ca.cert