td 0.16.6 → 0.16.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +96 -0
- data/.github/CODEOWNERS +1 -0
- data/ChangeLog +22 -0
- data/README.rdoc +7 -7
- data/appveyor.yml +2 -2
- data/lib/td/command/account.rb +1 -1
- data/lib/td/command/common.rb +14 -8
- data/lib/td/command/export.rb +3 -0
- data/lib/td/command/query.rb +2 -0
- data/lib/td/command/runner.rb +15 -1
- data/lib/td/command/table.rb +10 -8
- data/lib/td/command/workflow.rb +12 -3
- data/lib/td/config.rb +26 -6
- data/lib/td/file_reader.rb +2 -2
- data/lib/td/updater.rb +1 -1
- data/lib/td/version.rb +1 -1
- data/spec/td/command/table_spec.rb +4 -2
- data/spec/td/command/workflow_spec.rb +13 -0
- data/spec/td/config_spec.rb +82 -0
- data/td.gemspec +7 -4
- metadata +46 -16
- data/.travis.yml +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a372eaff21645cac711c4df4fe0faeba64a8fffed0af8d9de4367f5bdf3d4dae
|
4
|
+
data.tar.gz: b4f0c3751f57780008be2162c78853003b138d9ed691f1c7eef756a8ce6f7237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f332bc9d0cc8659e31d2f737aec26c827a6eda4c980dd0d21ddf0df749fae5595b16950a9ba3195e76361925d190bf8aa5e016dee6f25cf49bdf139e8606363
|
7
|
+
data.tar.gz: af1d0421633676a8938be8cf77474681f05e863006c56561db18b377853ee9f8529c168d1d176a2e4f3156a1eb4acd582241765f52a8aac6ecce0e3e158e1ddf
|
@@ -0,0 +1,96 @@
|
|
1
|
+
version: 2.1
|
2
|
+
|
3
|
+
|
4
|
+
orbs:
|
5
|
+
ruby: circleci/ruby@1.1.4
|
6
|
+
win: circleci/windows@2.4.0
|
7
|
+
|
8
|
+
|
9
|
+
commands:
|
10
|
+
install_windows_requirements:
|
11
|
+
description: "Install windows requirements"
|
12
|
+
steps:
|
13
|
+
- run:
|
14
|
+
name: "Install MSYS2"
|
15
|
+
command: choco install msys2
|
16
|
+
- run:
|
17
|
+
name: "Install Ruby devkit"
|
18
|
+
command: ridk install 2 3
|
19
|
+
bundle-install:
|
20
|
+
description: "Install dependencies"
|
21
|
+
steps:
|
22
|
+
- run:
|
23
|
+
name: Which bundler?
|
24
|
+
command: bundle -v
|
25
|
+
- run:
|
26
|
+
name: Bundle install
|
27
|
+
command: bundle install
|
28
|
+
run-tests:
|
29
|
+
description: "Run tests"
|
30
|
+
steps:
|
31
|
+
- run:
|
32
|
+
name: Run tests
|
33
|
+
command: bundle exec rake spec SPEC_OPTS="-fd"
|
34
|
+
run-tests-flow:
|
35
|
+
description: "Single flow for running tests"
|
36
|
+
steps:
|
37
|
+
- checkout
|
38
|
+
- bundle-install
|
39
|
+
- run-tests
|
40
|
+
|
41
|
+
|
42
|
+
jobs:
|
43
|
+
|
44
|
+
ruby_25:
|
45
|
+
machine:
|
46
|
+
image: ubuntu-1604:202004-01
|
47
|
+
steps:
|
48
|
+
- ruby/install:
|
49
|
+
version: '2.5'
|
50
|
+
- run-tests-flow
|
51
|
+
|
52
|
+
ruby_26:
|
53
|
+
machine:
|
54
|
+
image: ubuntu-1604:202004-01
|
55
|
+
steps:
|
56
|
+
- ruby/install:
|
57
|
+
version: '2.6'
|
58
|
+
- run-tests-flow
|
59
|
+
|
60
|
+
ruby_27:
|
61
|
+
machine:
|
62
|
+
image: ubuntu-1604:202004-01
|
63
|
+
steps:
|
64
|
+
- ruby/install:
|
65
|
+
version: '2.7'
|
66
|
+
- run-tests-flow
|
67
|
+
|
68
|
+
ruby_30:
|
69
|
+
machine:
|
70
|
+
image: ubuntu-1604:202004-01
|
71
|
+
steps:
|
72
|
+
- ruby/install:
|
73
|
+
version: '3.0'
|
74
|
+
- run-tests-flow
|
75
|
+
|
76
|
+
win_ruby:
|
77
|
+
executor:
|
78
|
+
name: win/default
|
79
|
+
shell: powershell.exe
|
80
|
+
steps:
|
81
|
+
- install_windows_requirements
|
82
|
+
- run:
|
83
|
+
name: "Install bundler"
|
84
|
+
shell: powershell.exe
|
85
|
+
command: gem install bundler
|
86
|
+
- run-tests-flow
|
87
|
+
|
88
|
+
|
89
|
+
workflows:
|
90
|
+
tests:
|
91
|
+
jobs:
|
92
|
+
- ruby_25
|
93
|
+
- ruby_26
|
94
|
+
- ruby_27
|
95
|
+
- ruby_30
|
96
|
+
# - win_ruby # Not testing on windows for now due to old version of ridk. Testing in Appveyor instead, will reconsider when CircleCI update ridk in their windows image.
|
data/.github/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @treasure-data/integrations
|
data/ChangeLog
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
== 2020-09-16 version 0.16.10
|
2
|
+
|
3
|
+
* Support proxy with username and password
|
4
|
+
* Increase the summary_width value to fix the broken options help message format
|
5
|
+
* Support AP03 Region
|
6
|
+
* Change old document urls to new document urls
|
7
|
+
* Show message to ask -w option in td query
|
8
|
+
* Adding users commnad help
|
9
|
+
* Allow trailing slash for endpoints
|
10
|
+
|
11
|
+
== 2020-04-10 version 0.16.9
|
12
|
+
|
13
|
+
* Update new workflow pattern to support ap02 #232
|
14
|
+
|
15
|
+
== 2020-01-16 version 0.16.8
|
16
|
+
|
17
|
+
* Update default maven repository #230
|
18
|
+
|
19
|
+
== 2019-12-16 version 0.16.7
|
20
|
+
|
21
|
+
* Disable direct download in Private Connect #225
|
22
|
+
|
1
23
|
== 2019-11-13 version 0.16.6
|
2
24
|
|
3
25
|
* Use HTTPS as default for downloading digdag module #223
|
data/README.rdoc
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
= Treasure Data command line tool
|
2
|
-
{<img src="https://
|
2
|
+
{<img src="https://circleci.com/gh/treasure-data/td.svg?style=svg" alt="Build Status" />}[https://circleci.com/gh/treasure-data/td.svg?style=svg]
|
3
3
|
{<img src="https://ci.appveyor.com/api/projects/status/github/treasure-data/td?branch=master&svg=true" alt="appveyor" />}[https://ci.appveyor.com/project/treasure-data/td/branch/master]
|
4
4
|
{<img src="https://coveralls.io/repos/treasure-data/td/badge.svg?branch=master&service=github" alt="Coverage Status" />}[https://coveralls.io/github/treasure-data/td?branch=master]
|
5
5
|
|
6
6
|
This CUI utility wraps the {Ruby Client Library td-client-ruby}[https://github.com/treasure-data/td-client-ruby]
|
7
7
|
to interact with the REST API in managing databases and jobs on the Treasure Data Cloud.
|
8
8
|
|
9
|
-
For more info about Treasure Data, see <
|
9
|
+
For more info about Treasure Data, see <https://www.treasuredata.com/>.
|
10
10
|
|
11
|
-
For full documentation see <https://
|
11
|
+
For full documentation see <https://docs.treasuredata.com/>.
|
12
12
|
|
13
13
|
= Getting Started
|
14
14
|
|
@@ -69,9 +69,9 @@ to process and Bulk load data in the Treasure Data Cloud.
|
|
69
69
|
|
70
70
|
The Bulk Import CLI is downloaded automatically at the first call to any of the command that require it; the use will
|
71
71
|
need internet connectivity in order to fetch the Bulk Import CLI JAR file from the
|
72
|
-
{Central Maven repository}[
|
72
|
+
{Central Maven repository}[https://repo1.maven.org/maven2/com/treasuredata/td-import/]
|
73
73
|
and take advantage of these advanced features. If you need to setup a proxy, please consult this
|
74
|
-
{documentation}[https://
|
74
|
+
{documentation}[https://docs.treasuredata.com/display/public/INT/Legacy+Bulk+Import+Tips+and+Tricks#LegacyBulkImportTipsandTricks-UsingaProxyServer] page.
|
75
75
|
|
76
76
|
The log levels and properties of the Bulk Import CLI can be configured in a +logging.properties+ file. A default
|
77
77
|
configuration is provided in a file within the gem or Toolbelt folder root, in the +java/+ folder. If you wish to
|
@@ -144,9 +144,9 @@ These are the available hooks:
|
|
144
144
|
|
145
145
|
$ TD_TOOLBELT_UPDATE_ROOT="http://toolbelt.treasuredata.com"
|
146
146
|
|
147
|
-
* Specify an alternative endpoint to use updating the JAR file (default:
|
147
|
+
* Specify an alternative endpoint to use updating the JAR file (default: https://repo1.maven.org):
|
148
148
|
|
149
|
-
$ TD_TOOLBELT_JARUPDATE_ROOT="
|
149
|
+
$ TD_TOOLBELT_JARUPDATE_ROOT="https://repo1.maven.org"
|
150
150
|
|
151
151
|
|
152
152
|
= Copyright
|
data/appveyor.yml
CHANGED
data/lib/td/command/account.rb
CHANGED
@@ -41,7 +41,7 @@ module Command
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
$stdout.puts "Enter your Treasure Data credentials. For Google SSO user, please see https://
|
44
|
+
$stdout.puts "Enter your Treasure Data credentials. For Google SSO user, please see https://docs.treasuredata.com/display/public/PD/Configuring+Authentication+for+TD+Using+the+TD+Toolbelt#ConfiguringAuthenticationforTDUsingtheTDToolbelt-SettingUpGoogleSSOUsers"
|
45
45
|
unless user_name
|
46
46
|
begin
|
47
47
|
$stdout.print "Email: "
|
data/lib/td/command/common.rb
CHANGED
@@ -47,7 +47,7 @@ module Command
|
|
47
47
|
|
48
48
|
# optional, if not provided a default is used from the ruby client library
|
49
49
|
begin
|
50
|
-
if Config.endpoint
|
50
|
+
if !opts[:endpoint] && Config.endpoint
|
51
51
|
opts[:endpoint] = Config.endpoint
|
52
52
|
end
|
53
53
|
rescue ConfigNotFoundError => e
|
@@ -67,6 +67,15 @@ module Command
|
|
67
67
|
Client.new(apikey, opts)
|
68
68
|
end
|
69
69
|
|
70
|
+
def get_import_client
|
71
|
+
import_endpoint = begin
|
72
|
+
Config.import_endpoint || nil
|
73
|
+
rescue TreasureData::ConfigNotFoundError
|
74
|
+
nil
|
75
|
+
end
|
76
|
+
get_client(endpoint: import_endpoint)
|
77
|
+
end
|
78
|
+
|
70
79
|
def get_ssl_client(opts={})
|
71
80
|
opts[:ssl] = true
|
72
81
|
get_client(opts)
|
@@ -96,7 +105,7 @@ module Command
|
|
96
105
|
headers = options[:fields]
|
97
106
|
csv_opts = {}
|
98
107
|
csv_opts[:col_sep] = "\t" if format == 'tsv'
|
99
|
-
CSV.generate('', csv_opts) { |csv|
|
108
|
+
CSV.generate('', **csv_opts) { |csv|
|
100
109
|
csv << headers
|
101
110
|
rows.each { |row|
|
102
111
|
r = []
|
@@ -357,12 +366,9 @@ EOS
|
|
357
366
|
|
358
367
|
def self.get_http_class
|
359
368
|
# use Net::HTTP::Proxy in place of Net::HTTP if a proxy is provided
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
host, port = http_proxy.split(':', 2)
|
364
|
-
port = (port ? port.to_i : 80)
|
365
|
-
return Net::HTTP::Proxy(host, port)
|
369
|
+
if ENV['HTTP_PROXY']
|
370
|
+
uri = URI.parse(ENV['HTTP_PROXY'])
|
371
|
+
return Net::HTTP::Proxy(uri.host, uri.port, uri.user, uri.password)
|
366
372
|
else
|
367
373
|
return Net::HTTP
|
368
374
|
end
|
data/lib/td/command/export.rb
CHANGED
@@ -67,6 +67,9 @@ module Command
|
|
67
67
|
encryption = nil
|
68
68
|
assume_role = nil
|
69
69
|
|
70
|
+
# Increase the summary_width value from default 32 into 36, to show the options help message properly.
|
71
|
+
op.summary_width = 36
|
72
|
+
|
70
73
|
op.on('-w', '--wait', 'wait until the job is completed', TrueClass) {|b|
|
71
74
|
wait = b
|
72
75
|
}
|
data/lib/td/command/query.rb
CHANGED
data/lib/td/command/runner.rb
CHANGED
@@ -6,11 +6,12 @@ class Runner
|
|
6
6
|
@config_path = nil
|
7
7
|
@apikey = nil
|
8
8
|
@endpoint = nil
|
9
|
+
@import_endpoint = nil
|
9
10
|
@prog_name = nil
|
10
11
|
@insecure = false
|
11
12
|
end
|
12
13
|
|
13
|
-
attr_accessor :apikey, :endpoint, :config_path, :prog_name, :insecure
|
14
|
+
attr_accessor :apikey, :endpoint, :import_endpoint, :config_path, :prog_name, :insecure
|
14
15
|
|
15
16
|
def run(argv=ARGV)
|
16
17
|
require 'td/version'
|
@@ -47,7 +48,9 @@ Basic commands:
|
|
47
48
|
sched # create/delete/list schedules that run a query periodically
|
48
49
|
schema # create/delete/modify schemas of tables
|
49
50
|
connector # manage connectors
|
51
|
+
users # show/create/list users
|
50
52
|
workflow # manage workflows
|
53
|
+
user # manage users
|
51
54
|
|
52
55
|
Additional commands:
|
53
56
|
|
@@ -73,6 +76,7 @@ EOF
|
|
73
76
|
config_path = @config_path
|
74
77
|
apikey = @apikey
|
75
78
|
endpoint = @endpoint
|
79
|
+
import_endpoint = @import_endpoint || @endpoint
|
76
80
|
insecure = nil
|
77
81
|
$verbose = false
|
78
82
|
#$debug = false
|
@@ -94,6 +98,12 @@ EOF
|
|
94
98
|
endpoint = e
|
95
99
|
}
|
96
100
|
|
101
|
+
op.on('--import-endpoint API_IMPORT_SERVER', "specify the URL for API Import server to use (default: https://api-import.treasuredata.com).") { |e|
|
102
|
+
require 'td/command/common'
|
103
|
+
Command.validate_api_endpoint(e)
|
104
|
+
import_endpoint = e
|
105
|
+
}
|
106
|
+
|
97
107
|
op.on('--insecure', "Insecure access: disable SSL (enabled by default)") {|b|
|
98
108
|
insecure = true
|
99
109
|
}
|
@@ -140,6 +150,10 @@ EOF
|
|
140
150
|
Config.endpoint = endpoint
|
141
151
|
Config.cl_endpoint = true
|
142
152
|
end
|
153
|
+
if import_endpoint
|
154
|
+
Config.import_endpoint = import_endpoint
|
155
|
+
Config.cl_import_endpoint = true
|
156
|
+
end
|
143
157
|
if insecure
|
144
158
|
Config.secure = false
|
145
159
|
end
|
data/lib/td/command/table.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'td/helpers'
|
2
2
|
require 'td/command/job'
|
3
|
+
require 'td/client/api'
|
3
4
|
|
4
5
|
module TreasureData
|
5
6
|
module Command
|
@@ -40,7 +41,7 @@ module Command
|
|
40
41
|
if HIVE_RESERVED_KEYWORDS.include?(table_name.upcase)
|
41
42
|
$stderr.puts "* WARNING *"
|
42
43
|
$stderr.puts " '#{table_name}' is a reserved keyword in Hive. We recommend renaming the table."
|
43
|
-
$stderr.puts " For a list of all reserved keywords, see our FAQ: https://
|
44
|
+
$stderr.puts " For a list of all reserved keywords, see our FAQ: https://docs.treasuredata.com/display/public/PD/Hive+Reserved+and+Non-Reserved+Keywords"
|
44
45
|
end
|
45
46
|
|
46
47
|
client = get_client
|
@@ -170,7 +171,7 @@ module Command
|
|
170
171
|
if rows.empty?
|
171
172
|
if db_name
|
172
173
|
if databases.first.permission == :import_only
|
173
|
-
$stderr.puts "Database '#{db_name}' is import only, cannot list
|
174
|
+
$stderr.puts "Database '#{db_name}' is import only, cannot list."
|
174
175
|
else
|
175
176
|
$stderr.puts "Database '#{db_name}' has no tables."
|
176
177
|
$stderr.puts "Use '#{$prog} " + Config.cl_options_string + "table:create <db> <table>' to create a table."
|
@@ -453,17 +454,18 @@ module Command
|
|
453
454
|
import_params[:table_name] = table_name
|
454
455
|
import_params[:paths] = paths
|
455
456
|
|
456
|
-
|
457
|
+
api_client = get_client
|
458
|
+
import_client = get_import_client
|
457
459
|
|
458
460
|
if auto_create
|
459
|
-
create_database_and_table_if_not_exist(
|
461
|
+
create_database_and_table_if_not_exist(api_client, db_name, table_name)
|
460
462
|
end
|
461
463
|
|
462
|
-
do_table_import(
|
464
|
+
do_table_import(api_client, import_client, import_params)
|
463
465
|
end
|
464
466
|
|
465
467
|
private
|
466
|
-
def do_table_import(
|
468
|
+
def do_table_import(api_client, import_client, import_params)
|
467
469
|
case import_params[:format]
|
468
470
|
when 'json', 'msgpack'
|
469
471
|
#unless time_key
|
@@ -488,7 +490,7 @@ module Command
|
|
488
490
|
end
|
489
491
|
|
490
492
|
begin
|
491
|
-
db =
|
493
|
+
db = api_client.database(import_params[:db_name])
|
492
494
|
rescue ForbiddenError => e
|
493
495
|
$stdout.puts "Warning: database and table validation skipped - #{e.message}"
|
494
496
|
else
|
@@ -521,7 +523,7 @@ module Command
|
|
521
523
|
#require 'thread'
|
522
524
|
|
523
525
|
files.zip(import_params[:paths]).each {|file, path|
|
524
|
-
import_log_file(file, path,
|
526
|
+
import_log_file(file, path, import_client, import_params[:db_name], import_params[:table_name], parser)
|
525
527
|
}
|
526
528
|
|
527
529
|
$stdout.puts "done."
|
data/lib/td/command/workflow.rb
CHANGED
@@ -43,6 +43,9 @@ module TreasureData
|
|
43
43
|
].join($/) + $/)
|
44
44
|
cmd << '-Dio.digdag.standards.td.secrets.enabled=false'
|
45
45
|
cmd << "-Dconfig.td.default_endpoint=#{Config.endpoint_domain}"
|
46
|
+
if workflow_endpoint.match(/\.connect\./i)
|
47
|
+
cmd << '-Dclient.http.disable_direct_download=true'
|
48
|
+
end
|
46
49
|
else
|
47
50
|
# Use the digdag td.conf plugin to configure wf api and apikey.
|
48
51
|
env['TREASURE_DATA_CONFIG_PATH'] = Config.path
|
@@ -243,14 +246,20 @@ EOF
|
|
243
246
|
return false
|
244
247
|
end
|
245
248
|
if output =~ /openjdk version/ or output =~ /java version/
|
246
|
-
m = output.match(/version "(\d+)\.(\d+)\.(\d+)(?:_(\d+))"/)
|
249
|
+
m = output.match(/version "(\d+)\.(\d+)\.(\d+)(?:_(\d+))?"/)
|
247
250
|
if not m or m.size < 4
|
248
251
|
return false
|
249
252
|
end
|
250
|
-
# Check for at least Java 8. Let digdag itself verify revision.
|
251
253
|
major = m[1].to_i
|
252
254
|
minor = m[2].to_i
|
253
|
-
|
255
|
+
# Check for at least Java 8. Let digdag itself verify revision.
|
256
|
+
if major < 1
|
257
|
+
return false
|
258
|
+
elsif major == 1 # suppose the version style: 1.8.10_52 (JDK8 and before)
|
259
|
+
if minor < 8
|
260
|
+
return false
|
261
|
+
end
|
262
|
+
elsif major < 9 # suppose the version style: 11.0.2
|
254
263
|
return false
|
255
264
|
end
|
256
265
|
end
|
data/lib/td/config.rb
CHANGED
@@ -21,6 +21,9 @@ class Config
|
|
21
21
|
@@endpoint = ENV['TREASURE_DATA_API_SERVER'] || ENV['TD_API_SERVER']
|
22
22
|
@@endpoint = nil if @@endpoint == ""
|
23
23
|
@@cl_endpoint = false # flag to indicate whether an endpoint has been provided through the command-line
|
24
|
+
@@import_endpoint = ENV['TREASURE_DATA_API_IMPORT_SERVER'] || ENV['TD_API_IMPORT_SERVER']
|
25
|
+
@@import_endpoint = nil if @@endpoint == ""
|
26
|
+
@@cl_import_endpoint = false # flag to indicate whether an endpoint has been provided through the command-line option
|
24
27
|
@@secure = true
|
25
28
|
@@retry_post_requests = false
|
26
29
|
|
@@ -145,7 +148,8 @@ class Config
|
|
145
148
|
|
146
149
|
|
147
150
|
def self.endpoint
|
148
|
-
@@endpoint || Config.read['account.endpoint']
|
151
|
+
endpoint = @@endpoint || Config.read['account.endpoint']
|
152
|
+
endpoint.sub(/(\/)+$/, '') if endpoint
|
149
153
|
end
|
150
154
|
|
151
155
|
def self.endpoint=(endpoint)
|
@@ -164,9 +168,26 @@ class Config
|
|
164
168
|
@@cl_endpoint = flag
|
165
169
|
end
|
166
170
|
|
171
|
+
def self.import_endpoint
|
172
|
+
endpoint = @@import_endpoint || Config.read['account.import_endpoint']
|
173
|
+
endpoint.sub(/(\/)+$/, '') if endpoint
|
174
|
+
end
|
175
|
+
|
176
|
+
def self.import_endpoint=(endpoint)
|
177
|
+
@@import_endpoint = endpoint
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.cl_import_endpoint
|
181
|
+
@@cl_import_endpoint
|
182
|
+
end
|
183
|
+
|
184
|
+
def self.cl_import_endpoint=(flag)
|
185
|
+
@@cl_import_endpoint = flag
|
186
|
+
end
|
187
|
+
|
167
188
|
def self.workflow_endpoint
|
168
189
|
case self.endpoint_domain
|
169
|
-
when /\Aapi(-(?:staging|development))?(-[a-z0-9]+)?\.(connect\.)?(eu01\.)?treasuredata\.(com|co\.jp)\z/i
|
190
|
+
when /\Aapi(-(?:staging|development))?(-[a-z0-9]+)?\.(connect\.)?((?:eu01|ap02|ap03)\.)?treasuredata\.(com|co\.jp)\z/i
|
170
191
|
"https://api#{$1}-workflow#{$2}.#{$3}#{$4}treasuredata.#{$5}"
|
171
192
|
else
|
172
193
|
raise ConfigError, "Workflow is not supported for '#{self.endpoint}'"
|
@@ -176,10 +197,9 @@ class Config
|
|
176
197
|
# renders the apikey and endpoint options as a string for the helper commands
|
177
198
|
def self.cl_options_string
|
178
199
|
string = ""
|
179
|
-
string += "-k #{@@apikey}" if @@cl_apikey
|
180
|
-
string += " "
|
181
|
-
string += "-
|
182
|
-
string += " " unless string.empty?
|
200
|
+
string += "-k #{@@apikey} " if @@cl_apikey
|
201
|
+
string += "-e #{@@endpoint} " if @@cl_endpoint
|
202
|
+
string += "--import-endpoint #{@@import_endpoint} " if @@cl_import_endpoint
|
183
203
|
string
|
184
204
|
end
|
185
205
|
|
data/lib/td/file_reader.rb
CHANGED
@@ -96,10 +96,10 @@ module TreasureData
|
|
96
96
|
csv_opts[:quote_char] = opts[:quote_char] if opts[:quote_char]
|
97
97
|
begin
|
98
98
|
require 'fastercsv'
|
99
|
-
@io = FasterCSV.new(io, csv_opts)
|
99
|
+
@io = FasterCSV.new(io, **csv_opts)
|
100
100
|
rescue LoadError => e
|
101
101
|
require 'csv'
|
102
|
-
@io = CSV.new(io, csv_opts)
|
102
|
+
@io = CSV.new(io, **csv_opts)
|
103
103
|
end
|
104
104
|
@error = error
|
105
105
|
# @escape_char = opts[:escape_char]
|
data/lib/td/updater.rb
CHANGED
data/lib/td/version.rb
CHANGED
@@ -302,6 +302,7 @@ module TreasureData::Command
|
|
302
302
|
let(:db_name) { 'database' }
|
303
303
|
let(:table_name) { 'table' }
|
304
304
|
let(:client) { double('client') }
|
305
|
+
let(:import_client) { double('import-client') }
|
305
306
|
let(:command) { Class.new { include TreasureData::Command }.new }
|
306
307
|
|
307
308
|
describe 'auto create table' do
|
@@ -336,6 +337,7 @@ module TreasureData::Command
|
|
336
337
|
describe 'time key' do
|
337
338
|
before do
|
338
339
|
allow(command).to receive(:get_client) { client }
|
340
|
+
allow(command).to receive(:get_import_client) { import_client }
|
339
341
|
allow(command).to receive(:do_table_import)
|
340
342
|
end
|
341
343
|
let(:input_params) {{
|
@@ -355,7 +357,7 @@ module TreasureData::Command
|
|
355
357
|
end
|
356
358
|
|
357
359
|
it "with '#{tk_option}' option" do
|
358
|
-
expect(command).to receive(:do_table_import).with(client, input_params)
|
360
|
+
expect(command).to receive(:do_table_import).with(client, import_client, input_params)
|
359
361
|
command.table_import(option)
|
360
362
|
end
|
361
363
|
end
|
@@ -371,7 +373,7 @@ module TreasureData::Command
|
|
371
373
|
end
|
372
374
|
|
373
375
|
it 'without \'-t / --time-key\' option' do
|
374
|
-
expect(command).to receive(:do_table_import).with(client, input_params)
|
376
|
+
expect(command).to receive(:do_table_import).with(client, import_client, input_params)
|
375
377
|
command.table_import(option)
|
376
378
|
end
|
377
379
|
end
|
@@ -335,6 +335,7 @@ EOF
|
|
335
335
|
let(:config_path){ nil }
|
336
336
|
let(:apikey){ nil }
|
337
337
|
let(:endpoint){ nil }
|
338
|
+
let(:command_args){ Hash.new }
|
338
339
|
before do
|
339
340
|
# TreasureData::Command::Runner#run
|
340
341
|
if config_path
|
@@ -348,6 +349,7 @@ EOF
|
|
348
349
|
TreasureData::Config.endpoint = endpoint
|
349
350
|
TreasureData::Config.cl_endpoint = true
|
350
351
|
end
|
352
|
+
command_args.clear
|
351
353
|
|
352
354
|
allow(Kernel).to receive(:system) do |env, *cmd|
|
353
355
|
digdag_env.replace env
|
@@ -365,6 +367,7 @@ EOF
|
|
365
367
|
args[nil] << x
|
366
368
|
end
|
367
369
|
end
|
370
|
+
args.each { |key, value| command_args[key] = value }
|
368
371
|
if args['--config']
|
369
372
|
File.foreach(args['--config']) do |line|
|
370
373
|
k, v = line.strip.split(/\s*=\s*/, 2)
|
@@ -402,6 +405,16 @@ EOF
|
|
402
405
|
expect(workflow_config['client.http.headers.authorization']).to eq "TD1 #{apikey}"
|
403
406
|
expect(workflow_config['secrets.td.apikey']).to eq apikey
|
404
407
|
expect(digdag_env['TREASURE_DATA_WORKFLOW_ENDPOINT']).to eq 'https://api-workflow.treasuredata.co.jp'
|
408
|
+
expect(command_args['-Dclient.http.disable_direct_download']).to be_nil
|
409
|
+
end
|
410
|
+
end
|
411
|
+
context 'endpoint: https://api-hoge.connect.treasuredata.com' do
|
412
|
+
let(:apikey){ '1/deadbeaf' }
|
413
|
+
let(:endpoint){ 'https://api-hoge.connect.treasuredata.com' }
|
414
|
+
it 'add arg to disable direct download workflow logs from Private Connect' do
|
415
|
+
op = List::CommandParser.new("workflow", [], [], nil, ['log', '8000111'], true)
|
416
|
+
command.workflow(op, false, false)
|
417
|
+
expect(command_args['-Dclient.http.disable_direct_download']).to be_truthy
|
405
418
|
end
|
406
419
|
end
|
407
420
|
end
|
data/spec/td/config_spec.rb
CHANGED
@@ -28,6 +28,14 @@ describe TreasureData::Config do
|
|
28
28
|
let(:api_endpoint){ 'api.eu01.treasuredata.com' }
|
29
29
|
it { is_expected.to eq 'https://api-workflow.eu01.treasuredata.com' }
|
30
30
|
end
|
31
|
+
context 'api.ap02.treasuredata.com' do
|
32
|
+
let(:api_endpoint){ 'api.ap02.treasuredata.com' }
|
33
|
+
it { is_expected.to eq 'https://api-workflow.ap02.treasuredata.com' }
|
34
|
+
end
|
35
|
+
context 'api.ap03.treasuredata.com' do
|
36
|
+
let(:api_endpoint){ 'api.ap03.treasuredata.com' }
|
37
|
+
it { is_expected.to eq 'https://api-workflow.ap03.treasuredata.com' }
|
38
|
+
end
|
31
39
|
|
32
40
|
context 'api-hoge.connect.treasuredata.com' do
|
33
41
|
let(:api_endpoint){ 'api-hoge.connect.treasuredata.com' }
|
@@ -50,6 +58,14 @@ describe TreasureData::Config do
|
|
50
58
|
let(:api_endpoint){ 'api-staging.eu01.treasuredata.com' }
|
51
59
|
it { is_expected.to eq 'https://api-staging-workflow.eu01.treasuredata.com' }
|
52
60
|
end
|
61
|
+
context 'api-staging.ap02.treasuredata.com' do
|
62
|
+
let(:api_endpoint){ 'api-staging.ap02.treasuredata.com' }
|
63
|
+
it { is_expected.to eq 'https://api-staging-workflow.ap02.treasuredata.com' }
|
64
|
+
end
|
65
|
+
context 'api-staging.ap03.treasuredata.com' do
|
66
|
+
let(:api_endpoint){ 'api-staging.ap03.treasuredata.com' }
|
67
|
+
it { is_expected.to eq 'https://api-staging-workflow.ap03.treasuredata.com' }
|
68
|
+
end
|
53
69
|
|
54
70
|
context 'api-development.treasuredata.com' do
|
55
71
|
let(:api_endpoint){ 'api-development.treasuredata.com' }
|
@@ -63,6 +79,14 @@ describe TreasureData::Config do
|
|
63
79
|
let(:api_endpoint){ 'api-development.eu01.treasuredata.com' }
|
64
80
|
it { is_expected.to eq 'https://api-development-workflow.eu01.treasuredata.com' }
|
65
81
|
end
|
82
|
+
context 'api-development.ap02.treasuredata.com' do
|
83
|
+
let(:api_endpoint){ 'api-development.ap02.treasuredata.com' }
|
84
|
+
it { is_expected.to eq 'https://api-development-workflow.ap02.treasuredata.com' }
|
85
|
+
end
|
86
|
+
context 'api-development.ap03.treasuredata.com' do
|
87
|
+
let(:api_endpoint){ 'api-development.ap03.treasuredata.com' }
|
88
|
+
it { is_expected.to eq 'https://api-development-workflow.ap03.treasuredata.com' }
|
89
|
+
end
|
66
90
|
|
67
91
|
context 'ybi.jp-east.idcfcloud.com' do
|
68
92
|
let(:api_endpoint){ 'ybi.jp-east.idcfcloud.com' }
|
@@ -72,6 +96,64 @@ describe TreasureData::Config do
|
|
72
96
|
end
|
73
97
|
end
|
74
98
|
|
99
|
+
describe 'allow endpoint with trailing slash' do
|
100
|
+
context 'self.endpoint' do
|
101
|
+
before { TreasureData::Config.endpoint = api_endpoint }
|
102
|
+
subject { TreasureData::Config.endpoint }
|
103
|
+
|
104
|
+
context 'api.treasuredata.com' do
|
105
|
+
let(:api_endpoint) { 'https://api.treasuredata.com/' }
|
106
|
+
it { is_expected.to eq 'https://api.treasuredata.com' }
|
107
|
+
end
|
108
|
+
context 'api.treasuredata.co.jp' do
|
109
|
+
let(:api_endpoint) { 'https://api.treasuredata.co.jp/' }
|
110
|
+
it { is_expected.to eq 'https://api.treasuredata.co.jp' }
|
111
|
+
end
|
112
|
+
context 'api.eu01.treasuredata.com' do
|
113
|
+
let(:api_endpoint) { 'https://api.eu01.treasuredata.com/' }
|
114
|
+
it { is_expected.to eq 'https://api.eu01.treasuredata.com' }
|
115
|
+
end
|
116
|
+
context 'api.ap02.treasuredata.com' do
|
117
|
+
let(:api_endpoint) { 'https://api.ap02.treasuredata.com/' }
|
118
|
+
it { is_expected.to eq 'https://api.ap02.treasuredata.com' }
|
119
|
+
end
|
120
|
+
context 'api.ap03.treasuredata.com' do
|
121
|
+
let(:api_endpoint) { 'https://api.ap03.treasuredata.com/' }
|
122
|
+
it { is_expected.to eq 'https://api.ap03.treasuredata.com' }
|
123
|
+
end
|
124
|
+
context 'api-hoge.connect.treasuredata.com' do
|
125
|
+
let(:api_endpoint){ 'https://api-hoge.connect.treasuredata.com/' }
|
126
|
+
it { is_expected.to eq 'https://api-hoge.connect.treasuredata.com' }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context 'self.import_endpoint' do
|
131
|
+
before { TreasureData::Config.import_endpoint = api_endpoint }
|
132
|
+
subject { TreasureData::Config.import_endpoint }
|
133
|
+
|
134
|
+
context 'api-import.treasuredata.com' do
|
135
|
+
let(:api_endpoint) { 'https://api-import.treasuredata.com/' }
|
136
|
+
it { is_expected.to eq 'https://api-import.treasuredata.com' }
|
137
|
+
end
|
138
|
+
context 'api-import.treasuredata.co.jp' do
|
139
|
+
let(:api_endpoint) { 'https://api-import.treasuredata.co.jp/' }
|
140
|
+
it { is_expected.to eq 'https://api-import.treasuredata.co.jp' }
|
141
|
+
end
|
142
|
+
context 'api-import.eu01.treasuredata.com' do
|
143
|
+
let(:api_endpoint) { 'https://api-import.eu01.treasuredata.com/' }
|
144
|
+
it { is_expected.to eq 'https://api-import.eu01.treasuredata.com' }
|
145
|
+
end
|
146
|
+
context 'api-import.ap02.treasuredata.com' do
|
147
|
+
let(:api_endpoint) { 'https://api-import.ap02.treasuredata.com/' }
|
148
|
+
it { is_expected.to eq 'https://api-import.ap02.treasuredata.com' }
|
149
|
+
end
|
150
|
+
context 'api-import.ap03.treasuredata.com' do
|
151
|
+
let(:api_endpoint) { 'https://api-import.ap03.treasuredata.com/' }
|
152
|
+
it { is_expected.to eq 'https://api-import.ap03.treasuredata.com' }
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
75
157
|
describe '#read' do
|
76
158
|
it 'sets @conf' do
|
77
159
|
Tempfile.create('td.conf') do |f|
|
data/td.gemspec
CHANGED
@@ -15,18 +15,21 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
16
16
|
gem.require_paths = ['lib']
|
17
17
|
gem.required_ruby_version = '>= 2.1'
|
18
|
+
gem.licenses = ["Apache-2.0"]
|
18
19
|
|
19
20
|
gem.add_dependency "msgpack"
|
20
|
-
gem.add_dependency "
|
21
|
+
gem.add_dependency "rexml"
|
22
|
+
gem.add_dependency "yajl-ruby", "~> 1.3.1"
|
21
23
|
gem.add_dependency "hirb", ">= 0.4.5"
|
22
|
-
gem.add_dependency "parallel", "~> 1.
|
23
|
-
gem.add_dependency "td-client", ">= 1.0.
|
24
|
+
gem.add_dependency "parallel", "~> 1.20.0"
|
25
|
+
gem.add_dependency "td-client", ">= 1.0.8", "< 2"
|
24
26
|
gem.add_dependency "td-logger", ">= 0.3.21", "< 2"
|
25
|
-
gem.add_dependency "rubyzip", "
|
27
|
+
gem.add_dependency "rubyzip", "~> 1.3.0"
|
26
28
|
gem.add_dependency "zip-zip", "~> 0.3"
|
27
29
|
gem.add_dependency "ruby-progressbar", "~> 1.7"
|
28
30
|
gem.add_development_dependency "rake"
|
29
31
|
gem.add_development_dependency "rspec"
|
32
|
+
gem.add_development_dependency 'webrick'
|
30
33
|
gem.add_development_dependency "simplecov"
|
31
34
|
gem.add_development_dependency 'coveralls'
|
32
35
|
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.16.
|
4
|
+
version: 0.16.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Treasure Data, Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|
@@ -24,20 +24,34 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rexml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: yajl-ruby
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: 1.3.1
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: 1.3.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: hirb
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,21 +72,21 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 1.20.0
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 1.20.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: td-client
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0.
|
89
|
+
version: 1.0.8
|
76
90
|
- - "<"
|
77
91
|
- !ruby/object:Gem::Version
|
78
92
|
version: '2'
|
@@ -82,7 +96,7 @@ dependencies:
|
|
82
96
|
requirements:
|
83
97
|
- - ">="
|
84
98
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.0.
|
99
|
+
version: 1.0.8
|
86
100
|
- - "<"
|
87
101
|
- !ruby/object:Gem::Version
|
88
102
|
version: '2'
|
@@ -110,14 +124,14 @@ dependencies:
|
|
110
124
|
name: rubyzip
|
111
125
|
requirement: !ruby/object:Gem::Requirement
|
112
126
|
requirements:
|
113
|
-
- - "
|
127
|
+
- - "~>"
|
114
128
|
- !ruby/object:Gem::Version
|
115
129
|
version: 1.3.0
|
116
130
|
type: :runtime
|
117
131
|
prerelease: false
|
118
132
|
version_requirements: !ruby/object:Gem::Requirement
|
119
133
|
requirements:
|
120
|
-
- - "
|
134
|
+
- - "~>"
|
121
135
|
- !ruby/object:Gem::Version
|
122
136
|
version: 1.3.0
|
123
137
|
- !ruby/object:Gem::Dependency
|
@@ -176,6 +190,20 @@ dependencies:
|
|
176
190
|
- - ">="
|
177
191
|
- !ruby/object:Gem::Version
|
178
192
|
version: '0'
|
193
|
+
- !ruby/object:Gem::Dependency
|
194
|
+
name: webrick
|
195
|
+
requirement: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - ">="
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
type: :development
|
201
|
+
prerelease: false
|
202
|
+
version_requirements: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - ">="
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
179
207
|
- !ruby/object:Gem::Dependency
|
180
208
|
name: simplecov
|
181
209
|
requirement: !ruby/object:Gem::Requirement
|
@@ -211,9 +239,10 @@ executables:
|
|
211
239
|
extensions: []
|
212
240
|
extra_rdoc_files: []
|
213
241
|
files:
|
242
|
+
- ".circleci/config.yml"
|
214
243
|
- ".coveralls.yml"
|
244
|
+
- ".github/CODEOWNERS"
|
215
245
|
- ".gitignore"
|
216
|
-
- ".travis.yml"
|
217
246
|
- ChangeLog
|
218
247
|
- Gemfile
|
219
248
|
- README.rdoc
|
@@ -291,9 +320,10 @@ files:
|
|
291
320
|
- spec/td/version_spec.rb
|
292
321
|
- td.gemspec
|
293
322
|
homepage: http://treasure-data.com/
|
294
|
-
licenses:
|
323
|
+
licenses:
|
324
|
+
- Apache-2.0
|
295
325
|
metadata: {}
|
296
|
-
post_install_message:
|
326
|
+
post_install_message:
|
297
327
|
rdoc_options: []
|
298
328
|
require_paths:
|
299
329
|
- lib
|
@@ -308,8 +338,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
308
338
|
- !ruby/object:Gem::Version
|
309
339
|
version: '0'
|
310
340
|
requirements: []
|
311
|
-
rubygems_version: 3.
|
312
|
-
signing_key:
|
341
|
+
rubygems_version: 3.1.4
|
342
|
+
signing_key:
|
313
343
|
specification_version: 4
|
314
344
|
summary: CLI to manage data on Treasure Data, the Hadoop-based cloud data warehousing
|
315
345
|
test_files:
|
data/.travis.yml
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
jdk:
|
4
|
-
- openjdk8
|
5
|
-
|
6
|
-
rvm:
|
7
|
-
- 2.1.10
|
8
|
-
- 2.2.10
|
9
|
-
- 2.3.8
|
10
|
-
- 2.4.5
|
11
|
-
- 2.5.3
|
12
|
-
- ruby-head
|
13
|
-
|
14
|
-
gemfile:
|
15
|
-
- Gemfile
|
16
|
-
|
17
|
-
script: bundle exec rake spec SPEC_OPTS="-fd"
|
18
|
-
|
19
|
-
matrix:
|
20
|
-
allow_failures:
|
21
|
-
- rvm: ruby-head
|
22
|
-
|
23
|
-
sudo: false
|
24
|
-
|
25
|
-
notifications:
|
26
|
-
webhooks: http://td-beda.herokuapp.com/travisci_callback
|