cnvrg 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cnvrg/cli.rb +27 -0
- data/lib/cnvrg/files.rb +54 -0
- data/lib/cnvrg/version.rb +1 -1
- 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: b9b8198ef7c07b5e104013d85ea8cafab151bd82
|
4
|
+
data.tar.gz: 285b8c2c3213db29c8e01d8e0d0937e465ee5427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46dc6ef133915f5db232df9452a05ad0ef7be0a210f9e3d88e8a1b484aed0ddcc30657a1ff172148b1648c11ca7d150fb44387ab8970cb087c35d26cfb2c60d7
|
7
|
+
data.tar.gz: bf4085d68ce2e0b4de724b6208ea9496a11407e14b720bfcec50e909f0a87d8d6575af344d5289f29912770e39b8d92677197bc5c37c1e79d518829c29bd9085
|
data/lib/cnvrg/cli.rb
CHANGED
@@ -2269,6 +2269,33 @@ module Cnvrg
|
|
2269
2269
|
end
|
2270
2270
|
end
|
2271
2271
|
|
2272
|
+
desc 'show', 'Show specific file from a specific commit'
|
2273
|
+
method_option :path, :type => :string, :aliases => ["-p"], :desc => "File path", :default => ""
|
2274
|
+
method_option :commit, :type => :string, :aliases => ["-c"], :desc => "Commit sha1", :default => nil
|
2275
|
+
def show
|
2276
|
+
path = options['path']
|
2277
|
+
commit = options['commit']
|
2278
|
+
|
2279
|
+
verify_logged_in(true)
|
2280
|
+
log_start(__method__, args, options)
|
2281
|
+
project_home = get_project_home
|
2282
|
+
@project = Project.new(project_home)
|
2283
|
+
|
2284
|
+
|
2285
|
+
project_dir = is_cnvrg_dir(Dir.pwd)
|
2286
|
+
@files = Cnvrg::Files.new(@project.owner, @project.slug)
|
2287
|
+
begin
|
2288
|
+
|
2289
|
+
file = @files.show_file_s3(path, commit)
|
2290
|
+
|
2291
|
+
if file
|
2292
|
+
puts file
|
2293
|
+
else
|
2294
|
+
say "Couldn't find file"
|
2295
|
+
end
|
2296
|
+
end
|
2297
|
+
end
|
2298
|
+
|
2272
2299
|
|
2273
2300
|
desc 'data_jump', 'jump to specific commit', :hide => true
|
2274
2301
|
|
data/lib/cnvrg/files.rb
CHANGED
@@ -460,6 +460,60 @@ module Cnvrg
|
|
460
460
|
return true
|
461
461
|
end
|
462
462
|
|
463
|
+
def show_file_s3(relative_path, commit_sha1=nil)
|
464
|
+
begin
|
465
|
+
res = Cnvrg::API.request(@base_resource + "download_file", 'POST', { absolute_path: '', relative_path: relative_path, commit_sha1: commit_sha1, new_version:true })
|
466
|
+
|
467
|
+
Cnvrg::CLI.is_response_success(res, false)
|
468
|
+
if res["result"]
|
469
|
+
download_resp = res
|
470
|
+
filename = download_resp["result"]["filename"]
|
471
|
+
|
472
|
+
#absolute_path += ".conflict" if conflict
|
473
|
+
sts_path = download_resp["result"]["path_sts"]
|
474
|
+
uri = URI.parse(sts_path)
|
475
|
+
http_object = Net::HTTP.new(uri.host, uri.port)
|
476
|
+
http_object.use_ssl = true if uri.scheme == 'https'
|
477
|
+
request = Net::HTTP::Get.new(sts_path)
|
478
|
+
|
479
|
+
body = ""
|
480
|
+
http_object.start do |http|
|
481
|
+
response = http.request request
|
482
|
+
body = response.read_body
|
483
|
+
end
|
484
|
+
split = body.split("\n")
|
485
|
+
key = split[0]
|
486
|
+
iv = split[1]
|
487
|
+
|
488
|
+
access = Cnvrg::Helpers.decrypt(key, iv, download_resp["result"]["sts_a"])
|
489
|
+
|
490
|
+
secret = Cnvrg::Helpers.decrypt(key,iv, download_resp["result"]["sts_s"])
|
491
|
+
|
492
|
+
session = Cnvrg::Helpers.decrypt(key,iv, download_resp["result"]["sts_st"])
|
493
|
+
region = Cnvrg::Helpers.decrypt(key,iv, download_resp["result"]["region"])
|
494
|
+
|
495
|
+
bucket = Cnvrg::Helpers.decrypt(key,iv, download_resp["result"]["bucket"])
|
496
|
+
key = Cnvrg::Helpers.decrypt(key,iv, download_resp["result"]["key"])
|
497
|
+
|
498
|
+
client = Aws::S3::Client.new(
|
499
|
+
:access_key_id =>access,
|
500
|
+
:secret_access_key => secret,
|
501
|
+
:session_token => session,
|
502
|
+
:region => region,
|
503
|
+
:http_open_timeout => 60, :retry_limit => 20
|
504
|
+
)
|
505
|
+
resp = client.get_object({bucket:bucket,
|
506
|
+
key:key})
|
507
|
+
return resp.body.string
|
508
|
+
end
|
509
|
+
|
510
|
+
rescue => e
|
511
|
+
puts e
|
512
|
+
return false
|
513
|
+
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
463
517
|
def download_dir(absolute_path, relative_path, project_home)
|
464
518
|
FileUtils.mkdir_p("#{project_home}/#{absolute_path}")
|
465
519
|
end
|
data/lib/cnvrg/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cnvrg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yochay Ettun
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -416,7 +416,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
416
416
|
version: '0'
|
417
417
|
requirements: []
|
418
418
|
rubyforge_project:
|
419
|
-
rubygems_version: 2.
|
419
|
+
rubygems_version: 2.5.1
|
420
420
|
signing_key:
|
421
421
|
specification_version: 4
|
422
422
|
summary: A CLI tool for interacting with cnvrg.io.
|