bfs-s3 0.7.4 → 0.8.2

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: ac3a8ad583c3cd4849b744a550bf281cc2c8b921538fda890981fb6fcf566a7e
4
- data.tar.gz: 35a48baca7cc5e8d6903f1e5ef4bb215199e9635e8ae84b9fe928d98a857fd87
3
+ metadata.gz: eaa1ea1fe4992c8906df21de648b99f938a9c214be07566dbc6163c15b94cbf2
4
+ data.tar.gz: e8703b5f3a586124995f81de0fbca1cd1d19abbe5c2f37623f19d1b40d67667c
5
5
  SHA512:
6
- metadata.gz: 844c31903cb25363730e01ba630f3127ed0af3b9cbfccb249ab74d4fe7c468b27c7f94230a7ac6898447eaa01301f66ac0872911517bc135495c6c78e07d93be
7
- data.tar.gz: 3ba0d4876291f272426843ce319b9bcea2f3487ce617bb6604e15b310525e6808838e085986d0d35d395b673519d18bab87bd5d3587b050a45b105627648cfd6
6
+ metadata.gz: 74a9b4b41efc8d9123e620fcf350539f8662b4d0bd58cff6cf441744c264a879e03f1b2fde6993c85f0c11363d52509a70a5e2ed5075ca5a48297bdb8e32cff1
7
+ data.tar.gz: 01f28fc9cd26b31dd239511e22e9fef436df1fd8fed467780cb50d6f2870f1bd9740f05ebcaca396c9766b73d084762ad9015eea9022ab04eb4fe2a38380f0ce
data/lib/bfs/bucket/s3.rb CHANGED
@@ -82,18 +82,11 @@ module BFS
82
82
  opts[:server_side_encryption] ||= @sse if @sse
83
83
  opts[:storage_class] ||= @storage_class if @storage_class
84
84
 
85
- temp = BFS::TempWriter.new(path, encoding: encoding, perm: perm) do |t|
85
+ BFS::Writer.new(path, encoding: encoding, perm: perm) do |t|
86
86
  File.open(t, encoding: encoding) do |file|
87
87
  @client.put_object(opts.merge(body: file))
88
88
  end
89
- end
90
- return temp unless block
91
-
92
- begin
93
- yield temp
94
- ensure
95
- temp.close
96
- end
89
+ end.perform(&block)
97
90
  end
98
91
 
99
92
  # Opens an existing file for reading
@@ -151,6 +144,11 @@ module BFS
151
144
  config[:credentials] = opts[:credentials] if opts[:credentials]
152
145
  config[:credentials] ||= Aws::Credentials.new(opts[:access_key_id].to_s, opts[:secret_access_key].to_s) if opts[:access_key_id]
153
146
  config[:credentials] ||= Aws::SharedCredentials.new(profile_name: opts[:profile_name]) if opts[:profile_name]
147
+ config[:credentials] = Aws::AssumeRoleCredentials.new(
148
+ client: Aws::STS::Client.new(credentials: config[:credentials]),
149
+ role_arn: opts[:assume_role],
150
+ role_session_name: "#{opts[:assume_role]}_#{SecureRandom.urlsafe_base64(12)}",
151
+ ) if opts[:assume_role]
154
152
 
155
153
  Aws::S3::Client.new(config)
156
154
  end
@@ -1,38 +1,39 @@
1
1
  require 'spec_helper'
2
2
 
3
- sandbox = { bucket: 'bsm-bfs-unittest' }.freeze
3
+ bucket_name = 'bsm-bfs-unittest'
4
4
 
5
5
  RSpec.describe BFS::Bucket::S3, s3: true do
6
- let(:prefix) { "x/#{SecureRandom.uuid}/" }
7
-
8
6
  subject do
9
- described_class.new sandbox[:bucket], prefix: prefix
7
+ described_class.new bucket_name, prefix: prefix
10
8
  end
11
- after :all do
12
- bucket = described_class.new sandbox[:bucket], prefix: 'x/'
9
+
10
+ let(:prefix) { "x/#{SecureRandom.uuid}/" }
11
+
12
+ after do
13
+ bucket = described_class.new bucket_name, prefix: prefix
13
14
  bucket.ls.each {|name| bucket.rm(name) }
14
15
  end
15
16
 
16
17
  it_behaves_like 'a bucket'
17
18
 
18
- it 'should resolve from URL' do
19
- bucket = BFS.resolve("s3://#{sandbox[:bucket]}/?acl=private&encoding=binary")
19
+ it 'resolves from URL' do
20
+ bucket = BFS.resolve("s3://#{bucket_name}/?acl=private&encoding=binary")
20
21
  expect(bucket).to be_instance_of(described_class)
21
- expect(bucket.name).to eq(sandbox[:bucket])
22
+ expect(bucket.name).to eq(bucket_name)
22
23
  expect(bucket.acl).to eq(:private)
23
24
  expect(bucket.encoding).to eq('binary')
24
25
  expect(bucket.instance_variable_get(:@prefix)).to be_nil
25
26
  bucket.close
26
27
 
27
- bucket = BFS.resolve("s3://#{sandbox[:bucket]}/a/b/")
28
+ bucket = BFS.resolve("s3://#{bucket_name}/a/b/")
28
29
  expect(bucket).to be_instance_of(described_class)
29
- expect(bucket.name).to eq(sandbox[:bucket])
30
+ expect(bucket.name).to eq(bucket_name)
30
31
  expect(bucket.instance_variable_get(:@prefix)).to eq('a/b')
31
32
  bucket.close
32
33
  end
33
34
 
34
- it 'should enumerate over a large number of files' do
35
- bucket = described_class.new sandbox[:bucket], prefix: 'm/'
35
+ it 'enumerates over a large number of files' do
36
+ bucket = described_class.new bucket_name, prefix: 'm/'
36
37
  expect(bucket.ls('**/*').count).to eq(2121)
37
38
  bucket.close
38
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfs-s3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrij Denissenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-26 00:00:00.000000000 Z
11
+ date: 2021-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.7.4
33
+ version: 0.8.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.7.4
40
+ version: 0.8.2
41
41
  description: https://github.com/bsm/bfs.rb
42
42
  email: dimitrij@blacksquaremedia.com
43
43
  executables: []
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  requirements: []
70
- rubygems_version: 3.1.2
70
+ rubygems_version: 3.1.4
71
71
  signing_key:
72
72
  specification_version: 4
73
73
  summary: S3 bucket adapter for bfs