cnvrg 1.5.8.7 → 1.5.8.8

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
  SHA256:
3
- metadata.gz: cf3902f81d0a961b29dfb969f247eb3c347ec83ae950b18fd23e96a37ea9acd5
4
- data.tar.gz: 6179adccab5ee3f4a57210bc7d6201afb637a6175a67a537cc7a33c04601bf9c
3
+ metadata.gz: 46794cf31d991b88da8a0cd142415448da418c1f8b3b6b48c4c4cd4bc80ef5b2
4
+ data.tar.gz: b9890d7f639aef2263c15006df1d6518abf7fe916ca03534540e67c204ad7dcf
5
5
  SHA512:
6
- metadata.gz: 82dd3f6c559533e24f6e9ce5dc64e209ab947f8360ad4e4c8f8d93ff4fb67190f0389bdd9034cf56763e7f306df984fda4ef1a192180a26332728cb692b97bd5
7
- data.tar.gz: e4c377b406a682540105d7f94966aa7f4a62e0d12e38051c5c7694549a932a4d209277ae071f3c5110862ba2d9ee8bf27ef24240318bb5892cf1be08e49f4b25
6
+ metadata.gz: 8fa64c6b9e9973aa4b64800f9f617651cf0d666b0108691c6cbd114b14c0fb5e3f91640f0472b85e5a7009ec0ff0b2d8e2e34a3523656da3a2a36fb017706410
7
+ data.tar.gz: 53810d239e43ef20c3504035a8ac6d9cb378e73aee56930fb3ab765cff40c7c51c63c3087ee5fcd32079c1f0df61b059bd5c8ddcf01d77b65fd3e86e19f0e6b7
data/cnvrg.gemspec CHANGED
@@ -37,7 +37,8 @@ Gem::Specification.new do |spec|
37
37
  spec.add_runtime_dependency 'sucker_punch', '~> 2.0'
38
38
  spec.add_runtime_dependency 'urlcrypt', '~> 0.1.1'
39
39
  spec.add_runtime_dependency 'parallel', '~> 1.12.0'
40
-
40
+ spec.add_runtime_dependency 'azure-storage-blob', '~> 1.1.0'
41
+
41
42
  spec.add_runtime_dependency 'logstash-logger', '~> 0.22.1'
42
43
  spec.add_runtime_dependency 'launchy', '~> 2.4'
43
44
  spec.add_runtime_dependency 'docker-api', '~> 1.33'
@@ -43,7 +43,8 @@ module Cnvrg
43
43
  when 's3', 'minio'
44
44
  return Cnvrg::Downloader::Clients::S3Client.new(sts_path: params["path_sts"], access_key: params["sts_a"], secret: params["sts_s"], session_token: params["sts_st"], region: params["region"], bucket: params["bucket"], encryption: params["encryption"], endpoint: params["endpoint"], storage: params["storage"])
45
45
  when 'azure'
46
- return Cnvrg::Downloader::Clients::AzureDownloader.new(params)
46
+ azure_params = params.symbolize_keys.slice(*[:storage_account_name, :storage_access_key, :container, :sts])
47
+ return Cnvrg::Downloader::Clients::AzureClient.new(**azure_params)
47
48
  when 'gcp'
48
49
  return Cnvrg::Downloader::Clients::GcpClient.new(project_id: params["project_id"], credentials: params["credentials"], bucket_name: params["bucket_name"], sts: params["sts"])
49
50
  end
@@ -1,20 +1,32 @@
1
+ require 'azure/storage/blob'
2
+
1
3
  module Cnvrg
2
4
  module Downloader
3
5
  module Clients
4
6
  class AzureClient < Client
5
- def initialize(storage: nil, account_name: nil, access_key: nil, container: nil, sts_path: nil)
6
- @key, @iv = extract_key_iv(sts_path)
7
- @account_name = Cnvrg::Helpers.decrypt(@key, @iv, account_name)
8
- @access_key = Cnvrg::Helpers.decrypt(@key, @iv, access_key)
7
+ def initialize(storage_account_name: nil, storage_access_key: nil, container: nil, sts: nil)
8
+ @key, @iv = extract_key_iv(sts)
9
+ @account_name = Cnvrg::Helpers.decrypt(@key, @iv, storage_account_name)
10
+ @access_key = Cnvrg::Helpers.decrypt(@key, @iv, storage_access_key)
9
11
  @container = Cnvrg::Helpers.decrypt(@key, @iv, container)
10
12
  end
11
13
 
12
- def download(storage_path, local_path)
13
-
14
+ def download(storage_path, local_path, decrypt: true)
15
+ prepare_download(local_path)
16
+ storage_path = Cnvrg::Helpers.decrypt(@key, @iv, storage_path) if decrypt
17
+ blob, content = client.get_blob(@container, storage_path)
18
+ ::File.open(local_path, 'wb') {|f| f.write(content)}
19
+ blob
14
20
  end
15
21
 
16
22
  def upload(storage_path, local_path)
23
+ client.create_block_blob(@container, storage_path, File.open(local_path, "rb"))
24
+ end
25
+
17
26
 
27
+ private
28
+ def client
29
+ Azure::Storage::Blob::BlobService.create(storage_account_name: @account_name, storage_access_key: @access_key)
18
30
  end
19
31
  end
20
32
  end
data/lib/cnvrg/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Cnvrg
2
- VERSION = '1.5.8.7'
2
+ VERSION = '1.5.8.8'
3
3
  end
4
4
 
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: 1.5.8.7
4
+ version: 1.5.8.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yochay Ettun
@@ -288,6 +288,20 @@ dependencies:
288
288
  - - "~>"
289
289
  - !ruby/object:Gem::Version
290
290
  version: 1.12.0
291
+ - !ruby/object:Gem::Dependency
292
+ name: azure-storage-blob
293
+ requirement: !ruby/object:Gem::Requirement
294
+ requirements:
295
+ - - "~>"
296
+ - !ruby/object:Gem::Version
297
+ version: 1.1.0
298
+ type: :runtime
299
+ prerelease: false
300
+ version_requirements: !ruby/object:Gem::Requirement
301
+ requirements:
302
+ - - "~>"
303
+ - !ruby/object:Gem::Version
304
+ version: 1.1.0
291
305
  - !ruby/object:Gem::Dependency
292
306
  name: logstash-logger
293
307
  requirement: !ruby/object:Gem::Requirement