s3-migrator 0.1.0 → 1.0.0

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
  SHA1:
3
- metadata.gz: 662bedcc18bb924505996a41af1b1de5d338e6c1
4
- data.tar.gz: df303f0a98ed9498a152ab9f9dbb78422efb4cf4
3
+ metadata.gz: 844d9650749c205ec33b36c015fc8835b36c694f
4
+ data.tar.gz: fbb246acccfc815c767879bb2f753cece84793db
5
5
  SHA512:
6
- metadata.gz: 0c95a738fe5c56a4014446c55815942f9125de64b34a99943f25cf6ff06a402136bc5ab255eb88d284a516b20218d7312f26dfbb027ff3f3f4d2cbe728aa8e38
7
- data.tar.gz: 5bdc61a2497fbc581107a2ba2e6a4c22726dd7b72f32ca43629a50c73cdfbd23bcd0dd9b277df94c9bad96f9774a6d41b9056a836818aade163b16334213cac6
6
+ metadata.gz: 6ec06f456c4579def35c3a08ea72a4c1238fa49406959056a6ac58d14691762f6033d13a12ffad8b868d011c8a60033b4747a7fa1f03ebcb6b2071c097b76cbe
7
+ data.tar.gz: 047d37d21d4564444246b33a053cdbe21bd87baf28afa757c7bd14199e29987e98101e53c3f5f7d3265933e3f86c7282bccd0ce9290c46dc2c624d5f26ef1ebb
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+
16
+ /vendor/bundle/
@@ -10,6 +10,7 @@ OptionParser.new { |o|
10
10
  o.on("-s", "--src-bucket SOURCE_BUCKET") { |v| opts[:src_bucket] = v }
11
11
  o.on("-d", "--dest-bucket DESTINATION_BUCKET", ) { |v| opts[:dest_bucket] = v }
12
12
  o.on("-p", "--prefix [PREFIX]") { |v| opts[:prefix] = v }
13
+ o.on("--profile [AWS PROFILE]") { |v| opts[:profile] = v }
13
14
  o.on("-t", "--thread [COUNT]") { |v| opts[:thread_count] = v }
14
15
  }.parse!(ARGV)
15
16
 
@@ -13,8 +13,17 @@ module S3
13
13
  DEFAULT_THREAD_COUNT = 10
14
14
 
15
15
  def migrate!(opts)
16
- creds = Aws::Credentials.new(opts[:access_key_id], opts[:secret_access_key])
17
- s3_client = Aws::S3::Client.new(credentials: creds, region: opts[:region])
16
+ # use ~/.aws/credentials if without credentials opts
17
+ creds = if opts[:profile]
18
+ Aws::SharedCredentials.new(profile_name: opts[:profile])
19
+ elsif opts[:access_key_id] && opts[:secret_access_key]
20
+ Aws::Credentials.new(opts[:access_key_id], opts[:secret_access_key])
21
+ end
22
+
23
+ client_opts = { region: opts[:region] || ENV['AWS_REGION'] }
24
+ client_opts[:credentials] = creds if creds
25
+
26
+ s3_client = Aws::S3::Client.new(client_opts)
18
27
 
19
28
  pagerble = if opts[:prefix]
20
29
  s3_client.list_objects(bucket: opts[:src_bucket], prefix: opts[:prefix])
@@ -25,7 +34,7 @@ module S3
25
34
  logger = Logger.new(STDOUT)
26
35
 
27
36
  begin
28
- each_in_threads(opts[:thread_count] || DEFAULT_THREAD_COUNT, pagerble.contents) do |obj|
37
+ each_in_threads(opts[:thread_count].to_i || DEFAULT_THREAD_COUNT, pagerble.contents) do |obj|
29
38
  begin
30
39
  s3_client.copy_object(
31
40
  bucket: opts[:dest_bucket],
@@ -1,5 +1,5 @@
1
1
  module S3
2
2
  module Migrator
3
- VERSION = "0.1.0"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3-migrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoppi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-27 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.4.5
92
+ rubygems_version: 2.5.1
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: '"Migrate S3 object"'