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
@@ -0,0 +1,34 @@
|
|
1
|
+
module Heirloom
|
2
|
+
|
3
|
+
class Verifier
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@config = args[:config]
|
7
|
+
@name = args[:name]
|
8
|
+
@logger = @config.logger
|
9
|
+
end
|
10
|
+
|
11
|
+
def buckets_exist?(args)
|
12
|
+
bucket_prefix = args[:bucket_prefix]
|
13
|
+
result = true
|
14
|
+
|
15
|
+
@config.regions.each do |region|
|
16
|
+
bucket = "#{bucket_prefix}-#{region}"
|
17
|
+
|
18
|
+
s3 ||= AWS::S3.new :config => @config,
|
19
|
+
:region => region
|
20
|
+
|
21
|
+
if s3.get_bucket bucket
|
22
|
+
@logger.debug "#{bucket} exists in #{region}"
|
23
|
+
else
|
24
|
+
@logger.debug "#{bucket} in #{region} does not exist"
|
25
|
+
result = false
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
result
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -15,8 +15,12 @@ module Heirloom
|
|
15
15
|
@sdb.list_domains.body['Domains']
|
16
16
|
end
|
17
17
|
|
18
|
+
def domain_exists?(domain)
|
19
|
+
domains.include? domain
|
20
|
+
end
|
21
|
+
|
18
22
|
def create_domain(domain)
|
19
|
-
@sdb.create_domain(domain) unless
|
23
|
+
@sdb.create_domain(domain) unless domain_exists?(domain)
|
20
24
|
end
|
21
25
|
|
22
26
|
def put_attributes(domain, key, attributes, options = {})
|
data/lib/heirloom/cli.rb
CHANGED
@@ -10,79 +10,25 @@ require 'heirloom/cli/destroy'
|
|
10
10
|
module Heirloom
|
11
11
|
module CLI
|
12
12
|
def self.start
|
13
|
-
@opts = Trollop::options do
|
14
|
-
version Heirloom::VERSION
|
15
|
-
banner <<-EOS
|
16
|
-
|
17
|
-
I build and manage artifacts
|
18
|
-
|
19
|
-
Usage:
|
20
|
-
|
21
|
-
heirloom list -n NAME
|
22
|
-
heirloom show -n NAME -i ID
|
23
|
-
heirloom build -n NAME -i ID -b BUCKET_PREFIX [-d DIRECTORY] [-p] [-g]
|
24
|
-
heirloom download -n NAME -i ID -r REGION -o OUTPUT_FILE
|
25
|
-
heirloom update -n NAME -i ID -a ATTRIBUTE -u UPDATE
|
26
|
-
heirloom destroy -n NAME -i ID
|
27
|
-
|
28
|
-
EOS
|
29
|
-
opt :help, "Display Help"
|
30
|
-
opt :attribute, "Attribute to update.", :type => :string
|
31
|
-
opt :bucket_prefix, "Bucket prefix which will be combined with region.", :type => :string
|
32
|
-
opt :directory, "Source directory of build.", :type => :string,
|
33
|
-
:default => '.'
|
34
|
-
opt :exclude, "Comma spereate list of files or directories to exclude.", :type => :string,
|
35
|
-
:default => '.git'
|
36
|
-
opt :git, "Read git commit information from directory."
|
37
|
-
opt :id, "Id of artifact.", :type => :string
|
38
|
-
opt :limit, "Limit the results returned by list.", :type => :integer,
|
39
|
-
:default => 10
|
40
|
-
opt :name, "Name of artifact.", :type => :string
|
41
|
-
opt :output, "Output download to file.", :type => :string
|
42
|
-
opt :public, "Set this artifact as public readable?"
|
43
|
-
opt :region, "Region to download artifact.", :type => :string,
|
44
|
-
:default => 'us-west-1'
|
45
|
-
opt :update, "Update value of attribute.", :type => :string
|
46
|
-
end
|
47
|
-
|
48
13
|
cmd = ARGV.shift
|
49
14
|
|
50
15
|
case cmd
|
51
16
|
when 'list'
|
52
|
-
|
53
|
-
cli_list.list @opts[:limit]
|
17
|
+
CLI::List.new.list
|
54
18
|
when 'show'
|
55
|
-
|
56
|
-
:id => @opts[:id]
|
57
|
-
cli_show.show
|
19
|
+
CLI::Show.new.show
|
58
20
|
when 'build'
|
59
|
-
|
60
|
-
:id => @opts[:id],
|
61
|
-
:accounts => @opts[:accounts],
|
62
|
-
:bucket_prefix => @opts[:bucket_prefix],
|
63
|
-
:directory => @opts[:directory],
|
64
|
-
:exclude => @opts[:exclude],
|
65
|
-
:public => @opts[:public],
|
66
|
-
:git => @opts[:git]
|
67
|
-
cli_build.build
|
21
|
+
CLI::Build.new.build
|
68
22
|
when 'update'
|
69
|
-
|
70
|
-
:id => @opts[:id],
|
71
|
-
:attribute => @opts[:attribute],
|
72
|
-
:update => @opts[:update]
|
73
|
-
cli_update.update
|
23
|
+
CLI::Update.new.update
|
74
24
|
when 'download'
|
75
|
-
|
76
|
-
:id => @opts[:id],
|
77
|
-
:output => @opts[:output],
|
78
|
-
:region => @opts[:region]
|
79
|
-
cli_download.download
|
25
|
+
CLI::Download.new.download
|
80
26
|
when 'destroy', 'delete'
|
81
|
-
|
82
|
-
:id => @opts[:id]
|
83
|
-
cli_destroy.destroy
|
27
|
+
CLI::Destroy.new.destroy
|
84
28
|
else
|
85
29
|
puts "Unkown command: '#{cmd}'."
|
30
|
+
puts "heirloom [list|show|build|update|download|destroy] OPTIONS"
|
31
|
+
puts "Append -h for help on specific command."
|
86
32
|
end
|
87
33
|
end
|
88
34
|
end
|
data/lib/heirloom/cli/build.rb
CHANGED
@@ -1,38 +1,66 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Heirloom
|
2
4
|
module CLI
|
3
5
|
class Build
|
4
6
|
|
5
|
-
def initialize
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
@exclude = args[:exclude].split(',')
|
12
|
-
@public = args[:public]
|
13
|
-
@git = args[:git]
|
14
|
-
@logger = args[:logger]
|
15
|
-
@artifact = Artifact.new :name => @name,
|
16
|
-
:id => @id,
|
17
|
-
:logger => @logger
|
7
|
+
def initialize
|
8
|
+
@opts = read_options
|
9
|
+
@logger = HeirloomLogger.new :log_level => @opts[:level]
|
10
|
+
@archive = Archive.new :name => @opts[:name],
|
11
|
+
:id => @opts[:id],
|
12
|
+
:logger => @logger
|
18
13
|
end
|
19
|
-
|
14
|
+
|
20
15
|
def build
|
21
|
-
@
|
16
|
+
unless @archive.buckets_exist? :bucket_prefix => @opts[:bucket_prefix]
|
17
|
+
@logger.error "Buckets do no exist in required regions."
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
|
21
|
+
@archive.destroy if @archive.exists?
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
archive_file = @archive.build :bucket_prefix => @opts[:bucket_prefix],
|
24
|
+
:directory => @opts[:directory],
|
25
|
+
:exclude => @opts[:exclude].split(','),
|
26
|
+
:public => @opts[:public],
|
27
|
+
:git => @opts[:git]
|
28
|
+
|
29
|
+
@archive.upload :bucket_prefix => @opts[:bucket_prefix],
|
30
|
+
:file => archive_file
|
31
|
+
|
32
|
+
@archive.authorize unless @public
|
33
|
+
|
34
|
+
@archive.cleanup
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def read_options
|
40
|
+
Trollop::options do
|
41
|
+
version Heirloom::VERSION
|
42
|
+
banner <<-EOS
|
43
|
+
|
44
|
+
Build and upload a new archive.
|
29
45
|
|
30
|
-
|
31
|
-
:file => file
|
46
|
+
Usage:
|
32
47
|
|
33
|
-
|
48
|
+
heirloom build -n NAME -i ID -b BUCKET_PREFIX [-d DIRECTORY] [-p] [-g] [-e DIRECTORIES_TO_EXCLUDE]
|
34
49
|
|
35
|
-
|
50
|
+
EOS
|
51
|
+
opt :bucket_prefix, "Bucket prefix which will be combined with region.", :type => :string
|
52
|
+
opt :directory, "Source directory of build.", :type => :string,
|
53
|
+
:default => '.'
|
54
|
+
opt :exclude, "Comma spereate list of files or directories to exclude.", :type => :string,
|
55
|
+
:default => '.git'
|
56
|
+
opt :git, "Read git commit information from directory."
|
57
|
+
opt :help, "Display Help"
|
58
|
+
opt :id, "ID of the archive to display.", :type => :string
|
59
|
+
opt :level, "Log level.", :type => :string,
|
60
|
+
:default => 'info'
|
61
|
+
opt :name, "Name of archive.", :type => :string
|
62
|
+
opt :public, "Set this archive as public readable?"
|
63
|
+
end
|
36
64
|
end
|
37
65
|
|
38
66
|
end
|
data/lib/heirloom/cli/destroy.rb
CHANGED
@@ -2,19 +2,41 @@ module Heirloom
|
|
2
2
|
module CLI
|
3
3
|
class Destroy
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
|
11
|
-
|
5
|
+
def initialize
|
6
|
+
@opts = read_options
|
7
|
+
@name = @opts[:name]
|
8
|
+
@id = @opts[:id]
|
9
|
+
@logger = HeirloomLogger.new :log_level => @opts[:level]
|
10
|
+
@archive = Archive.new :name => @name,
|
11
|
+
:id => @id,
|
12
|
+
:logger => @logger
|
12
13
|
end
|
13
14
|
|
14
15
|
def destroy
|
15
|
-
@
|
16
|
+
@archive.destroy
|
16
17
|
end
|
17
18
|
|
19
|
+
private
|
20
|
+
|
21
|
+
def read_options
|
22
|
+
Trollop::options do
|
23
|
+
version Heirloom::VERSION
|
24
|
+
banner <<-EOS
|
25
|
+
|
26
|
+
Destroy an archive.
|
27
|
+
|
28
|
+
Usage:
|
29
|
+
|
30
|
+
heirloom destroy -n NAME -i ID [-l LOG_LEVEL]
|
31
|
+
|
32
|
+
EOS
|
33
|
+
opt :help, "Display Help"
|
34
|
+
opt :id, "ID of the archive to display.", :type => :string
|
35
|
+
opt :level, "Log level.", :type => :string,
|
36
|
+
:default => 'info'
|
37
|
+
opt :name, "Name of archive.", :type => :string
|
38
|
+
end
|
39
|
+
end
|
18
40
|
end
|
19
41
|
end
|
20
42
|
end
|
@@ -2,22 +2,43 @@ module Heirloom
|
|
2
2
|
module CLI
|
3
3
|
class Download
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
@artifact = Artifact.new :name => @name,
|
12
|
-
:id => @id,
|
13
|
-
:logger => @logger
|
5
|
+
def initialize
|
6
|
+
@opts = read_options
|
7
|
+
@logger = HeirloomLogger.new :log_level => @opts[:level]
|
8
|
+
@archive = Archive.new :name => @opts[:name],
|
9
|
+
:id => @opts[:id],
|
10
|
+
:logger => @logger
|
14
11
|
end
|
15
12
|
|
16
13
|
def download
|
17
|
-
@
|
18
|
-
|
14
|
+
@archive.download :output => @opts[:output],
|
15
|
+
:region => @opts[:region]
|
19
16
|
end
|
20
17
|
|
18
|
+
private
|
19
|
+
|
20
|
+
def read_options
|
21
|
+
Trollop::options do
|
22
|
+
version Heirloom::VERSION
|
23
|
+
banner <<-EOS
|
24
|
+
|
25
|
+
Download an archive.
|
26
|
+
|
27
|
+
Usage:
|
28
|
+
|
29
|
+
heirloom download -n NAME -i ID -r REGION -o OUTPUT_FILE
|
30
|
+
|
31
|
+
EOS
|
32
|
+
opt :help, "Display Help"
|
33
|
+
opt :id, "ID of the archive to display.", :type => :string
|
34
|
+
opt :level, "Log level.", :type => :string,
|
35
|
+
:default => 'info'
|
36
|
+
opt :name, "Name of archive.", :type => :string
|
37
|
+
opt :output, "Location to download archive.", :type => :string
|
38
|
+
opt :region, "Region to download archive.", :type => :string,
|
39
|
+
:default => 'us-west-1'
|
40
|
+
end
|
41
|
+
end
|
21
42
|
end
|
22
43
|
end
|
23
44
|
end
|
data/lib/heirloom/cli/list.rb
CHANGED
@@ -2,14 +2,38 @@ module Heirloom
|
|
2
2
|
module CLI
|
3
3
|
class List
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
@
|
7
|
-
|
5
|
+
def initialize
|
6
|
+
@opts = read_options
|
7
|
+
@logger = HeirloomLogger.new :log_level => @opts[:level]
|
8
|
+
@archive = Archive.new :name => @opts[:name],
|
9
|
+
:logger => @logger
|
8
10
|
end
|
9
11
|
|
10
|
-
def list(
|
11
|
-
@
|
12
|
-
|
12
|
+
def list(count = @opts[:count])
|
13
|
+
puts @archive.list(count)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def read_options
|
19
|
+
Trollop::options do
|
20
|
+
version Heirloom::VERSION
|
21
|
+
banner <<-EOS
|
22
|
+
|
23
|
+
List versions of archive.
|
24
|
+
|
25
|
+
Usage:
|
26
|
+
|
27
|
+
heirloom list -n NAME
|
28
|
+
|
29
|
+
EOS
|
30
|
+
opt :help, "Display Help"
|
31
|
+
opt :level, "Log level.", :type => :string,
|
32
|
+
:default => 'info'
|
33
|
+
opt :name, "Name of archive.", :type => :string
|
34
|
+
opt :count, "Number of versions to return.", :type => :integer,
|
35
|
+
:default => 10
|
36
|
+
end
|
13
37
|
end
|
14
38
|
|
15
39
|
end
|
data/lib/heirloom/cli/show.rb
CHANGED
@@ -2,24 +2,46 @@ module Heirloom
|
|
2
2
|
module CLI
|
3
3
|
class Show
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
def initialize
|
6
|
+
@opts = read_options
|
7
|
+
id = @opts[:id] ? @opts[:id] : latest_id
|
8
|
+
@logger = HeirloomLogger.new :log_level => @opts[:level]
|
9
|
+
@archive = Archive.new :name => @opts[:name],
|
10
|
+
:id => id,
|
11
|
+
:logger => @logger
|
10
12
|
end
|
11
13
|
|
12
14
|
def show
|
13
|
-
@
|
14
|
-
puts @artifact.show.to_yaml
|
15
|
+
puts @archive.show.to_yaml
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
18
19
|
|
19
|
-
def latest_id
|
20
|
-
@
|
21
|
-
|
22
|
-
|
20
|
+
def latest_id
|
21
|
+
@archive = Archive.new :name => @opts[:name]
|
22
|
+
@archive.list(1).first
|
23
|
+
end
|
24
|
+
|
25
|
+
def read_options
|
26
|
+
Trollop::options do
|
27
|
+
version Heirloom::VERSION
|
28
|
+
banner <<-EOS
|
29
|
+
|
30
|
+
Show details about a version of an archive.
|
31
|
+
|
32
|
+
Usage:
|
33
|
+
|
34
|
+
heirloom show -n NAME -i ID
|
35
|
+
|
36
|
+
If -i is ommited, latest version is displayed.
|
37
|
+
|
38
|
+
EOS
|
39
|
+
opt :help, "Display Help"
|
40
|
+
opt :level, "Log level.", :type => :string,
|
41
|
+
:default => 'info'
|
42
|
+
opt :name, "Name of archive.", :type => :string
|
43
|
+
opt :id, "ID of the archive to display.", :type => :string
|
44
|
+
end
|
23
45
|
end
|
24
46
|
|
25
47
|
end
|
data/lib/heirloom/cli/update.rb
CHANGED
@@ -2,22 +2,42 @@ module Heirloom
|
|
2
2
|
module CLI
|
3
3
|
class Update
|
4
4
|
|
5
|
-
def initialize
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
@artifact = Artifact.new :name => @name,
|
12
|
-
:id => @id,
|
13
|
-
:logger => @logger
|
5
|
+
def initialize
|
6
|
+
@opts = read_options
|
7
|
+
@logger = HeirloomLogger.new :log_level => @opts[:level]
|
8
|
+
@archive = Archive.new :name => @opts[:name],
|
9
|
+
:id => @opts[:id],
|
10
|
+
:logger => @logger
|
14
11
|
end
|
15
12
|
|
16
13
|
def update
|
17
|
-
@
|
18
|
-
|
14
|
+
@archive.update :attribute => @opts[:attribute],
|
15
|
+
:value => @opts[:value]
|
19
16
|
end
|
20
17
|
|
18
|
+
private
|
19
|
+
|
20
|
+
def read_options
|
21
|
+
Trollop::options do
|
22
|
+
version Heirloom::VERSION
|
23
|
+
banner <<-EOS
|
24
|
+
|
25
|
+
Update an archive's attribute.
|
26
|
+
|
27
|
+
Usage:
|
28
|
+
|
29
|
+
heirloom update -n NAME -i ID -a ATTRIBUTE_TO_UPDATE -v NEW_VALUE
|
30
|
+
|
31
|
+
EOS
|
32
|
+
opt :attribute, "Attribute to update.", :type => :string
|
33
|
+
opt :help, "Display Help"
|
34
|
+
opt :id, "ID of the archive to display.", :type => :string
|
35
|
+
opt :level, "Log level.", :type => :string,
|
36
|
+
:default => 'info'
|
37
|
+
opt :name, "Name of archive.", :type => :string
|
38
|
+
opt :value, "New value of attribute.", :type => :string
|
39
|
+
end
|
40
|
+
end
|
21
41
|
end
|
22
42
|
end
|
23
43
|
end
|