zillabyte-cli 0.1.4 → 0.1.5
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 +8 -8
- data/bin/zb +1 -15
- data/bin/zillabyte +1 -15
- data/lib/zillabyte-cli.rb +0 -3
- data/lib/zillabyte-cli/version.rb +1 -1
- data/lib/zillabyte/api.rb +14 -34
- data/lib/zillabyte/api/apps.rb +3 -4
- data/lib/zillabyte/api/base.rb +2 -2
- data/lib/zillabyte/api/components.rb +1 -3
- data/lib/zillabyte/api/data.rb +2 -1
- data/lib/zillabyte/api/flows.rb +9 -4
- data/lib/zillabyte/api/keys.rb +2 -1
- data/lib/zillabyte/api/logs.rb +1 -2
- data/lib/zillabyte/api/metrics.rb +3 -2
- data/lib/zillabyte/api/queries.rb +2 -0
- data/lib/zillabyte/api/semantic_tags.rb +1 -0
- data/lib/zillabyte/api/sources.rb +2 -0
- data/lib/zillabyte/api/zillalogs.rb +1 -0
- data/lib/zillabyte/auth.rb +8 -12
- data/lib/zillabyte/cli.rb +7 -24
- data/lib/zillabyte/cli/apps.rb +7 -12
- data/lib/zillabyte/cli/base.rb +3 -3
- data/lib/zillabyte/cli/components.rb +6 -3
- data/lib/zillabyte/cli/config.rb +3 -3
- data/lib/zillabyte/cli/data.rb +6 -8
- data/lib/zillabyte/cli/flows.rb +17 -16
- data/lib/zillabyte/cli/help.rb +5 -2
- data/lib/zillabyte/cli/helpers/table_output_builder.rb +3 -3
- data/lib/zillabyte/cli/keys.rb +0 -5
- data/lib/zillabyte/cli/log_formatter.rb +2 -0
- data/lib/zillabyte/cli/nuke.rb +0 -3
- data/lib/zillabyte/cli/query.rb +1 -1
- data/lib/zillabyte/cli/repl.rb +4 -2
- data/lib/zillabyte/command.rb +29 -12
- data/lib/zillabyte/common/tar.rb +8 -7
- data/lib/zillabyte/helpers.rb +4 -2
- data/lib/zillabyte/runner/app_runner.rb +4 -4
- data/lib/zillabyte/runner/component_operation.rb +2 -5
- data/lib/zillabyte/runner/component_runner.rb +3 -3
- data/lib/zillabyte/runner/multilang_operation.rb +8 -6
- data/zillabyte-cli.gemspec +3 -7
- metadata +2 -45
- data/lib/zillabyte/api/locks.rb +0 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjczNzk4NGFlYTc2MGY1M2JjZWExZDNmZjg4MzBkNDlmNGEzYTg3NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzM4MDJlMjc3M2NiMmRhM2E5ZWQ5ZThmZjA2ZjY5YTcyZjI3ZTNhMg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWQ5NzcxYTUzODMwNDI3ZDRmMmMyYmM4NTgwY2JjMzU5NDA2ZjZlODdkMWJk
|
10
|
+
YTM5YjI0ZmFhM2VlNDBjZDMzNjZjOGFmNWVlMTRiMTQzOWZhY2UwNDFkOWUw
|
11
|
+
YmUwYjY1ZGJlYjZhNmZjMzYzY2RjYzVkZTljMDc1MjEzNzk2ZjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjZiMmI2YmM4MjA4NGFiYjNlY2M0MTc2YzQ5ODZmMjM5MjUzZWNlNmViMGQz
|
14
|
+
MmY3MGYxZTY2ZmZiOTk1OGJhZWZlZjU0MTcwMmRkMzYyYTcxZjYwODdlZDkz
|
15
|
+
NjA0MTY3Y2E2YWJlZjVhMzc4NTZmYTU3NDY1ZTNlYzQxMGI1ZGQ=
|
data/bin/zb
CHANGED
@@ -1,18 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'zillabyte' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
2
|
|
9
|
-
require
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
require_relative '../lib/zillabyte-cli'
|
3
|
+
require("zillabyte-cli")
|
17
4
|
Zillabyte::CLI.start(*ARGV)
|
18
|
-
|
data/bin/zillabyte
CHANGED
@@ -1,18 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This file was generated by Bundler.
|
4
|
-
#
|
5
|
-
# The application 'zillabyte' is installed as part of a gem, and
|
6
|
-
# this file is here to facilitate running it.
|
7
|
-
#
|
8
2
|
|
9
|
-
require
|
10
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
-
Pathname.new(__FILE__).realpath)
|
12
|
-
|
13
|
-
require 'rubygems'
|
14
|
-
require 'bundler/setup'
|
15
|
-
|
16
|
-
require_relative '../lib/zillabyte-cli'
|
3
|
+
require("zillabyte-cli")
|
17
4
|
Zillabyte::CLI.start(*ARGV)
|
18
|
-
|
data/lib/zillabyte-cli.rb
CHANGED
data/lib/zillabyte/api.rb
CHANGED
@@ -1,20 +1,4 @@
|
|
1
|
-
|
2
|
-
# load('zillabyte/updater.rb') # reload updater after possible inject_loadpath
|
3
|
-
|
4
|
-
require "base64"
|
5
|
-
require "excon"
|
6
|
-
# require "securerandom"
|
7
|
-
require "uri"
|
8
|
-
require "zlib"
|
9
|
-
require "active_support/core_ext/object/to_query.rb"
|
10
|
-
require 'json'
|
11
|
-
|
12
|
-
|
13
|
-
# workaround for rescue/reraise to define errors in command.rb failing in 1.8.6
|
14
|
-
if RUBY_VERSION =~ /^1.8.6/
|
15
|
-
# require('zillabyte-api')
|
16
|
-
require('rest_client')
|
17
|
-
end
|
1
|
+
require("json")
|
18
2
|
|
19
3
|
class Zillabyte::API
|
20
4
|
|
@@ -38,6 +22,7 @@ class Zillabyte::API
|
|
38
22
|
|
39
23
|
|
40
24
|
def initialize(options={})
|
25
|
+
require("excon")
|
41
26
|
options = OPTIONS.merge(options)
|
42
27
|
@session = options.delete(:session)
|
43
28
|
@api_key = options.delete(:api_key) || ENV['ZILLABYTE_API_KEY']
|
@@ -178,76 +163,71 @@ class Zillabyte::API
|
|
178
163
|
|
179
164
|
|
180
165
|
def data
|
166
|
+
require("zillabyte/api/data")
|
181
167
|
@_data ||= ::Zillabyte::API::Data.new(self)
|
182
168
|
end
|
183
169
|
|
184
170
|
def logs
|
171
|
+
require("zillabyte/api/logs")
|
185
172
|
@_logs ||= ::Zillabyte::API::Logs.new(self)
|
186
173
|
end
|
187
174
|
|
188
175
|
def keys
|
176
|
+
require("zillabyte/api/keys")
|
189
177
|
@_keys ||= ::Zillabyte::API::Keys.new(self)
|
190
178
|
end
|
191
179
|
|
192
180
|
def queries
|
181
|
+
require("zillabyte/api/queries")
|
193
182
|
@_queries ||= ::Zillabyte::API::Queries.new(self)
|
194
183
|
end
|
195
184
|
alias_method :query, :queries
|
196
185
|
|
197
186
|
def apps
|
187
|
+
require("zillabyte/api/apps")
|
198
188
|
@_apps ||= ::Zillabyte::API::Apps.new(self)
|
199
189
|
end
|
200
190
|
alias_method :app, :apps
|
201
191
|
|
202
192
|
def flows
|
193
|
+
require("zillabyte/api/flows")
|
203
194
|
@_flows || ::Zillabyte::API::Flows.new(self)
|
204
195
|
end
|
205
196
|
alias_method :flow, :flows
|
206
197
|
|
207
198
|
def components
|
199
|
+
require("zillabyte/api/components")
|
208
200
|
@_components ||= ::Zillabyte::API::Components.new(self)
|
209
201
|
end
|
210
202
|
alias_method :component, :components
|
211
203
|
|
212
204
|
def metrics
|
205
|
+
require("zillabyte/api/metrics")
|
213
206
|
@_metrics ||= ::Zillabyte::API::Metrics.new(self)
|
214
207
|
end
|
215
208
|
alias_method :metric, :metrics
|
216
209
|
|
217
210
|
def zillalogs
|
211
|
+
require("zilabyte/api/zillalogs")
|
218
212
|
@_rules ||= ::Zillabyte::API::Zillalogs.new(self)
|
219
213
|
end
|
220
214
|
alias_method :zillalog, :zillalogs
|
221
215
|
|
222
216
|
def sources
|
217
|
+
require("zillabyte/api/sources")
|
223
218
|
@_sources ||= ::Zillabyte::API::Sources.new(self)
|
224
219
|
end
|
225
220
|
alias_method :source, :sources
|
226
221
|
|
227
222
|
def collectors
|
223
|
+
require("zillabyte/api/collectors")
|
228
224
|
@_collectors ||= ::Zillabyte::API::Collectors.new(self)
|
229
225
|
end
|
230
226
|
alias_method :collector, :collectors
|
231
227
|
|
232
228
|
def semantic_tags
|
229
|
+
require("zillabyte/api/semantic_tags")
|
233
230
|
@_rules ||= ::Zillabyte::API::SemanticTags.new(self)
|
234
231
|
end
|
235
232
|
alias_method :zillalog, :zillalogs
|
236
|
-
|
237
|
-
def self.load
|
238
|
-
require File.join(File.dirname(__FILE__), "api", "base.rb")
|
239
|
-
Dir[File.join(File.dirname(__FILE__), "api", "*.rb")].sort.each do |file|
|
240
|
-
require file
|
241
|
-
end
|
242
|
-
|
243
|
-
Dir[File.join(File.dirname(__FILE__), "api", "helpers", "*.rb")].sort.each do |file|
|
244
|
-
require file
|
245
|
-
end
|
246
|
-
end
|
247
|
-
|
248
|
-
|
249
233
|
end
|
250
|
-
|
251
|
-
|
252
|
-
# Load all helpers...
|
253
|
-
Zillabyte::API.load()
|
data/lib/zillabyte/api/apps.rb
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'zillabyte/cli/config'
|
3
|
-
require 'zillabyte/api/flows'
|
1
|
+
require("zillabyte/api/flows")
|
4
2
|
|
5
3
|
class Zillabyte::API::Apps < Zillabyte::API::Flows
|
6
4
|
|
@@ -88,7 +86,7 @@ class Zillabyte::API::Apps < Zillabyte::API::Flows
|
|
88
86
|
# POST /apps
|
89
87
|
#
|
90
88
|
def push_directory(dir, session = nil, options = {})
|
91
|
-
|
89
|
+
require("zillabyte/common/tar")
|
92
90
|
type = options[:output_type]
|
93
91
|
# Get the meta info
|
94
92
|
options[:local_flag] = 1
|
@@ -134,6 +132,7 @@ class Zillabyte::API::Apps < Zillabyte::API::Flows
|
|
134
132
|
|
135
133
|
|
136
134
|
if(res.body['uri'])
|
135
|
+
require("net/http")
|
137
136
|
uri = URI(res.body['uri'])
|
138
137
|
try_again = 1
|
139
138
|
while(try_again)
|
data/lib/zillabyte/api/base.rb
CHANGED
data/lib/zillabyte/api/data.rb
CHANGED
data/lib/zillabyte/api/flows.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require
|
2
|
-
require 'zillabyte/cli/config'
|
1
|
+
require("zillabyte/api/base")
|
3
2
|
|
4
3
|
class Zillabyte::API::Flows < Zillabyte::API::Base
|
5
4
|
|
@@ -88,7 +87,8 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
88
87
|
|
89
88
|
# GET /flows/id/download
|
90
89
|
def pull_to_directory(id, dir, session = nil, options = {})
|
91
|
-
|
90
|
+
require("zillabyte/common/tar")
|
91
|
+
require("stringio")
|
92
92
|
# Get the resource. note query params
|
93
93
|
type = options[:output_type]
|
94
94
|
session.display "downloading ##{id}" if session && type.nil?
|
@@ -105,11 +105,13 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
105
105
|
else
|
106
106
|
if(hash['tar'])
|
107
107
|
session.display "unpacking to #{dir}" if type.nil?
|
108
|
+
require("base64")
|
108
109
|
tar = StringIO.new(Base64.decode64(hash['tar']))
|
109
110
|
hash.delete('tar')
|
110
111
|
Zillabyte::Common::Tar.untar(tar, dir)
|
111
112
|
#If you get an uri instead of the tar, then download the file directly from s3
|
112
113
|
elsif(hash['uri'])
|
114
|
+
require("net/http")
|
113
115
|
session.display "downloading ##{id} to #{dir}" if type.nil?
|
114
116
|
uri = URI(hash['uri'])
|
115
117
|
try_again = 1
|
@@ -143,6 +145,7 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
143
145
|
# #
|
144
146
|
####################################################IMPORTANT####################################################
|
145
147
|
def self.get_rich_meta_info_from_script(dir, session = nil, options = {})
|
148
|
+
require("zillabyte/cli/config")
|
146
149
|
hash = Zillabyte::CLI::Config.get_config_info(dir, session, options)
|
147
150
|
if hash.nil?
|
148
151
|
return {"status" => "error", "error" => "invalid_directory", "error_message" => "The specified directory (#{dir}) does not appear to contain a valid Zillabyte configuration file."}
|
@@ -153,7 +156,7 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
153
156
|
full_script = File.join(dir, hash['script'])
|
154
157
|
command = nil
|
155
158
|
|
156
|
-
|
159
|
+
require("securerandom")
|
157
160
|
info_file = "#{dir}/#{SecureRandom.uuid}"
|
158
161
|
arg = "--info --file #{info_file}"
|
159
162
|
|
@@ -169,6 +172,7 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
169
172
|
command = "cd \"#{dir}\"; PYTHONPATH=~/zb1/multilang/python/Zillabyte python \"#{full_script}\" #{arg}"
|
170
173
|
end
|
171
174
|
when "js"
|
175
|
+
require("zillabyte/api/settings")
|
172
176
|
#command = "#{Zillabyte::API::CASPERJS_BIN} #{Zillabyte::API::API_CLIENT_JS} \"#{full_script}\" --info"
|
173
177
|
command = "cd \"#{dir}\"; NODE_PATH=~/zb1/multilang/js/src/lib #{Zillabyte::API::NODEJS_BIN} \"#{full_script}\" #{arg}"
|
174
178
|
else
|
@@ -176,6 +180,7 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
176
180
|
return nil
|
177
181
|
end
|
178
182
|
|
183
|
+
require("zillabyte/cli/flows")
|
179
184
|
results = Zillabyte::Command::Flows.get_info(command, info_file, dir, options)
|
180
185
|
|
181
186
|
begin
|
data/lib/zillabyte/api/keys.rb
CHANGED
data/lib/zillabyte/api/logs.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require("zillabyte/api/base")
|
2
|
+
|
1
3
|
class Zillabyte::API::Metrics < Zillabyte::API::Base
|
2
4
|
|
3
5
|
|
@@ -22,8 +24,7 @@ class Zillabyte::API::Metrics < Zillabyte::API::Base
|
|
22
24
|
|
23
25
|
# GET /metrics
|
24
26
|
def show(id, options = {}, block = nil)
|
25
|
-
|
26
|
-
|
27
|
+
require("active_support/core_ext/object/to_query.rb")
|
27
28
|
if block
|
28
29
|
res = @api.request(
|
29
30
|
:expects => 200,
|
data/lib/zillabyte/auth.rb
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
require "cgi"
|
2
|
-
require "zillabyte/helpers"
|
3
|
-
|
4
|
-
require "netrc"
|
5
|
-
|
6
1
|
class Zillabyte::Auth
|
7
2
|
class << self
|
8
3
|
include Zillabyte::Helpers
|
@@ -55,6 +50,7 @@ class Zillabyte::Auth
|
|
55
50
|
|
56
51
|
|
57
52
|
def netrc_path
|
53
|
+
require("netrc")
|
58
54
|
default = Netrc.default_path
|
59
55
|
encrypted = default + ".gpg"
|
60
56
|
if File.exists?(encrypted)
|
@@ -65,9 +61,10 @@ class Zillabyte::Auth
|
|
65
61
|
end
|
66
62
|
|
67
63
|
def netrc # :nodoc:
|
64
|
+
require("netrc")
|
68
65
|
@netrc ||= begin
|
69
66
|
Netrc.read(netrc_path)
|
70
|
-
rescue
|
67
|
+
rescue Netrc::Error => error
|
71
68
|
if error.message =~ /^Permission bits for/
|
72
69
|
perm = File.stat(netrc_path).mode & 0777
|
73
70
|
abort("Permissions #{perm} for '#{netrc_path}' are too open. You should run `chmod 0600 #{netrc_path}` so that your credentials are NOT accessible by others.")
|
@@ -104,12 +101,13 @@ class Zillabyte::Auth
|
|
104
101
|
|
105
102
|
def write_credentials(email, auth_token)
|
106
103
|
begin
|
104
|
+
require("fileutils")
|
107
105
|
FileUtils.mkdir_p(File.dirname(netrc_path))
|
108
106
|
FileUtils.touch(netrc_path)
|
109
107
|
FileUtils.chmod 0600, netrc_path
|
110
108
|
netrc[host] = [email, auth_token]
|
111
109
|
netrc.save
|
112
|
-
rescue
|
110
|
+
rescue Netrc::Error => error
|
113
111
|
display 'Netrc Read or Save Error'
|
114
112
|
display error.message
|
115
113
|
exit 1
|
@@ -119,7 +117,7 @@ class Zillabyte::Auth
|
|
119
117
|
def delete_credentials
|
120
118
|
begin
|
121
119
|
netrc.delete(host)
|
122
|
-
rescue
|
120
|
+
rescue Netrc::Error => error
|
123
121
|
display 'Netrc Delete Error'
|
124
122
|
display error.message
|
125
123
|
exit 1
|
@@ -128,7 +126,7 @@ class Zillabyte::Auth
|
|
128
126
|
tries = 0
|
129
127
|
begin
|
130
128
|
netrc.save
|
131
|
-
rescue
|
129
|
+
rescue Netrc::Error => error
|
132
130
|
tries +=1
|
133
131
|
display 'netrc save error'
|
134
132
|
error.message
|
@@ -151,6 +149,7 @@ class Zillabyte::Auth
|
|
151
149
|
end
|
152
150
|
|
153
151
|
def valid_credentials?(email, auth_token)
|
152
|
+
require("zillabyte/api")
|
154
153
|
api = Zillabyte::API.new(:api_key => auth_token, :session => self)
|
155
154
|
response = api.request(
|
156
155
|
:expects => 200,
|
@@ -255,8 +254,5 @@ class Zillabyte::Auth
|
|
255
254
|
end
|
256
255
|
end
|
257
256
|
|
258
|
-
class Zillabyte::Auth::NetrcError < Netrc::Error
|
259
|
-
end
|
260
|
-
|
261
257
|
class Zillabyte::Auth::InvalidCredentialsException < Exception
|
262
258
|
end
|