heirloom 0.4.1rc1 → 0.5.0rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -1
- data/lib/heirloom/cli/authorize.rb +3 -4
- data/lib/heirloom/cli/build.rb +4 -5
- data/lib/heirloom/cli/destroy.rb +3 -3
- data/lib/heirloom/cli/download.rb +3 -4
- data/lib/heirloom/cli/list.rb +3 -3
- data/lib/heirloom/cli/shared.rb +16 -12
- data/lib/heirloom/cli/show.rb +3 -3
- data/lib/heirloom/cli/update.rb +3 -5
- data/lib/heirloom/config.rb +14 -8
- data/lib/heirloom/version.rb +1 -1
- data/spec/cli/authorize_spec.rb +6 -4
- data/spec/cli/build_spec.rb +4 -1
- data/spec/cli/destroy_spec.rb +6 -4
- data/spec/cli/download_spec.rb +6 -4
- data/spec/cli/list_spec.rb +3 -1
- data/spec/cli/shared_spec.rb +28 -15
- data/spec/cli/show_spec.rb +3 -1
- data/spec/cli/update_spec.rb +3 -1
- data/spec/config_spec.rb +8 -0
- metadata +12 -12
data/CHANGELOG
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
##
|
1
|
+
## v0.5.0:
|
2
2
|
|
3
3
|
* Added check to verify domain exists for all cmds except build
|
4
|
+
* Removing requirement to check simpledb on download.
|
5
|
+
* Adding requirement base_prefix on download.
|
6
|
+
* Fix error when .heirloom.yml does not exist.
|
7
|
+
* Refactor cli option validation
|
8
|
+
* Refactor cli specs
|
4
9
|
|
5
10
|
## v0.4.0:
|
6
11
|
|
@@ -10,10 +10,9 @@ module Heirloom
|
|
10
10
|
@config = load_config :logger => @logger,
|
11
11
|
:opts => @opts
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:logger => @logger
|
13
|
+
ensure_valid_options :provided => @opts,
|
14
|
+
:required => [:accounts, :name, :id],
|
15
|
+
:config => @config
|
17
16
|
|
18
17
|
ensure_domain_exists :name => @opts[:name], :config => @config
|
19
18
|
|
data/lib/heirloom/cli/build.rb
CHANGED
@@ -10,11 +10,10 @@ module Heirloom
|
|
10
10
|
@config = load_config :logger => @logger,
|
11
11
|
:opts => @opts
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
:logger => @logger
|
13
|
+
ensure_valid_options :provided => @opts,
|
14
|
+
:required => [:name, :id, :region,
|
15
|
+
:base_prefix, :directory],
|
16
|
+
:config => @config
|
18
17
|
|
19
18
|
@archive = Archive.new :name => @opts[:name],
|
20
19
|
:id => @opts[:id],
|
data/lib/heirloom/cli/destroy.rb
CHANGED
@@ -10,9 +10,9 @@ module Heirloom
|
|
10
10
|
@config = load_config :logger => @logger,
|
11
11
|
:opts => @opts
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ensure_valid_options :provided => @opts,
|
14
|
+
:required => [:name, :id],
|
15
|
+
:config => @config
|
16
16
|
|
17
17
|
ensure_domain_exists :name => @opts[:name], :config => @config
|
18
18
|
|
@@ -10,10 +10,9 @@ module Heirloom
|
|
10
10
|
@config = load_config :logger => @logger,
|
11
11
|
:opts => @opts
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:logger => @logger
|
13
|
+
ensure_valid_options :provided => @opts,
|
14
|
+
:required => [:base_prefix, :name, :id, :output],
|
15
|
+
:config => @config
|
17
16
|
|
18
17
|
@archive = Archive.new :name => @opts[:name],
|
19
18
|
:id => @opts[:id],
|
data/lib/heirloom/cli/list.rb
CHANGED
@@ -10,9 +10,9 @@ module Heirloom
|
|
10
10
|
@config = load_config :logger => @logger,
|
11
11
|
:opts => @opts
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ensure_valid_options :provided => @opts,
|
14
|
+
:required => [:name],
|
15
|
+
:config => @config
|
16
16
|
|
17
17
|
ensure_domain_exists :name => @opts[:name], :config => @config
|
18
18
|
|
data/lib/heirloom/cli/shared.rb
CHANGED
@@ -2,10 +2,23 @@ module Heirloom
|
|
2
2
|
module CLI
|
3
3
|
module Shared
|
4
4
|
|
5
|
-
def
|
5
|
+
def load_config(args)
|
6
|
+
opts = args[:opts]
|
7
|
+
logger = args[:logger]
|
8
|
+
config = Config.new :logger => logger
|
9
|
+
config.access_key = opts[:key] if opts[:key_given]
|
10
|
+
config.secret_key = opts[:secret] if opts[:secret_given]
|
11
|
+
config
|
12
|
+
end
|
13
|
+
|
14
|
+
def ensure_valid_options(args)
|
6
15
|
provided = args[:provided]
|
7
16
|
required = args[:required]
|
8
|
-
|
17
|
+
config = args[:config]
|
18
|
+
logger = config.logger
|
19
|
+
|
20
|
+
required << :key unless config.access_key
|
21
|
+
required << :secret unless config.secret_key
|
9
22
|
|
10
23
|
missing_opts = required.map do |opt|
|
11
24
|
case provided[opt]
|
@@ -20,16 +33,7 @@ module Heirloom
|
|
20
33
|
|
21
34
|
missing_opts.each {|missing_opt| logger.error missing_opt}
|
22
35
|
|
23
|
-
missing_opts.empty?
|
24
|
-
end
|
25
|
-
|
26
|
-
def load_config(args)
|
27
|
-
opts = args[:opts]
|
28
|
-
logger = args[:logger]
|
29
|
-
config = Config.new :logger => logger
|
30
|
-
config.access_key = opts[:key] if opts[:key_given]
|
31
|
-
config.secret_key = opts[:secret] if opts[:secret_given]
|
32
|
-
config
|
36
|
+
exit 1 unless missing_opts.empty?
|
33
37
|
end
|
34
38
|
|
35
39
|
def ensure_domain_exists(args)
|
data/lib/heirloom/cli/show.rb
CHANGED
@@ -10,9 +10,9 @@ module Heirloom
|
|
10
10
|
@config = load_config :logger => @logger,
|
11
11
|
:opts => @opts
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ensure_valid_options :provided => @opts,
|
14
|
+
:required => [:name],
|
15
|
+
:config => @config
|
16
16
|
|
17
17
|
ensure_domain_exists :name => @opts[:name], :config => @config
|
18
18
|
|
data/lib/heirloom/cli/update.rb
CHANGED
@@ -10,11 +10,9 @@ module Heirloom
|
|
10
10
|
@config = load_config :logger => @logger,
|
11
11
|
:opts => @opts
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
:updated_value],
|
17
|
-
:logger => @logger
|
13
|
+
ensure_valid_options :provided => @opts,
|
14
|
+
:required => [:name, :id, :attribute, :updated_value],
|
15
|
+
:config => @config
|
18
16
|
|
19
17
|
ensure_domain_exists :name => @opts[:name], :config => @config
|
20
18
|
|
data/lib/heirloom/config.rb
CHANGED
@@ -4,21 +4,27 @@ module Heirloom
|
|
4
4
|
attr_accessor :access_key, :secret_key, :primary_region, :logger
|
5
5
|
|
6
6
|
def initialize(args = {})
|
7
|
-
@config = args[:config]
|
7
|
+
@config = args[:config] ? args[:config] : load_config_file
|
8
8
|
self.logger = args[:logger] ||= HeirloomLogger.new
|
9
|
-
|
9
|
+
load_config
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
config = @config ? @config : YAML::load(File.open(config_file))
|
15
|
-
|
16
|
-
aws = config['aws']
|
17
|
-
|
12
|
+
def load_config
|
13
|
+
aws = @config['aws']
|
18
14
|
self.access_key = aws['access_key']
|
19
15
|
self.secret_key = aws['secret_key']
|
20
16
|
self.primary_region = aws['primary_region'] ||= 'us-west-1'
|
21
17
|
end
|
22
18
|
|
19
|
+
def load_config_file
|
20
|
+
config_file = "#{ENV['HOME']}/.heirloom.yml"
|
21
|
+
|
22
|
+
if File.exists? config_file
|
23
|
+
YAML::load File.open(config_file)
|
24
|
+
else
|
25
|
+
{ 'aws' => Hash.new }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
23
29
|
end
|
24
30
|
end
|
data/lib/heirloom/version.rb
CHANGED
data/spec/cli/authorize_spec.rb
CHANGED
@@ -8,15 +8,17 @@ describe Heirloom do
|
|
8
8
|
:accounts => ['test@test.com'],
|
9
9
|
:name => 'archive_name',
|
10
10
|
:id => '1.0.0' }
|
11
|
-
@
|
11
|
+
@logger_stub = stub
|
12
12
|
@config_mock = mock 'config'
|
13
13
|
@archive_mock = mock 'archive'
|
14
|
-
@config_mock.stub :logger
|
14
|
+
@config_mock.stub :logger => @logger_stub,
|
15
|
+
:access_key => 'key',
|
16
|
+
:secret_key => 'secret'
|
15
17
|
Trollop.stub(:options).and_return options
|
16
18
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
17
|
-
and_return @
|
19
|
+
and_return @logger_stub
|
18
20
|
Heirloom::CLI::Authorize.any_instance.should_receive(:load_config).
|
19
|
-
with(:logger => @
|
21
|
+
with(:logger => @logger_stub,
|
20
22
|
:opts => options).
|
21
23
|
and_return @config_mock
|
22
24
|
Heirloom::Archive.should_receive(:new).
|
data/spec/cli/build_spec.rb
CHANGED
@@ -16,6 +16,9 @@ describe Heirloom do
|
|
16
16
|
|
17
17
|
@logger_stub = stub :error => true, :info => true
|
18
18
|
@config_mock = mock 'config'
|
19
|
+
@config_mock.stub :logger => @logger_stub,
|
20
|
+
:access_key => 'key',
|
21
|
+
:secret_key => 'secret'
|
19
22
|
@archive_mock = mock 'archive'
|
20
23
|
Trollop.stub(:options).and_return options
|
21
24
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
@@ -32,7 +35,7 @@ describe Heirloom do
|
|
32
35
|
@build = Heirloom::CLI::Build.new
|
33
36
|
end
|
34
37
|
|
35
|
-
it "should build an
|
38
|
+
it "should build an archive" do
|
36
39
|
@archive_mock.should_receive(:buckets_exist?).
|
37
40
|
with(:bucket_prefix => 'base',
|
38
41
|
:regions => ["us-west-1", "us-west-2"]).
|
data/spec/cli/destroy_spec.rb
CHANGED
@@ -7,15 +7,17 @@ describe Heirloom do
|
|
7
7
|
options = { :name => 'archive_name',
|
8
8
|
:id => '1.0.0',
|
9
9
|
:level => 'info' }
|
10
|
-
@
|
10
|
+
@logger_stub = stub 'logger'
|
11
11
|
@config_mock = mock 'config'
|
12
12
|
@archive_mock = mock 'archive'
|
13
|
-
@config_mock.stub :logger
|
13
|
+
@config_mock.stub :logger => @logger_stub,
|
14
|
+
:access_key => 'key',
|
15
|
+
:secret_key => 'secret'
|
14
16
|
Trollop.stub(:options).and_return options
|
15
17
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
16
|
-
and_return @
|
18
|
+
and_return @logger_stub
|
17
19
|
Heirloom::CLI::Destroy.any_instance.should_receive(:load_config).
|
18
|
-
with(:logger => @
|
20
|
+
with(:logger => @logger_stub,
|
19
21
|
:opts => options).
|
20
22
|
and_return @config_mock
|
21
23
|
Heirloom::Archive.should_receive(:new).
|
data/spec/cli/download_spec.rb
CHANGED
@@ -10,16 +10,18 @@ describe Heirloom do
|
|
10
10
|
:output => '/tmp/test123',
|
11
11
|
:region => 'us-east-1',
|
12
12
|
:base_prefix => 'base' }
|
13
|
-
@
|
13
|
+
@logger_stub = stub 'logger'
|
14
14
|
@config_mock = mock 'config'
|
15
15
|
@archive_mock = mock 'archive'
|
16
|
-
@config_mock.stub :logger
|
16
|
+
@config_mock.stub :logger => @logger_stub,
|
17
|
+
:access_key => 'key',
|
18
|
+
:secret_key => 'secret'
|
17
19
|
Trollop.stub(:options).and_return options
|
18
20
|
Heirloom::HeirloomLogger.should_receive(:new).
|
19
21
|
with(:log_level => 'info').
|
20
|
-
and_return @
|
22
|
+
and_return @logger_stub
|
21
23
|
Heirloom::CLI::Download.any_instance.should_receive(:load_config).
|
22
|
-
with(:logger => @
|
24
|
+
with(:logger => @logger_stub,
|
23
25
|
:opts => options).
|
24
26
|
and_return @config_mock
|
25
27
|
Heirloom::Archive.should_receive(:new).
|
data/spec/cli/list_spec.rb
CHANGED
@@ -10,7 +10,9 @@ describe Heirloom do
|
|
10
10
|
@logger_stub = stub :debug => true
|
11
11
|
@config_mock = mock 'config'
|
12
12
|
@archive_mock = mock 'archive'
|
13
|
-
@config_mock.stub :logger
|
13
|
+
@config_mock.stub :logger => @logger_mock,
|
14
|
+
:access_key => 'key',
|
15
|
+
:secret_key => 'secret'
|
14
16
|
Trollop.stub(:options).and_return options
|
15
17
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
16
18
|
and_return @logger_stub
|
data/spec/cli/shared_spec.rb
CHANGED
@@ -4,44 +4,57 @@ require 'heirloom/cli'
|
|
4
4
|
|
5
5
|
describe Heirloom do
|
6
6
|
|
7
|
-
context "testing
|
7
|
+
context "testing ensure_valid_options" do
|
8
8
|
|
9
9
|
before do
|
10
|
+
@config_mock = mock 'config'
|
10
11
|
@logger_mock = mock 'logger'
|
12
|
+
@config_mock.stub :logger => @logger_mock,
|
13
|
+
:access_key => 'key',
|
14
|
+
:secret_key => 'secret'
|
11
15
|
@object = Object.new
|
12
16
|
@object.extend Heirloom::CLI::Shared
|
13
17
|
end
|
14
18
|
|
15
19
|
it "should return false if a required array is emtpy" do
|
16
20
|
@logger_mock.should_receive(:error)
|
17
|
-
@object.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
lambda { @object.ensure_valid_options(:provided => {
|
22
|
+
:array => [],
|
23
|
+
:string => 'present'
|
24
|
+
},
|
25
|
+
:required => [:array, :string],
|
26
|
+
:config => @config_mock) }.
|
27
|
+
should raise_error SystemExit
|
21
28
|
end
|
22
29
|
|
23
30
|
it "should return false if a required string is nil" do
|
24
31
|
@logger_mock.should_receive(:error)
|
25
|
-
@object.
|
26
|
-
|
27
|
-
|
28
|
-
|
32
|
+
lambda { @object.ensure_valid_options(:provided => {
|
33
|
+
:array => ['present'],
|
34
|
+
:string => nil
|
35
|
+
},
|
36
|
+
:required => [:array, :string],
|
37
|
+
:config => @config_mock) }.
|
38
|
+
should raise_error SystemExit
|
29
39
|
end
|
30
40
|
|
31
41
|
it "should return false if a require string is nil & array is empty" do
|
32
42
|
@logger_mock.should_receive(:error).exactly(2).times
|
33
|
-
@object.
|
34
|
-
|
35
|
-
|
36
|
-
|
43
|
+
lambda { @object.ensure_valid_options(:provided => {
|
44
|
+
:array => [],
|
45
|
+
:string => nil
|
46
|
+
},
|
47
|
+
:required => [:array, :string],
|
48
|
+
:config => @config_mock) }.
|
49
|
+
should raise_error SystemExit
|
37
50
|
end
|
38
51
|
|
39
52
|
it "should return true if all options are present" do
|
40
53
|
@logger_mock.should_receive(:error).exactly(0).times
|
41
|
-
@object.
|
54
|
+
@object.ensure_valid_options(:provided => { :array => ['present'],
|
42
55
|
:string => 'present' },
|
43
56
|
:required => [:array, :string],
|
44
|
-
:
|
57
|
+
:config => @config_mock)
|
45
58
|
end
|
46
59
|
end
|
47
60
|
|
data/spec/cli/show_spec.rb
CHANGED
@@ -10,7 +10,9 @@ describe Heirloom do
|
|
10
10
|
@logger_stub = stub :debug => true
|
11
11
|
@config_mock = mock 'config'
|
12
12
|
@archive_mock = mock 'archive'
|
13
|
-
@config_mock.stub :logger
|
13
|
+
@config_mock.stub :logger => @logger_stub,
|
14
|
+
:access_key => 'key',
|
15
|
+
:secret_key => 'secret'
|
14
16
|
Trollop.stub(:options).and_return options
|
15
17
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
16
18
|
and_return @logger_stub
|
data/spec/cli/update_spec.rb
CHANGED
@@ -12,7 +12,9 @@ describe Heirloom do
|
|
12
12
|
@logger_stub = stub :debug => true
|
13
13
|
@config_mock = mock 'config'
|
14
14
|
@archive_mock = mock 'archive'
|
15
|
-
@config_mock.stub :logger
|
15
|
+
@config_mock.stub :logger => @logger_stub,
|
16
|
+
:access_key => 'key',
|
17
|
+
:secret_key => 'secret'
|
16
18
|
Trollop.stub(:options).and_return options
|
17
19
|
Heirloom::HeirloomLogger.should_receive(:new).with(:log_level => 'info').
|
18
20
|
and_return @logger_stub
|
data/spec/config_spec.rb
CHANGED
@@ -21,6 +21,7 @@ describe Heirloom do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should create a new config object and read from ~/.heirloom.yml" do
|
24
|
+
File.should_receive(:exists?).and_return true
|
24
25
|
File.should_receive(:open).with("#{ENV['HOME']}/.heirloom.yml").
|
25
26
|
and_return(@config.to_yaml)
|
26
27
|
config = Heirloom::Config.new
|
@@ -36,5 +37,12 @@ describe Heirloom do
|
|
36
37
|
config.primary_region.should == 'us-west-1'
|
37
38
|
end
|
38
39
|
|
40
|
+
it "should load a blank config if the file does not exist and no config passed" do
|
41
|
+
File.should_receive(:exists?).and_return false
|
42
|
+
config = Heirloom::Config.new
|
43
|
+
config.access_key.should be_nil
|
44
|
+
config.secret_key.should be_nil
|
45
|
+
config.primary_region.should == 'us-west-1'
|
46
|
+
end
|
39
47
|
|
40
48
|
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.
|
4
|
+
version: 0.5.0rc1
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-08-17 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70238839864540 !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: *
|
24
|
+
version_requirements: *70238839864540
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: fog
|
27
|
-
requirement: &
|
27
|
+
requirement: &70238839863940 !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: *
|
35
|
+
version_requirements: *70238839863940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: grit
|
38
|
-
requirement: &
|
38
|
+
requirement: &70238839863260 !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: *
|
46
|
+
version_requirements: *70238839863260
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: logger
|
49
|
-
requirement: &
|
49
|
+
requirement: &70238839862320 !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: *
|
57
|
+
version_requirements: *70238839862320
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: trollop
|
60
|
-
requirement: &
|
60
|
+
requirement: &70238839861680 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70238839861680
|
69
69
|
description: I help build and manage building tar.gz files and deploying them into
|
70
70
|
the cloud
|
71
71
|
email:
|
@@ -164,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
segments:
|
166
166
|
- 0
|
167
|
-
hash:
|
167
|
+
hash: 911003878403684883
|
168
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
169
|
none: false
|
170
170
|
requirements:
|