heirloom 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,6 +39,7 @@ module Heirloom
39
39
 
40
40
  a = Array.new
41
41
 
42
+ # Add each account email as read access
42
43
  @accounts.each do |g|
43
44
  a << {
44
45
  'Grantee' => { 'EmailAddress' => g } ,
@@ -46,6 +47,11 @@ module Heirloom
46
47
  }
47
48
  end
48
49
 
50
+ # Grand owner full access
51
+ a << { 'Grantee' => { 'DisplayName' => name, 'ID' => id },
52
+ 'Permission' => 'FULL_CONTROL'
53
+ }
54
+
49
55
  {
50
56
  'Owner' => {
51
57
  'DisplayName' => name,
@@ -26,6 +26,7 @@ module Heirloom
26
26
 
27
27
  artifact_uploader.upload :id => args[:id],
28
28
  :name => args[:name],
29
+ :bucket_prefix => args[:bucket_prefix],
29
30
  :public_readable => args[:public],
30
31
  :file => file
31
32
 
@@ -16,8 +16,9 @@ module Heirloom
16
16
  @logger.info "Authorizing access to artifact."
17
17
 
18
18
  @config.regions.each do |region|
19
- bucket = "#{@config.bucket_prefix}-#{region}"
20
-
19
+ bucket = artifact_reader.get_bucket :region => region,
20
+ :name => name,
21
+ :id => id
21
22
  s3_acl = ACL::S3.new :config => @config,
22
23
  :logger => @logger,
23
24
  :region => region
@@ -29,5 +30,11 @@ module Heirloom
29
30
  end
30
31
  end
31
32
 
33
+ private
34
+
35
+ def artifact_reader
36
+ @artifact_reader ||= ArtifactReader.new :config => @config
37
+ end
38
+
32
39
  end
33
40
  end
@@ -14,7 +14,10 @@ module Heirloom
14
14
  @logger.info "Destroying #{args[:name]} - #{args[:id]}"
15
15
 
16
16
  @config.regions.each do |region|
17
- bucket = "#{@config.bucket_prefix}-#{region}"
17
+ puts "#{region}, #{name}, #{id}"
18
+ bucket = artifact_reader.get_bucket :region => region,
19
+ :name => name,
20
+ :id => id
18
21
  key = "#{id}.tar.gz"
19
22
 
20
23
  @logger.info "Deleting s3://#{bucket}/#{name}/#{key}"
@@ -26,8 +29,8 @@ module Heirloom
26
29
  :key_folder => name,
27
30
  :bucket => bucket
28
31
 
29
- sdb.delete name, id
30
32
  end
33
+ sdb.delete name, id
31
34
  end
32
35
 
33
36
  private
@@ -36,5 +39,9 @@ module Heirloom
36
39
  @sdb ||= AWS::SimpleDB.new :config => @config
37
40
  end
38
41
 
42
+ def artifact_reader
43
+ @artifact_reader ||= ArtifactReader.new :config => @config
44
+ end
45
+
39
46
  end
40
47
  end
@@ -17,10 +17,18 @@ module Heirloom
17
17
  :logger => @logger,
18
18
  :region => @region
19
19
 
20
- @logger.info "Downloading s3://#{get_bucket}/#{get_key} from #{@region}."
20
+ bucket = artifact_reader.get_bucket :region => @region,
21
+ :name => @name,
22
+ :id => @id
21
23
 
22
- file = s3_downloader.download_file :bucket => get_bucket,
23
- :key => get_key
24
+ key = artifact_reader.get_key :region => @region,
25
+ :name => @name,
26
+ :id => @id
27
+
28
+ @logger.info "Downloading s3://#{bucket}/#{key} from #{@region}."
29
+
30
+ file = s3_downloader.download_file :bucket => bucket,
31
+ :key => key
24
32
 
25
33
  @logger.info "Writing file to #{@output}."
26
34
 
@@ -17,6 +17,26 @@ module Heirloom
17
17
  show(args) != nil
18
18
  end
19
19
 
20
+ def get_bucket(args)
21
+ artifact = show :name => args[:name],
22
+ :id => args[:id]
23
+
24
+ url = artifact["#{args[:region]}-s3-url"].first
25
+
26
+ bucket = url.gsub('s3://', '').split('/').first
27
+ end
28
+
29
+ def get_key(args)
30
+ artifact = show :name => args[:name],
31
+ :id => args[:id]
32
+
33
+ url = artifact["#{args[:region]}-s3-url"].first
34
+
35
+ bucket = url.gsub('s3://', '').gsub(get_bucket(args), '')
36
+ bucket.slice!(0)
37
+ bucket
38
+ end
39
+
20
40
  private
21
41
 
22
42
  def sdb
@@ -13,10 +13,11 @@ module Heirloom
13
13
  key_folder = args[:name]
14
14
  key_name = "#{id}.tar.gz"
15
15
  name = args[:name]
16
+ bucket_prefix = args[:bucket_prefix]
16
17
  public_readable = args[:public_readable]
17
18
 
18
19
  @config.regions.each do |region|
19
- bucket = "#{@config.bucket_prefix}-#{region}"
20
+ bucket = "#{bucket_prefix}-#{region}"
20
21
 
21
22
  s3_uploader = Uploader::S3.new :config => @config,
22
23
  :logger => @logger,
@@ -13,7 +13,7 @@ Usage:
13
13
  heirloom names
14
14
  heirloom list -n NAME
15
15
  heirloom show -n NAME -i ID
16
- heirloom build -n NAME -i ID [-d DIRECTORY] [-p] [-g]
16
+ heirloom build -n NAME -i ID -b BUCKET_PREFIX [-d DIRECTORY] [-p] [-g]
17
17
  heirloom download -n NAME -i ID -r REGION -o OUTPUT_FILE
18
18
  heirloom update -n NAME -i ID -a ATTRIBUTE -u UPDATE
19
19
  heirloom destroy -n NAME -i ID
@@ -21,6 +21,7 @@ heirloom destroy -n NAME -i ID
21
21
  EOS
22
22
  opt :help, "Display Help"
23
23
  opt :attribute, "Attribute to update.", :type => :string
24
+ opt :bucket_prefix, "Bucket prefix which will be combined with region.", :type => :string
24
25
  opt :directory, "Source directory of build.", :type => :string,
25
26
  :default => '.'
26
27
  opt :exclude, "Comma spereate list of files or directories to exclude.", :type => :string,
@@ -52,13 +53,14 @@ EOS
52
53
  puts a.show(:name => @opts[:name],
53
54
  :id => @opts[:id]).to_yaml
54
55
  when 'build'
55
- a.build :name => @opts[:name],
56
- :id => @opts[:id],
57
- :accounts => @opts[:accounts],
58
- :directory => @opts[:directory],
59
- :exclude => @opts[:exclude].split(','),
60
- :public => @opts[:public],
61
- :git => @opts[:git]
56
+ a.build :name => @opts[:name],
57
+ :id => @opts[:id],
58
+ :accounts => @opts[:accounts],
59
+ :bucket_prefix => @opts[:bucket_prefix],
60
+ :directory => @opts[:directory],
61
+ :exclude => @opts[:exclude].split(','),
62
+ :public => @opts[:public],
63
+ :git => @opts[:git]
62
64
  when 'update'
63
65
  a.update :name => @opts[:name],
64
66
  :id => @opts[:id],
@@ -1,3 +1,3 @@
1
1
  module Heirloom
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -6,7 +6,7 @@ describe Heirloom do
6
6
  'secret_key' => 'secret',
7
7
  'regions' => ['us-west-1', 'us-west-2'],
8
8
  'bucket_prefix' => 'prefix',
9
- 'authorized_aws_accounts' => [ 'test1 @acct.com', 'test2@acct.com'] }
9
+ 'authorized_aws_accounts' => [ 'test1 @acct.com', 'test2@acct.com' ] }
10
10
  @logger = 'logger'
11
11
  end
12
12
 
@@ -17,7 +17,8 @@ describe Heirloom do
17
17
  :logger => 'logger'
18
18
  end
19
19
 
20
- it "should build the artifact"
20
+ it "should build the artifact"
21
+
21
22
  it "should update the artifact"
22
23
 
23
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heirloom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-06-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70233621052940 !ruby/object:Gem::Requirement
16
+ requirement: &70276834500700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70233621052940
24
+ version_requirements: *70276834500700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fog
27
- requirement: &70233621051920 !ruby/object:Gem::Requirement
27
+ requirement: &70276834499760 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70233621051920
35
+ version_requirements: *70276834499760
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: grit
38
- requirement: &70233621006260 !ruby/object:Gem::Requirement
38
+ requirement: &70276834499000 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70233621006260
46
+ version_requirements: *70276834499000
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: logger
49
- requirement: &70233621004160 !ruby/object:Gem::Requirement
49
+ requirement: &70276834496380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70233621004160
57
+ version_requirements: *70276834496380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: minitar
60
- requirement: &70233621002400 !ruby/object:Gem::Requirement
60
+ requirement: &70276834494800 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70233621002400
68
+ version_requirements: *70276834494800
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: trollop
71
- requirement: &70233621000920 !ruby/object:Gem::Requirement
71
+ requirement: &70276834509460 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70233621000920
79
+ version_requirements: *70276834509460
80
80
  description: I help build and manage artifacts
81
81
  email:
82
82
  - brett@weav.net
@@ -139,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  segments:
141
141
  - 0
142
- hash: -188177513496697606
142
+ hash: 2277153022604360161
143
143
  required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  none: false
145
145
  requirements:
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  segments:
150
150
  - 0
151
- hash: -188177513496697606
151
+ hash: 2277153022604360161
152
152
  requirements: []
153
153
  rubyforge_project: heirloom
154
154
  rubygems_version: 1.8.16