Skip to content

Commit

Permalink
Make it possible to specify the backup bucket region. (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdrakeweb authored and askreet committed Jun 8, 2017
1 parent de10116 commit c856631
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/plugins/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class Backup # rubocop:disable Metrics/ClassLength
:hooks,
:target_name,
:backup_parameters,
:backup_template
:backup_template,
:bucket_region

def initialize
yield self if block_given?
Expand Down Expand Up @@ -162,7 +163,9 @@ def zip(io_tar)
#
# @param io_zip [IO] tar stream
def upload(io_zip)
s3_client.put_object(
opts = {}
opts[:region] = @bucket_region if @bucket_region
s3_client(opts).put_object(
acl: 'private',
bucket: @target_bucket,
key: @target_name,
Expand Down
2 changes: 2 additions & 0 deletions spec/moonshot/plugins/backup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
it 'should yield self' do
backup = subject.new do |b|
b.bucket = 'test'
b.bucket_region = 'us-east-2'
b.files = %w(sample files)
b.hooks = [:sample, :hooks]
end
expect(backup.bucket).to eq('test')
expect(backup.bucket_region).to eq('us-east-2')
expect(backup.files).to eq(%w(sample files))
expect(backup.hooks).to eq([:sample, :hooks])
end
Expand Down

0 comments on commit c856631

Please sign in to comment.