heirloom 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +7 -0
- data/README.md +4 -6
- data/heirloom.gemspec +2 -2
- data/lib/heirloom.rb +1 -1
- data/lib/heirloom/archive.rb +121 -0
- data/lib/heirloom/{artifact/artifact_authorizer.rb → archive/authorizer.rb} +6 -6
- data/lib/heirloom/{artifact/artifact_builder.rb → archive/builder.rb} +1 -6
- data/lib/heirloom/archive/destroyer.rb +50 -0
- data/lib/heirloom/{artifact/artifact_downloader.rb → archive/downloader.rb} +7 -7
- data/lib/heirloom/{artifact/artifact_lister.rb → archive/lister.rb} +1 -7
- data/lib/heirloom/archive/reader.rb +74 -0
- data/lib/heirloom/{artifact/artifact_updater.rb → archive/updater.rb} +4 -4
- data/lib/heirloom/{artifact/artifact_uploader.rb → archive/uploader.rb} +8 -5
- data/lib/heirloom/archive/verifier.rb +34 -0
- data/lib/heirloom/aws/simpledb.rb +5 -1
- data/lib/heirloom/cli.rb +8 -62
- data/lib/heirloom/cli/build.rb +53 -25
- data/lib/heirloom/cli/destroy.rb +30 -8
- data/lib/heirloom/cli/download.rb +32 -11
- data/lib/heirloom/cli/list.rb +30 -6
- data/lib/heirloom/cli/show.rb +33 -11
- data/lib/heirloom/cli/update.rb +31 -11
- data/lib/heirloom/config.rb +3 -3
- data/lib/heirloom/destroyer/s3.rb +1 -1
- data/lib/heirloom/directory/directory.rb +1 -1
- data/lib/heirloom/downloader/s3.rb +1 -1
- data/lib/heirloom/logger.rb +23 -0
- data/lib/heirloom/uploader/s3.rb +6 -11
- data/lib/heirloom/version.rb +1 -1
- data/spec/acl/s3_spec.rb +2 -10
- data/spec/config_spec.rb +15 -4
- data/spec/directory/directory_spec.rb +1 -1
- data/spec/{artifact/artifact_authorizer_spec.rb → heirloom/authorizer_spec.rb} +7 -7
- data/spec/{artifact/artifact_builder_spec.rb → heirloom/builder_spec.rb} +3 -3
- data/spec/{artifact/artifact_destroyer_spec.rb → heirloom/destroyer_spec.rb} +7 -7
- data/spec/{artifact/artifact_downloader_spec.rb → heirloom/downloader_spec.rb} +17 -17
- data/spec/{artifact/artifact_lister_spec.rb → heirloom/lister_spec.rb} +3 -3
- data/spec/heirloom/reader_spec.rb +90 -0
- data/spec/heirloom/updater_spec.rb +16 -0
- data/spec/heirloom/uploader_spec.rb +16 -0
- data/spec/heirloom/verifier_spec.rb +38 -0
- data/spec/heirloom_spec.rb +74 -0
- data/spec/logger_spec.rb +9 -0
- metadata +49 -45
- data/lib/heirloom/artifact.rb +0 -111
- data/lib/heirloom/artifact/artifact_destroyer.rb +0 -49
- data/lib/heirloom/artifact/artifact_reader.rb +0 -44
- data/spec/artifact/artifact_reader_spec.rb +0 -55
- data/spec/artifact/artifact_updater_spec.rb +0 -16
- data/spec/artifact/artifact_uploader_spec.rb +0 -16
- data/spec/artifact_spec.rb +0 -74
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## v0.2.0:
|
2
|
+
|
3
|
+
* Command line options updates for each sub command.
|
4
|
+
* Command line option moved into seperate class.
|
5
|
+
* Artifact renamed to archive across the gem.
|
6
|
+
* Added bucket verification
|
7
|
+
|
1
8
|
## v0.1.4:
|
2
9
|
|
3
10
|
* Limit list of artifact ids returned in list
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Heirloom
|
2
2
|
========
|
3
3
|
|
4
|
-
I help building and deploying
|
4
|
+
I help building and deploying .tar.gz files to cloud based storage services and tracking meta data about those 'Heirlooms' for easy deployments.
|
5
5
|
|
6
6
|
How To Use Heirloom
|
7
7
|
-------------------
|
@@ -12,7 +12,6 @@ To get started copy the sample below into .heirloom.yml and update the specified
|
|
12
12
|
aws:
|
13
13
|
access_key: UPDATE_ME
|
14
14
|
secret_key: UPDATE_ME
|
15
|
-
bucket_prefix: UPDATE_ME
|
16
15
|
regions:
|
17
16
|
- us-west-1
|
18
17
|
- us-west-2
|
@@ -22,10 +21,9 @@ aws:
|
|
22
21
|
- UPDATE@ME
|
23
22
|
```
|
24
23
|
|
25
|
-
* **access_key / secret_key**: Account where you would like the
|
26
|
-
* **
|
27
|
-
* **
|
28
|
-
* **authorized_aws_accounts**: Heirloom expects you to deploy to seperate accounts from where the artifact is stored. authorized_aws_accounts specifices the **email** address of other accounts to be authorized to access private artifacts.
|
24
|
+
* **access_key / secret_key**: Account where you would like the Heirlooms storaged.
|
25
|
+
* **regions**: AWS regions where the Heirlooms should be uploaded
|
26
|
+
* **authorized_aws_accounts**: Heirloom expects you to deploy to seperate accounts from where the Heirloom is stored. authorized_aws_accounts specifices the **email** address of other accounts to be authorized to access private Heirlooms.
|
29
27
|
|
30
28
|
Platforms
|
31
29
|
---------
|
data/heirloom.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Brett Weaver"]
|
9
9
|
s.email = ["brett@weav.net"]
|
10
10
|
s.homepage = ""
|
11
|
-
s.summary = %q{I help with
|
12
|
-
s.description = %q{I help build and manage
|
11
|
+
s.summary = %q{I help with deploying code into the cloud}
|
12
|
+
s.description = %q{I help build and manage building tar.gz files and deploying them into the cloud}
|
13
13
|
|
14
14
|
s.rubyforge_project = "heirloom"
|
15
15
|
|
data/lib/heirloom.rb
CHANGED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'heirloom/archive/lister.rb'
|
2
|
+
require 'heirloom/archive/reader.rb'
|
3
|
+
require 'heirloom/archive/builder.rb'
|
4
|
+
require 'heirloom/archive/updater.rb'
|
5
|
+
require 'heirloom/archive/uploader.rb'
|
6
|
+
require 'heirloom/archive/downloader.rb'
|
7
|
+
require 'heirloom/archive/authorizer.rb'
|
8
|
+
require 'heirloom/archive/destroyer.rb'
|
9
|
+
require 'heirloom/archive/verifier.rb'
|
10
|
+
|
11
|
+
module Heirloom
|
12
|
+
|
13
|
+
class Archive
|
14
|
+
|
15
|
+
def initialize(args)
|
16
|
+
@config = Config.new :config => args[:config],
|
17
|
+
:logger => args[:logger]
|
18
|
+
@name = args[:name]
|
19
|
+
@id = args[:id]
|
20
|
+
end
|
21
|
+
|
22
|
+
def authorize
|
23
|
+
authorizer.authorize
|
24
|
+
end
|
25
|
+
|
26
|
+
def build(args)
|
27
|
+
builder.build args
|
28
|
+
end
|
29
|
+
|
30
|
+
def download(args)
|
31
|
+
downloader.download args
|
32
|
+
end
|
33
|
+
|
34
|
+
def update(args)
|
35
|
+
updater.update args
|
36
|
+
end
|
37
|
+
|
38
|
+
def upload(args)
|
39
|
+
uploader.upload args
|
40
|
+
end
|
41
|
+
|
42
|
+
def exists?
|
43
|
+
reader.exists?
|
44
|
+
end
|
45
|
+
|
46
|
+
def buckets_exist?(args)
|
47
|
+
verifier.buckets_exist? args
|
48
|
+
end
|
49
|
+
|
50
|
+
def destroy
|
51
|
+
destroyer.destroy
|
52
|
+
end
|
53
|
+
|
54
|
+
def show
|
55
|
+
reader.show
|
56
|
+
end
|
57
|
+
|
58
|
+
def list(limit=10)
|
59
|
+
lister.list(limit)
|
60
|
+
end
|
61
|
+
|
62
|
+
def cleanup
|
63
|
+
builder.cleanup
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def lister
|
69
|
+
@lister ||= Lister.new :config => @config,
|
70
|
+
:name => @name
|
71
|
+
end
|
72
|
+
|
73
|
+
def reader
|
74
|
+
@reader ||= Reader.new :config => @config,
|
75
|
+
:name => @name,
|
76
|
+
:id => @id
|
77
|
+
end
|
78
|
+
|
79
|
+
def builder
|
80
|
+
@builder ||= Builder.new :config => @config,
|
81
|
+
:name => @name,
|
82
|
+
:id => @id
|
83
|
+
end
|
84
|
+
|
85
|
+
def updater
|
86
|
+
@updater ||= Updater.new :config => @config,
|
87
|
+
:name => @name,
|
88
|
+
:id => @id
|
89
|
+
end
|
90
|
+
|
91
|
+
def uploader
|
92
|
+
@uploader ||= Uploader.new :config => @config,
|
93
|
+
:name => @name,
|
94
|
+
:id => @id
|
95
|
+
end
|
96
|
+
|
97
|
+
def downloader
|
98
|
+
@downloader ||= Downloader.new :config => @config,
|
99
|
+
:name => @name,
|
100
|
+
:id => @id
|
101
|
+
end
|
102
|
+
|
103
|
+
def authorizer
|
104
|
+
@authorizer ||= Authorizer.new :config => @config,
|
105
|
+
:name => @name,
|
106
|
+
:id => @id
|
107
|
+
end
|
108
|
+
|
109
|
+
def destroyer
|
110
|
+
@destroyer ||= Destroyer.new :config => @config,
|
111
|
+
:name => @name,
|
112
|
+
:id => @id
|
113
|
+
end
|
114
|
+
|
115
|
+
def verifier
|
116
|
+
@verifier ||= Verifier.new :config => @config,
|
117
|
+
:name => @name
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Heirloom
|
2
2
|
|
3
|
-
class
|
3
|
+
class Authorizer
|
4
4
|
|
5
5
|
def initialize(args)
|
6
6
|
@config = args[:config]
|
@@ -13,7 +13,7 @@ module Heirloom
|
|
13
13
|
@logger.info "Authorizing access to artifact."
|
14
14
|
|
15
15
|
@config.regions.each do |region|
|
16
|
-
bucket =
|
16
|
+
bucket = reader.get_bucket :region => region
|
17
17
|
|
18
18
|
s3_acl = ACL::S3.new :config => @config,
|
19
19
|
:region => region
|
@@ -28,10 +28,10 @@ module Heirloom
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
def
|
32
|
-
@
|
33
|
-
|
34
|
-
|
31
|
+
def reader
|
32
|
+
@reader ||= Reader.new :config => @config,
|
33
|
+
:name => @name,
|
34
|
+
:id => @id
|
35
35
|
end
|
36
36
|
|
37
37
|
end
|
@@ -3,7 +3,7 @@ require 'time'
|
|
3
3
|
|
4
4
|
module Heirloom
|
5
5
|
|
6
|
-
class
|
6
|
+
class Builder
|
7
7
|
|
8
8
|
attr_accessor :config, :id, :local_build, :logger, :name, :source
|
9
9
|
|
@@ -47,12 +47,7 @@ module Heirloom
|
|
47
47
|
add_git_commit_to_artifact_record git_commit
|
48
48
|
end
|
49
49
|
|
50
|
-
def create_artifact_domain
|
51
|
-
logger.info "Verifying artifact domain #{name} exists."
|
52
|
-
end
|
53
|
-
|
54
50
|
def create_artifact_record
|
55
|
-
create_artifact_domain
|
56
51
|
attributes = { 'built_by' => "#{user}@#{hostname}",
|
57
52
|
'built_at' => Time.now.utc.iso8601,
|
58
53
|
'id' => id }
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Heirloom
|
2
|
+
|
3
|
+
class Destroyer
|
4
|
+
|
5
|
+
attr_accessor :config, :id, :logger, :name
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
self.config = args[:config]
|
9
|
+
self.name = args[:name]
|
10
|
+
self.id = args[:id]
|
11
|
+
self.logger = config.logger
|
12
|
+
end
|
13
|
+
|
14
|
+
def destroy
|
15
|
+
logger.info "Destroying #{@name} - #{@id}"
|
16
|
+
|
17
|
+
config.regions.each do |region|
|
18
|
+
bucket = reader.get_bucket :region => region
|
19
|
+
|
20
|
+
key = "#{id}.tar.gz"
|
21
|
+
|
22
|
+
if bucket
|
23
|
+
logger.info "Destroying 's3://#{bucket}/#{name}/#{key}'."
|
24
|
+
|
25
|
+
s3_destroyer = Destroyer::S3.new :config => config,
|
26
|
+
:region => region
|
27
|
+
|
28
|
+
s3_destroyer.destroy_file :key_name => key,
|
29
|
+
:key_folder => name,
|
30
|
+
:bucket => bucket
|
31
|
+
end
|
32
|
+
end
|
33
|
+
sdb.delete name, id
|
34
|
+
logger.info "Destroy complete."
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def sdb
|
40
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
41
|
+
end
|
42
|
+
|
43
|
+
def reader
|
44
|
+
@reader ||= Reader.new :config => config,
|
45
|
+
:name => name,
|
46
|
+
:id => id
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Heirloom
|
2
2
|
|
3
|
-
class
|
3
|
+
class Downloader
|
4
4
|
|
5
5
|
attr_accessor :config, :id, :name, :logger
|
6
6
|
|
@@ -18,8 +18,8 @@ module Heirloom
|
|
18
18
|
:logger => logger,
|
19
19
|
:region => region
|
20
20
|
|
21
|
-
bucket =
|
22
|
-
key =
|
21
|
+
bucket = reader.get_bucket :region => region
|
22
|
+
key = reader.get_key :region => region
|
23
23
|
|
24
24
|
logger.info "Downloading s3://#{bucket}/#{key} from #{region}."
|
25
25
|
|
@@ -39,10 +39,10 @@ module Heirloom
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
def
|
43
|
-
@
|
44
|
-
|
45
|
-
|
42
|
+
def reader
|
43
|
+
@reader ||= Reader.new :config => config,
|
44
|
+
:name => name,
|
45
|
+
:id => id
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Heirloom
|
2
2
|
|
3
|
-
class
|
3
|
+
class Lister
|
4
4
|
|
5
5
|
def initialize(args)
|
6
6
|
@config = args[:config]
|
@@ -18,11 +18,5 @@ module Heirloom
|
|
18
18
|
@sdb ||= AWS::SimpleDB.new :config => @config
|
19
19
|
end
|
20
20
|
|
21
|
-
def artifact_reader(id)
|
22
|
-
@artifact_reader ||= ArtifactReader.new :config => @config,
|
23
|
-
:name => @name,
|
24
|
-
:id => id
|
25
|
-
end
|
26
|
-
|
27
21
|
end
|
28
22
|
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module Heirloom
|
2
|
+
|
3
|
+
class Reader
|
4
|
+
|
5
|
+
attr_accessor :config, :id, :name
|
6
|
+
|
7
|
+
def initialize(args)
|
8
|
+
self.config = args[:config]
|
9
|
+
self.name = args[:name]
|
10
|
+
self.id = args[:id]
|
11
|
+
@logger = config.logger
|
12
|
+
end
|
13
|
+
|
14
|
+
def exists?
|
15
|
+
if show.any?
|
16
|
+
@logger.debug "Found entry for #{id} in SimpleDB."
|
17
|
+
true
|
18
|
+
else
|
19
|
+
@logger.debug "Entry for #{id} not found in SimpleDB."
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_bucket(args)
|
25
|
+
@logger.debug "Looking for bucket in #{args[:region]} for #{id}"
|
26
|
+
url = get_url(args)
|
27
|
+
if url
|
28
|
+
bucket = url.gsub('s3://', '').split('/').first
|
29
|
+
@logger.debug "Found bucket #{bucket}."
|
30
|
+
bucket
|
31
|
+
else
|
32
|
+
@logger.debug "Bucket not found."
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_key(args)
|
38
|
+
url = get_url(args)
|
39
|
+
if url
|
40
|
+
bucket_path = get_bucket :region => args[:region]
|
41
|
+
bucket = url.gsub('s3://', '').gsub(bucket_path, '')
|
42
|
+
bucket.slice!(0)
|
43
|
+
bucket
|
44
|
+
else
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def show
|
50
|
+
items = sdb.select "select * from #{name} where itemName() = '#{id}'"
|
51
|
+
items[id] ? items[id] : {}
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def get_url(args)
|
57
|
+
return nil unless exists?
|
58
|
+
@logger.debug "Looking for #{args[:region]} endpoint for #{id}"
|
59
|
+
url = "#{args[:region]}-s3-url"
|
60
|
+
if show[url]
|
61
|
+
@logger.debug "Found #{url} for #{id}."
|
62
|
+
show[url].first
|
63
|
+
else
|
64
|
+
@logger.debug "#{args[:region]} endpoint for #{id} not found."
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def sdb
|
70
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Heirloom
|
2
2
|
|
3
|
-
class
|
3
|
+
class Updater
|
4
4
|
|
5
5
|
def initialize(args)
|
6
6
|
@config = args[:config]
|
@@ -12,10 +12,10 @@ module Heirloom
|
|
12
12
|
|
13
13
|
def update(args)
|
14
14
|
attribute = args[:attribute]
|
15
|
-
|
15
|
+
value = args[:value]
|
16
16
|
|
17
|
-
sdb.put_attributes @name, @id, { attribute =>
|
18
|
-
@logger.info "Updated #{@name} (#{@id}): #{attribute} = #{
|
17
|
+
sdb.put_attributes @name, @id, { attribute => value }, { :replace => attribute }
|
18
|
+
@logger.info "Updated #{@name} (#{@id}): #{attribute} = #{value}."
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Heirloom
|
2
2
|
|
3
|
-
class
|
3
|
+
class Uploader
|
4
4
|
|
5
5
|
def initialize(args)
|
6
6
|
@config = args[:config]
|
@@ -10,8 +10,7 @@ module Heirloom
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def upload(args)
|
13
|
-
|
14
|
-
key_name = "#{@id}.tar.gz"
|
13
|
+
heirloom_file = args[:file]
|
15
14
|
bucket_prefix = args[:bucket_prefix]
|
16
15
|
public_readable = args[:public_readable]
|
17
16
|
|
@@ -23,12 +22,16 @@ module Heirloom
|
|
23
22
|
:region => region
|
24
23
|
|
25
24
|
s3_uploader.upload_file :bucket => bucket,
|
26
|
-
:file =>
|
25
|
+
:file => heirloom_file,
|
27
26
|
:id => @id,
|
28
27
|
:key_folder => @name,
|
29
|
-
:key_name =>
|
28
|
+
:key_name => "#{@id}.tar.gz",
|
30
29
|
:name => @name,
|
31
30
|
:public_readable => public_readable
|
31
|
+
|
32
|
+
s3_uploader.add_endpoint_attributes :bucket => bucket,
|
33
|
+
:id => @id,
|
34
|
+
:name => @name
|
32
35
|
end
|
33
36
|
@logger.info "Upload complete."
|
34
37
|
end
|