heirloom 0.6.1 → 0.7.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +11 -1
- data/lib/heirloom/acl/s3.rb +1 -1
- data/lib/heirloom/archive/authorizer.rb +1 -1
- data/lib/heirloom/archive/builder.rb +1 -3
- data/lib/heirloom/archive/destroyer.rb +2 -19
- data/lib/heirloom/archive/lister.rb +1 -1
- data/lib/heirloom/archive/reader.rb +1 -1
- data/lib/heirloom/archive/teardowner.rb +48 -0
- data/lib/heirloom/archive/verifier.rb +2 -2
- data/lib/heirloom/archive.rb +16 -3
- data/lib/heirloom/aws/s3.rb +8 -4
- data/lib/heirloom/aws/simpledb.rb +6 -1
- data/lib/heirloom/catalog/add.rb +31 -0
- data/lib/heirloom/catalog/delete.rb +37 -0
- data/lib/heirloom/catalog/list.rb +22 -0
- data/lib/heirloom/catalog/setup.rb +30 -0
- data/lib/heirloom/catalog/show.rb +35 -0
- data/lib/heirloom/catalog/verify.rb +39 -0
- data/lib/heirloom/catalog.rb +65 -0
- data/lib/heirloom/cli/authorize.rb +4 -4
- data/lib/heirloom/cli/catalog.rb +62 -0
- data/lib/heirloom/cli/destroy.rb +4 -4
- data/lib/heirloom/cli/download.rb +24 -13
- data/lib/heirloom/cli/list.rb +2 -2
- data/lib/heirloom/cli/setup.rb +21 -6
- data/lib/heirloom/cli/shared.rb +12 -3
- data/lib/heirloom/cli/show.rb +3 -3
- data/lib/heirloom/cli/tag.rb +3 -3
- data/lib/heirloom/cli/teardown.rb +75 -0
- data/lib/heirloom/cli/upload.rb +17 -26
- data/lib/heirloom/cli.rb +7 -1
- data/lib/heirloom/directory/directory.rb +1 -1
- data/lib/heirloom/version.rb +1 -1
- data/lib/heirloom.rb +7 -6
- data/spec/acl/s3_spec.rb +2 -7
- data/spec/archive/destroyer_spec.rb +4 -17
- data/spec/archive/lister_spec.rb +1 -1
- data/spec/archive/reader_spec.rb +9 -9
- data/spec/archive/teardowner_spec.rb +42 -0
- data/spec/archive_spec.rb +23 -3
- data/spec/aws/s3_spec.rb +5 -0
- data/spec/aws/simpledb_spec.rb +13 -3
- data/spec/catalog/add_spec.rb +28 -0
- data/spec/catalog/delete_spec.rb +35 -0
- data/spec/catalog/list_spec.rb +21 -0
- data/spec/catalog/setup_spec.rb +29 -0
- data/spec/catalog/show_spec.rb +32 -0
- data/spec/catalog/verify_spec.rb +47 -0
- data/spec/catalog_spec.rb +63 -0
- data/spec/cli/catalog_spec.rb +42 -0
- data/spec/cli/destroy_spec.rb +1 -1
- data/spec/cli/download_spec.rb +68 -26
- data/spec/cli/setup_spec.rb +11 -4
- data/spec/cli/shared_spec.rb +23 -0
- data/spec/cli/teardown_spec.rb +52 -0
- data/spec/cli/upload_spec.rb +6 -5
- metadata +44 -17
data/CHANGELOG
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
-
##
|
1
|
+
## HEAD:
|
2
|
+
|
3
|
+
* Adding catalog which will contain all heirloom regions & bases.
|
4
|
+
* CLI will lookup base & region from catalog.
|
5
|
+
* Removing base requirement for all subcmds outside download & setup.
|
6
|
+
* Added teardown command to delete domains & buckets.
|
7
|
+
* Enclosing simpledb domains in `s
|
8
|
+
* Added catalog subcommand to list available Heirlooms from catalog.
|
9
|
+
* Reducing log levels
|
10
|
+
|
11
|
+
### v0.6.1:
|
2
12
|
|
3
13
|
* Allowing engineer to specify region for metadata
|
4
14
|
* Ensuring metadata is in an upload region
|
data/lib/heirloom/acl/s3.rb
CHANGED
@@ -34,8 +34,6 @@ module Heirloom
|
|
34
34
|
|
35
35
|
add_git_commit if args[:git]
|
36
36
|
|
37
|
-
@logger.info "Build complete."
|
38
|
-
|
39
37
|
@local_build
|
40
38
|
end
|
41
39
|
|
@@ -70,7 +68,7 @@ module Heirloom
|
|
70
68
|
'encrypted' => encrypted?,
|
71
69
|
'base' => @base,
|
72
70
|
'id' => @id }
|
73
|
-
@logger.info "
|
71
|
+
@logger.info "Adding entry #{@id}."
|
74
72
|
sdb.put_attributes @domain, @id, attributes
|
75
73
|
end
|
76
74
|
|
@@ -12,9 +12,8 @@ module Heirloom
|
|
12
12
|
|
13
13
|
def destroy(args)
|
14
14
|
regions = args[:regions]
|
15
|
-
keep_domain = args[:keep_domain]
|
16
15
|
|
17
|
-
@logger.info "Destroying #{@name}
|
16
|
+
@logger.info "Destroying #{@name} #{@id}"
|
18
17
|
|
19
18
|
regions.each do |region|
|
20
19
|
bucket = reader.get_bucket :region => region
|
@@ -22,7 +21,7 @@ module Heirloom
|
|
22
21
|
key = "#{@id}.tar.gz"
|
23
22
|
|
24
23
|
if bucket
|
25
|
-
@logger.
|
24
|
+
@logger.debug "Destroying 's3://#{bucket}/#{@name}/#{key}'."
|
26
25
|
|
27
26
|
s3_destroyer = Destroyer::S3.new :config => @config,
|
28
27
|
:region => region
|
@@ -34,26 +33,10 @@ module Heirloom
|
|
34
33
|
end
|
35
34
|
|
36
35
|
sdb.delete @domain, @id
|
37
|
-
|
38
|
-
destroy_domain unless keep_domain
|
39
36
|
end
|
40
37
|
|
41
38
|
private
|
42
39
|
|
43
|
-
def destroy_domain
|
44
|
-
|
45
|
-
# Simple DB is eventually consisten
|
46
|
-
# Sleep for 3 sec for changes to reflect
|
47
|
-
Kernel.sleep 3
|
48
|
-
|
49
|
-
if sdb.domain_empty? @domain
|
50
|
-
@logger.info "Domain #{@domain} empty. Destroying."
|
51
|
-
sdb.delete_domain @domain
|
52
|
-
end
|
53
|
-
|
54
|
-
@logger.info "Destroy complete."
|
55
|
-
end
|
56
|
-
|
57
40
|
def sdb
|
58
41
|
@sdb ||= AWS::SimpleDB.new :config => @config
|
59
42
|
end
|
@@ -9,7 +9,7 @@ module Heirloom
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def list(limit=10)
|
12
|
-
sdb.select("select * from
|
12
|
+
sdb.select("select * from `#{@domain}` where built_at > '2000-01-01T00:00:00.000Z'\
|
13
13
|
order by built_at desc limit #{limit}").keys
|
14
14
|
end
|
15
15
|
|
@@ -57,7 +57,7 @@ module Heirloom
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def show
|
60
|
-
query = sdb.select "select * from
|
60
|
+
query = sdb.select "select * from `#{@domain}` where itemName() = '#{@id}'"
|
61
61
|
items = query[@id] ? query[@id] : {}
|
62
62
|
Hash.new.tap do |hash|
|
63
63
|
items.each_pair.map do |key,value|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Heirloom
|
2
|
+
|
3
|
+
class Teardowner
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@config = args[:config]
|
7
|
+
@name = args[:name]
|
8
|
+
@domain = "heirloom_#{@name}"
|
9
|
+
@logger = @config.logger
|
10
|
+
@region = @config.metadata_region
|
11
|
+
end
|
12
|
+
|
13
|
+
def delete_buckets(args)
|
14
|
+
regions = args[:regions]
|
15
|
+
bucket_prefix = args[:bucket_prefix]
|
16
|
+
|
17
|
+
regions.each do |region|
|
18
|
+
bucket = "#{bucket_prefix}-#{region}"
|
19
|
+
|
20
|
+
if verifier.bucket_exists? :region => region,
|
21
|
+
:bucket_prefix => bucket_prefix
|
22
|
+
@logger.info "Destroying bucket #{bucket} in #{region}."
|
23
|
+
s3 = AWS::S3.new :config => @config,
|
24
|
+
:region => region
|
25
|
+
s3.delete_bucket bucket
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def delete_domain
|
31
|
+
if verifier.domain_exists?
|
32
|
+
@logger.info "Destroying domain #{@name} in #{@region}."
|
33
|
+
sdb.delete_domain @domain
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def verifier
|
40
|
+
@verifier ||= Verifier.new :config => @config,
|
41
|
+
:name => @name
|
42
|
+
end
|
43
|
+
|
44
|
+
def sdb
|
45
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -36,7 +36,7 @@ module Heirloom
|
|
36
36
|
@logger.debug "Bucket '#{bucket}' exists in '#{region}'."
|
37
37
|
true
|
38
38
|
else
|
39
|
-
@logger.
|
39
|
+
@logger.debug "Bucket '#{bucket}' does not exist in '#{region}'."
|
40
40
|
false
|
41
41
|
end
|
42
42
|
end
|
@@ -48,7 +48,7 @@ module Heirloom
|
|
48
48
|
@logger.debug "Domain '#{@name}' exists in '#{region}'."
|
49
49
|
true
|
50
50
|
else
|
51
|
-
@logger.
|
51
|
+
@logger.debug "Domain '#{@name}' does not exist in '#{region}'."
|
52
52
|
false
|
53
53
|
end
|
54
54
|
end
|
data/lib/heirloom/archive.rb
CHANGED
@@ -5,6 +5,7 @@ require 'heirloom/archive/updater.rb'
|
|
5
5
|
require 'heirloom/archive/uploader.rb'
|
6
6
|
require 'heirloom/archive/downloader.rb'
|
7
7
|
require 'heirloom/archive/setuper.rb'
|
8
|
+
require 'heirloom/archive/teardowner.rb'
|
8
9
|
require 'heirloom/archive/writer.rb'
|
9
10
|
require 'heirloom/archive/authorizer.rb'
|
10
11
|
require 'heirloom/archive/destroyer.rb'
|
@@ -41,6 +42,14 @@ module Heirloom
|
|
41
42
|
setuper.setup args
|
42
43
|
end
|
43
44
|
|
45
|
+
def delete_buckets(args)
|
46
|
+
teardowner.delete_buckets args
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete_domain
|
50
|
+
teardowner.delete_domain
|
51
|
+
end
|
52
|
+
|
44
53
|
def update(args)
|
45
54
|
updater.update args
|
46
55
|
end
|
@@ -61,9 +70,8 @@ module Heirloom
|
|
61
70
|
verifier.domain_exists?
|
62
71
|
end
|
63
72
|
|
64
|
-
def destroy
|
65
|
-
destroyer.destroy :regions
|
66
|
-
:keep_domain => args[:keep_domain]
|
73
|
+
def destroy
|
74
|
+
destroyer.destroy :regions => regions
|
67
75
|
end
|
68
76
|
|
69
77
|
def show
|
@@ -132,6 +140,11 @@ module Heirloom
|
|
132
140
|
:name => @name
|
133
141
|
end
|
134
142
|
|
143
|
+
def teardowner
|
144
|
+
@teardowner ||= Teardowner.new :config => @config,
|
145
|
+
:name => @name
|
146
|
+
end
|
147
|
+
|
135
148
|
def verifier
|
136
149
|
@verifier ||= Verifier.new :config => @config,
|
137
150
|
:name => @name
|
data/lib/heirloom/aws/s3.rb
CHANGED
@@ -8,10 +8,10 @@ module Heirloom
|
|
8
8
|
@config = args[:config]
|
9
9
|
@region = args[:region]
|
10
10
|
|
11
|
-
@s3 = Fog::Storage.new :provider
|
12
|
-
:aws_access_key_id
|
13
|
-
:aws_secret_access_key
|
14
|
-
:region
|
11
|
+
@s3 = Fog::Storage.new :provider => 'AWS',
|
12
|
+
:aws_access_key_id => @config.access_key,
|
13
|
+
:aws_secret_access_key => @config.secret_key,
|
14
|
+
:region => @region
|
15
15
|
end
|
16
16
|
|
17
17
|
def delete_object(bucket_name, object_name, options = {})
|
@@ -22,6 +22,10 @@ module Heirloom
|
|
22
22
|
@s3.directories.get bucket
|
23
23
|
end
|
24
24
|
|
25
|
+
def delete_bucket(bucket)
|
26
|
+
@s3.delete_bucket bucket
|
27
|
+
end
|
28
|
+
|
25
29
|
def get_object(bucket_name, object_name)
|
26
30
|
@s3.get_object(bucket_name, object_name).body
|
27
31
|
end
|
@@ -44,10 +44,15 @@ module Heirloom
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def count(domain)
|
47
|
-
body = @sdb.select("SELECT count(*) FROM
|
47
|
+
body = @sdb.select("SELECT count(*) FROM `#{domain}`").body
|
48
48
|
body['Items']['Domain']['Count'].first.to_i
|
49
49
|
end
|
50
50
|
|
51
|
+
def item_count(domain, item)
|
52
|
+
query = "SELECT count(*) FROM `#{domain}` WHERE itemName() = '#{item}'"
|
53
|
+
@sdb.select(query).body['Items']['Domain']['Count'].first.to_i
|
54
|
+
end
|
55
|
+
|
51
56
|
end
|
52
57
|
end
|
53
58
|
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Heirloom
|
2
|
+
class Catalog
|
3
|
+
class Add
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@config = args[:config]
|
7
|
+
@name = args[:name]
|
8
|
+
@logger = @config.logger
|
9
|
+
end
|
10
|
+
|
11
|
+
def add_to_catalog(args)
|
12
|
+
regions = args[:regions]
|
13
|
+
base = args[:base]
|
14
|
+
|
15
|
+
@logger.info "Adding #{@name} to catalog."
|
16
|
+
|
17
|
+
sdb.put_attributes 'heirloom',
|
18
|
+
"heirloom_#{@name}",
|
19
|
+
{ "regions" => regions, "base" => base }
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def sdb
|
26
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Heirloom
|
2
|
+
class Catalog
|
3
|
+
class Delete
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@config = args[:config]
|
7
|
+
@name = args[:name]
|
8
|
+
@logger = @config.logger
|
9
|
+
end
|
10
|
+
|
11
|
+
def delete_from_catalog
|
12
|
+
domain = "heirloom_#{@name}"
|
13
|
+
|
14
|
+
return false unless catalog_domain_exists?
|
15
|
+
|
16
|
+
@logger.info "Deleting #{@name} from catalog."
|
17
|
+
|
18
|
+
sdb.delete 'heirloom', domain
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def catalog_domain_exists?
|
24
|
+
verify.catalog_domain_exists?
|
25
|
+
end
|
26
|
+
|
27
|
+
def sdb
|
28
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
29
|
+
end
|
30
|
+
|
31
|
+
def verify
|
32
|
+
@verify ||= Catalog::Verify.new :config => @config
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Heirloom
|
2
|
+
class Catalog
|
3
|
+
class List
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@config = args[:config]
|
7
|
+
end
|
8
|
+
|
9
|
+
def all
|
10
|
+
query = "SELECT * FROM heirloom"
|
11
|
+
sdb.select query
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def sdb
|
17
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Heirloom
|
2
|
+
class Catalog
|
3
|
+
class Setup
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@config = args[:config]
|
7
|
+
@logger = @config.logger
|
8
|
+
@region = @config.metadata_region
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_catalog_domain
|
12
|
+
unless verify.catalog_domain_exists?
|
13
|
+
@logger.info "Creating catalog in #{@region}."
|
14
|
+
sdb.create_domain "heirloom"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def sdb
|
21
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
22
|
+
end
|
23
|
+
|
24
|
+
def verify
|
25
|
+
@verify ||= Catalog::Verify.new :config => @config
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Heirloom
|
2
|
+
class Catalog
|
3
|
+
class Show
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@config = args[:config]
|
7
|
+
@name = args[:name]
|
8
|
+
end
|
9
|
+
|
10
|
+
def regions
|
11
|
+
lookup :name => @name, :attribute => 'regions'
|
12
|
+
end
|
13
|
+
|
14
|
+
def base
|
15
|
+
lookup(:name => @name, :attribute => 'base').first
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def lookup(args)
|
21
|
+
name = args[:name]
|
22
|
+
attribute = args[:attribute]
|
23
|
+
domain = "heirloom_#{name}"
|
24
|
+
query = "select #{attribute} from heirloom where itemName() = '#{domain}'"
|
25
|
+
result = sdb.select(query)
|
26
|
+
result[domain][attribute]
|
27
|
+
end
|
28
|
+
|
29
|
+
def sdb
|
30
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Heirloom
|
2
|
+
class Catalog
|
3
|
+
class Verify
|
4
|
+
|
5
|
+
def initialize(args)
|
6
|
+
@config = args[:config]
|
7
|
+
@logger = @config.logger
|
8
|
+
@region = @config.metadata_region
|
9
|
+
end
|
10
|
+
|
11
|
+
def catalog_domain_exists?
|
12
|
+
if sdb.domain_exists? 'heirloom'
|
13
|
+
@logger.debug "Catalog exists in #{@region}."
|
14
|
+
true
|
15
|
+
else
|
16
|
+
@logger.debug "Catalog does not exist in #{@region}."
|
17
|
+
false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def entry_exists_in_catalog?(entry)
|
22
|
+
if sdb.item_count('heirloom', "heirloom_#{entry}").zero?
|
23
|
+
@logger.debug "#{entry} does not exist in catalog."
|
24
|
+
false
|
25
|
+
else
|
26
|
+
@logger.debug "#{entry} exists in catalog."
|
27
|
+
true
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def sdb
|
34
|
+
@sdb ||= AWS::SimpleDB.new :config => @config
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'heirloom/catalog/add.rb'
|
2
|
+
require 'heirloom/catalog/delete.rb'
|
3
|
+
require 'heirloom/catalog/list.rb'
|
4
|
+
require 'heirloom/catalog/setup.rb'
|
5
|
+
require 'heirloom/catalog/show.rb'
|
6
|
+
require 'heirloom/catalog/verify.rb'
|
7
|
+
|
8
|
+
module Heirloom
|
9
|
+
class Catalog
|
10
|
+
|
11
|
+
def initialize(args)
|
12
|
+
@config = args[:config]
|
13
|
+
@name = args[:name]
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_catalog_domain
|
17
|
+
setup.create_catalog_domain
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete_from_catalog
|
21
|
+
delete.delete_from_catalog
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_to_catalog(args)
|
25
|
+
add.add_to_catalog args
|
26
|
+
end
|
27
|
+
|
28
|
+
def regions
|
29
|
+
show.regions
|
30
|
+
end
|
31
|
+
|
32
|
+
def base
|
33
|
+
show.base
|
34
|
+
end
|
35
|
+
|
36
|
+
def all
|
37
|
+
list.all
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def add
|
43
|
+
@add ||= Catalog::Add.new :config => @config,
|
44
|
+
:name => @name
|
45
|
+
end
|
46
|
+
|
47
|
+
def delete
|
48
|
+
@delete ||= Catalog::Delete.new :config => @config,
|
49
|
+
:name => @name
|
50
|
+
end
|
51
|
+
|
52
|
+
def list
|
53
|
+
@list ||= Catalog::List.new :config => @config
|
54
|
+
end
|
55
|
+
|
56
|
+
def setup
|
57
|
+
@setup ||= Catalog::Setup.new :config => @config
|
58
|
+
end
|
59
|
+
|
60
|
+
def show
|
61
|
+
@show ||= Catalog::Show.new :config => @config,
|
62
|
+
:name => @name
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -37,24 +37,24 @@ module Heirloom
|
|
37
37
|
version Heirloom::VERSION
|
38
38
|
banner <<-EOS
|
39
39
|
|
40
|
-
Authorize access from another AWS account to an
|
40
|
+
Authorize access from another AWS account to an Heirloom.
|
41
41
|
|
42
42
|
Usage:
|
43
43
|
|
44
44
|
heirloom authorize -n NAME -i ID -a AWS_ACCOUNT1 -a AWS_ACCOUNT2
|
45
45
|
|
46
|
-
Note: This will replace all current authorizations with those specified and make the
|
46
|
+
Note: This will replace all current authorizations with those specified and make the Heirloom private.
|
47
47
|
|
48
48
|
EOS
|
49
49
|
opt :accounts, "AWS Account(s) email to authorize. Can be specified multiple times.", :type => :string,
|
50
50
|
:multi => true
|
51
51
|
opt :help, "Display Help"
|
52
|
-
opt :id, "ID of the
|
52
|
+
opt :id, "ID of the Heirloom to authorize.", :type => :string
|
53
53
|
opt :level, "Log level [debug|info|warn|error].", :type => :string,
|
54
54
|
:default => 'info'
|
55
55
|
opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
|
56
56
|
:default => 'us-west-1'
|
57
|
-
opt :name, "Name of
|
57
|
+
opt :name, "Name of Heirloom.", :type => :string
|
58
58
|
opt :aws_access_key, "AWS Access Key ID", :type => :string,
|
59
59
|
:short => :none
|
60
60
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Heirloom
|
2
|
+
module CLI
|
3
|
+
class Catalog
|
4
|
+
|
5
|
+
include Heirloom::CLI::Shared
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@opts = read_options
|
9
|
+
@logger = HeirloomLogger.new :log_level => @opts[:level]
|
10
|
+
@config = load_config :logger => @logger,
|
11
|
+
:opts => @opts
|
12
|
+
|
13
|
+
ensure_valid_options :provided => @opts,
|
14
|
+
:required => [],
|
15
|
+
:config => @config
|
16
|
+
ensure_valid_region :region => @opts[:metadata_region],
|
17
|
+
:config => @config
|
18
|
+
@catalog = Heirloom::Catalog.new :config => @config
|
19
|
+
end
|
20
|
+
|
21
|
+
def list
|
22
|
+
if @opts[:details]
|
23
|
+
jj catalog_with_heirloom_prefix_removed
|
24
|
+
else
|
25
|
+
jj catalog_with_heirloom_prefix_removed.keys
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def catalog_with_heirloom_prefix_removed
|
32
|
+
Hash[@catalog.all.map { |k, v| [k.sub(/heirloom_/, ''), v] }]
|
33
|
+
end
|
34
|
+
|
35
|
+
def read_options
|
36
|
+
Trollop::options do
|
37
|
+
version Heirloom::VERSION
|
38
|
+
banner <<-EOS
|
39
|
+
|
40
|
+
Show catalog of Heirlooms.
|
41
|
+
|
42
|
+
Usage:
|
43
|
+
|
44
|
+
heirloom catalog
|
45
|
+
|
46
|
+
EOS
|
47
|
+
opt :help, "Display Help"
|
48
|
+
opt :level, "Log level [debug|info|warn|error].", :type => :string,
|
49
|
+
:default => 'info'
|
50
|
+
opt :details, "Include details."
|
51
|
+
opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
|
52
|
+
:default => 'us-west-1'
|
53
|
+
opt :aws_access_key, "AWS Access Key ID", :type => :string,
|
54
|
+
:short => :none
|
55
|
+
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|
56
|
+
:short => :none
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/heirloom/cli/destroy.rb
CHANGED
@@ -27,7 +27,7 @@ module Heirloom
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def destroy
|
30
|
-
@archive.destroy
|
30
|
+
@archive.destroy
|
31
31
|
end
|
32
32
|
|
33
33
|
private
|
@@ -37,7 +37,7 @@ module Heirloom
|
|
37
37
|
version Heirloom::VERSION
|
38
38
|
banner <<-EOS
|
39
39
|
|
40
|
-
Destroy an
|
40
|
+
Destroy an Heirloom.
|
41
41
|
|
42
42
|
Usage:
|
43
43
|
|
@@ -45,12 +45,12 @@ heirloom destroy -n NAME -i ID
|
|
45
45
|
|
46
46
|
EOS
|
47
47
|
opt :help, "Display Help"
|
48
|
-
opt :id, "ID of the
|
48
|
+
opt :id, "ID of the Heirloom to display.", :type => :string
|
49
49
|
opt :level, "Log level [debug|info|warn|error].", :type => :string,
|
50
50
|
:default => 'info'
|
51
51
|
opt :metadata_region, "AWS region to store Heirloom metadata.", :type => :string,
|
52
52
|
:default => 'us-west-1'
|
53
|
-
opt :name, "Name of
|
53
|
+
opt :name, "Name of Heirloom.", :type => :string
|
54
54
|
opt :aws_access_key, "AWS Access Key ID", :type => :string,
|
55
55
|
:short => :none
|
56
56
|
opt :aws_secret_key, "AWS Secret Access Key", :type => :string,
|