rivet 2.0.0 → 3.0.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +4 -4
- data/.travis.yml +5 -5
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +42 -26
- data/README.md +61 -10
- data/bin/rivet +14 -9
- data/example/ec2/defaults.rb +6 -0
- data/example/ec2/example.rb +8 -0
- data/example/ec2/user_data.erb +2 -0
- data/lib/rivet/{autoscale.rb → as/autoscale.rb} +33 -4
- data/lib/rivet/{config.rb → as/autoscale_config.rb} +3 -33
- data/lib/rivet/{launch_config.rb → as/launch_config.rb} +8 -11
- data/lib/rivet/{aws_utils.rb → common/aws_utils.rb} +27 -29
- data/lib/rivet/common/base_aws_attributes.rb +15 -0
- data/lib/rivet/common/base_config.rb +40 -0
- data/lib/rivet/{client.rb → common/client.rb} +11 -10
- data/lib/rivet/ec2/ec2.rb +163 -0
- data/lib/rivet/ec2/ec2_config.rb +19 -0
- data/lib/rivet/utils.rb +4 -3
- data/lib/rivet/version.rb +1 -1
- data/lib/rivet.rb +16 -11
- data/rivet.gemspec +6 -5
- data/spec/as/autoscale_config_spec.rb +65 -0
- data/spec/{aws_autoscale_wrapper_spec.rb → as/aws_autoscale_wrapper_spec.rb} +1 -1
- data/spec/aws_utils_spec.rb +44 -0
- data/spec/base_config_spec.rb +31 -0
- data/spec/bootstrap_spec.rb +1 -1
- data/spec/ec2/ec2_config_spec.rb +29 -0
- data/spec/launch_config_spec.rb +1 -1
- data/spec/shared_examples/a_config.rb +98 -0
- data/spec/shared_examples/a_config_util.rb +33 -0
- data/spec/spec_setup.rb +63 -39
- data/spec/util_spec.rb +16 -23
- metadata +63 -43
- data/lib/rivet/deep_merge.rb +0 -29
- data/spec/config_spec.rb +0 -168
- /data/lib/rivet/{aws_autoscale_wrapper.rb → as/aws_autoscale_wrapper.rb} +0 -0
- /data/lib/rivet/{bootstrap.rb → common/bootstrap.rb} +0 -0
- /data/lib/rivet/{config_proxy.rb → common/config_proxy.rb} +0 -0
- /data/lib/rivet/{logger.rb → common/logger.rb} +0 -0
- /data/lib/rivet/{open_state.rb → common/open_state.rb} +0 -0
@@ -21,37 +21,38 @@ module Rivet
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
def self.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
24
|
+
def self.parse_profile_text(text)
|
25
|
+
current_profile = nil
|
26
|
+
profile_matcher = /^\[(profile+\s)?(\w+)\]/
|
27
|
+
option_matcher = /(\w.*)\s*=\s*(\S.*)\s*/
|
28
|
+
aws_config = {}
|
29
|
+
|
30
|
+
text.each_line do |line|
|
31
|
+
if line =~ profile_matcher
|
32
|
+
current_profile = line.match(profile_matcher)[2]
|
33
|
+
aws_config[current_profile] = {} unless aws_config.has_key?(current_profile)
|
34
|
+
end
|
31
35
|
|
32
|
-
|
36
|
+
if line =~ option_matcher && !current_profile.nil?
|
37
|
+
results = line.match(option_matcher)
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
39
|
+
# Normalize the option name so it can be used with the AWS SDK
|
40
|
+
if results[1] =~ /^\S*aws_/
|
41
|
+
option = results[1].strip.gsub('aws_', '').to_sym
|
42
|
+
else
|
43
|
+
option = results[1].strip.to_sym
|
37
44
|
end
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
else
|
46
|
-
option = results[1].to_sym
|
47
|
-
end
|
48
|
-
|
49
|
-
value = results[2]
|
50
|
-
aws_config[current_profile].merge!({ option => value })
|
51
|
-
end
|
46
|
+
value = results[2].strip
|
47
|
+
aws_config[current_profile].merge!({ option => value })
|
48
|
+
end
|
49
|
+
end
|
50
|
+
aws_config
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
53
|
+
def self.config_parser
|
54
|
+
if ENV['AWS_CONFIG_FILE']
|
55
|
+
parse_profile_text(File.read(ENV['AWS_CONFIG_FILE']))
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
@@ -67,11 +68,8 @@ module Rivet
|
|
67
68
|
end
|
68
69
|
accum
|
69
70
|
end
|
70
|
-
|
71
71
|
AWS.config(aws_creds) if aws_creds
|
72
|
-
|
73
72
|
end
|
74
73
|
end
|
75
|
-
|
76
74
|
end
|
77
75
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Rivet
|
4
|
+
BASE_AWS_ATTRIBUTES = [
|
5
|
+
:iam_instance_profile,
|
6
|
+
:block_device_mappings,
|
7
|
+
:image_id,
|
8
|
+
:key_name,
|
9
|
+
:security_groups,
|
10
|
+
:instance_type,
|
11
|
+
:kernel_id,
|
12
|
+
:ramdisk_id,
|
13
|
+
:associate_public_ip_address
|
14
|
+
].each { |a| attr_reader a }
|
15
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Rivet
|
4
|
+
class BaseConfig < OpenState
|
5
|
+
attr_reader :name
|
6
|
+
attr_accessor :bootstrap
|
7
|
+
|
8
|
+
def self.from_file(dsl_file, load_path='.')
|
9
|
+
name = File.basename(dsl_file, '.rb')
|
10
|
+
data = Proc.new { eval(File.read(dsl_file)) }
|
11
|
+
new(name, load_path, &data)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(name, load_path='.', &block)
|
15
|
+
super()
|
16
|
+
@name = name
|
17
|
+
@path = load_path
|
18
|
+
@bootstrap = OpenState.new
|
19
|
+
instance_eval(&block) if block
|
20
|
+
end
|
21
|
+
|
22
|
+
def path(*args)
|
23
|
+
if args.size < 1
|
24
|
+
@path
|
25
|
+
else
|
26
|
+
File.join(@path, *args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def normalize_security_groups
|
31
|
+
security_groups.sort
|
32
|
+
end
|
33
|
+
|
34
|
+
protected
|
35
|
+
|
36
|
+
def import(import_path)
|
37
|
+
lambda { eval(File.read(import_path)) }.call
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -2,37 +2,38 @@
|
|
2
2
|
|
3
3
|
module Rivet
|
4
4
|
class Client
|
5
|
-
def run(options)
|
5
|
+
def run(client_type,options)
|
6
6
|
AwsUtils.set_aws_credentials options.profile
|
7
7
|
Rivet::Log.level options.log_level
|
8
8
|
|
9
|
-
Rivet::Log.info "Using
|
9
|
+
Rivet::Log.info "Using #{client_type} config path #{options.config_path}"
|
10
10
|
|
11
11
|
unless Dir.exists?(options.config_path)
|
12
|
-
Rivet::Utils.die
|
12
|
+
Rivet::Utils.die "The #{client_type} config path does not exist"
|
13
13
|
end
|
14
14
|
|
15
|
-
# Get config object for autoscaling group
|
16
15
|
config = Rivet::Utils.get_config(
|
17
|
-
|
16
|
+
client_type,
|
17
|
+
options.name,
|
18
18
|
options.config_path)
|
19
19
|
|
20
20
|
unless config
|
21
21
|
Rivet::Utils.list_groups(options.config_path)
|
22
|
-
Rivet::Utils.die "The #{options.
|
22
|
+
Rivet::Utils.die "The #{options.name} #{client_type} definition doesn't exist"
|
23
23
|
end
|
24
24
|
|
25
25
|
config.validate
|
26
26
|
|
27
27
|
config = ConfigProxy.new(config)
|
28
28
|
|
29
|
-
Rivet::Log.info "
|
29
|
+
Rivet::Log.info "#{options.name} #{client_type} definition"
|
30
30
|
|
31
|
-
|
32
|
-
|
31
|
+
asset = Rivet.const_get(client_type.capitalize).new(config)
|
32
|
+
asset.display
|
33
33
|
|
34
34
|
if options.sync
|
35
|
-
|
35
|
+
Rivet::Log.debug "syncing asset #{options.name}"
|
36
|
+
asset.sync
|
36
37
|
else
|
37
38
|
Rivet::Log.info 'use the -s [--sync] flag to sync changes'
|
38
39
|
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module Rivet
|
4
|
+
class Ec2
|
5
|
+
OPTIONS = [
|
6
|
+
:associate_public_ip_address,
|
7
|
+
:availability_zone,
|
8
|
+
:block_device_mappings,
|
9
|
+
:count,
|
10
|
+
:dedicated_tenancy,
|
11
|
+
:disable_api_termination,
|
12
|
+
:ebs_optimized,
|
13
|
+
:elastic_ips,
|
14
|
+
:iam_instance_profile,
|
15
|
+
:image_id,
|
16
|
+
:instance_initiated_shutdown_behavior,
|
17
|
+
:instance_type,
|
18
|
+
:kernel_id,
|
19
|
+
:key_name,
|
20
|
+
:key_pair,
|
21
|
+
:monitoring_enabled,
|
22
|
+
:network_interfaces,
|
23
|
+
:placement_group,
|
24
|
+
:private_ip_address,
|
25
|
+
:ramdisk_id,
|
26
|
+
:security_group_ids,
|
27
|
+
:security_groups,
|
28
|
+
:subnet,
|
29
|
+
:tags,
|
30
|
+
:user_data
|
31
|
+
].each { |a| attr_reader a }
|
32
|
+
|
33
|
+
REQUIRED_OPTIONS = [
|
34
|
+
:image_id
|
35
|
+
]
|
36
|
+
|
37
|
+
attr_reader :name
|
38
|
+
|
39
|
+
def initialize(config)
|
40
|
+
@ec2 = AWS::EC2.new
|
41
|
+
@name = config.name
|
42
|
+
@user_data = Bootstrap.new(config).user_data
|
43
|
+
|
44
|
+
OPTIONS.each do |o|
|
45
|
+
if config.respond_to?(o)
|
46
|
+
instance_variable_set("@#{o}", config.send(o))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def display(level = 'info')
|
52
|
+
options.each_pair do |attr, values|
|
53
|
+
Rivet::Log.write(level, " #{attr}: #{values}")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def options
|
58
|
+
options = {}
|
59
|
+
|
60
|
+
OPTIONS.each do |field|
|
61
|
+
local_value = self.send(field)
|
62
|
+
options[field] = local_value unless local_value.nil?
|
63
|
+
end
|
64
|
+
|
65
|
+
REQUIRED_OPTIONS.each do |field|
|
66
|
+
unless options.has_key? field
|
67
|
+
options[field] = self.send(field)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
options
|
71
|
+
end
|
72
|
+
|
73
|
+
def sync
|
74
|
+
# The AWS ruby SDK forces you to apply tags AFTER creation
|
75
|
+
# This option must be removed so the create call doesn't blow up.
|
76
|
+
server_options = options
|
77
|
+
tags_to_add = server_options.delete :tags
|
78
|
+
eips_to_add = server_options.delete :elastic_ips
|
79
|
+
enis_to_add = server_options.delete :network_interfaces
|
80
|
+
instances = @ec2.instances.create server_options
|
81
|
+
|
82
|
+
# Since create returns either an instance object or an array let us
|
83
|
+
# just go ahead and make that more sane
|
84
|
+
instances = [instances] unless instances.respond_to? :each
|
85
|
+
|
86
|
+
add_tags(instances,tags_to_add)
|
87
|
+
ready_instances = wait_until_running instances
|
88
|
+
add_eips(ready_instances,eips_to_add) if eips_to_add
|
89
|
+
add_network_interfaces(ready_instances,enis_to_add) if enis_to_add
|
90
|
+
end
|
91
|
+
|
92
|
+
protected
|
93
|
+
|
94
|
+
def add_network_interfaces(instances,interfaces)
|
95
|
+
index_to_instances = 0
|
96
|
+
interfaces.each do |i|
|
97
|
+
unless index_to_instances > instances.size
|
98
|
+
attach_interface(instances[index_to_instances],i)
|
99
|
+
index_to_instances + 1
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def attach_interface(instance,interface)
|
105
|
+
eni = AWS::EC2::NetworkInterface.new(interface)
|
106
|
+
if eni.exists?
|
107
|
+
Rivet::Log.info "Attaching #{eni.id} to #{instance.id}"
|
108
|
+
instance.attach_network_interface eni
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def add_eips(instances,eips_to_add)
|
113
|
+
index_to_instances = 0
|
114
|
+
eips_to_add.each do |ip|
|
115
|
+
unless index_to_instances > instances.size
|
116
|
+
attach_ip(instances[index_to_instances],ip)
|
117
|
+
index_to_instances + 1
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def attach_ip(instance,ip)
|
123
|
+
eip = AWS::EC2::ElasticIp.new(ip)
|
124
|
+
if eip.exists?
|
125
|
+
Rivet::Log.info "Attaching #{eip} to #{instance.id}"
|
126
|
+
instance.associate_elastic_ip eip
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def tag_instance(instance,tags_to_add)
|
131
|
+
tags_to_add.each do |t|
|
132
|
+
@ec2.tags.create(instance, t[:key].to_s, :value => t[:value])
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def add_tags(instances,tags_to_add)
|
137
|
+
instances.each do |i|
|
138
|
+
if tags_to_add
|
139
|
+
tag_instance(i,tags_to_add)
|
140
|
+
else
|
141
|
+
Rivet::Log.info "No tags in config, defaulting to Name: #{@name}"
|
142
|
+
tag_instance(i,[{ :key => 'Name', :value => @name }])
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def wait_until_running(instances)
|
148
|
+
Rivet::Log.info "Waiting for instance to start. This could take a while..."
|
149
|
+
finished = []
|
150
|
+
until instances.size <= 0
|
151
|
+
instances.reject! do |i|
|
152
|
+
unless i.status == :pending
|
153
|
+
Rivet::Log.info "#{i.id} is in #{i.status} state."
|
154
|
+
finished << i
|
155
|
+
true
|
156
|
+
end
|
157
|
+
end
|
158
|
+
sleep 1
|
159
|
+
end
|
160
|
+
finished
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
#encoding: UTF-8
|
2
|
+
|
3
|
+
module Rivet
|
4
|
+
class Ec2Config < BaseConfig
|
5
|
+
|
6
|
+
def initialize(name, load_path='.', &block)
|
7
|
+
@required_fields = {
|
8
|
+
:image_id => nil,
|
9
|
+
:region => 'us-east-1',
|
10
|
+
:availability_zone => 'a'
|
11
|
+
}
|
12
|
+
super(name,load_path, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def normalize_availability_zone
|
16
|
+
region + availability_zone
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/rivet/utils.rb
CHANGED
@@ -4,7 +4,7 @@ module Rivet
|
|
4
4
|
module Utils
|
5
5
|
def self.die(level = 'fatal', message)
|
6
6
|
Rivet::Log.write(level, message)
|
7
|
-
exit
|
7
|
+
exit 1
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.list_groups(directory)
|
@@ -15,9 +15,10 @@ module Rivet
|
|
15
15
|
config_file_names.each { |n| Rivet::Log.info n }
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.get_config(name, directory)
|
18
|
+
def self.get_config(client_type, name, directory)
|
19
19
|
dsl_file = File.join(directory, "#{name}.rb")
|
20
|
-
Rivet
|
20
|
+
klass = Rivet.const_get("#{client_type.capitalize}Config")
|
21
|
+
klass.from_file(dsl_file, directory) if File.exists?(dsl_file)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
data/lib/rivet/version.rb
CHANGED
data/lib/rivet.rb
CHANGED
@@ -9,16 +9,21 @@ require 'logger'
|
|
9
9
|
require 'optparse'
|
10
10
|
require 'ostruct'
|
11
11
|
require 'singleton'
|
12
|
+
require 'diff/lcs'
|
12
13
|
|
13
|
-
require_relative 'rivet/
|
14
|
-
require_relative 'rivet/
|
15
|
-
require_relative 'rivet/
|
16
|
-
require_relative 'rivet/
|
17
|
-
require_relative 'rivet/
|
18
|
-
require_relative 'rivet/
|
19
|
-
require_relative 'rivet/
|
20
|
-
require_relative 'rivet/
|
21
|
-
require_relative 'rivet/
|
22
|
-
require_relative 'rivet/
|
23
|
-
require_relative 'rivet/
|
14
|
+
require_relative 'rivet/common/base_aws_attributes'
|
15
|
+
require_relative 'rivet/as/autoscale'
|
16
|
+
require_relative 'rivet/as/aws_autoscale_wrapper'
|
17
|
+
require_relative 'rivet/common/client'
|
18
|
+
require_relative 'rivet/common/aws_utils'
|
19
|
+
require_relative 'rivet/common/bootstrap'
|
20
|
+
require_relative 'rivet/common/open_state'
|
21
|
+
require_relative 'rivet/common/base_config'
|
22
|
+
require_relative 'rivet/as/autoscale_config'
|
23
|
+
require_relative 'rivet/common/config_proxy'
|
24
|
+
require_relative 'rivet/as/launch_config'
|
25
|
+
require_relative 'rivet/common/logger'
|
26
|
+
require_relative 'rivet/ec2/ec2_config'
|
27
|
+
require_relative 'rivet/ec2/ec2'
|
24
28
|
require_relative 'rivet/utils'
|
29
|
+
require_relative 'rivet/version'
|
data/rivet.gemspec
CHANGED
@@ -21,10 +21,11 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.test_files = spec.files.grep(%r{^spec/})
|
22
22
|
|
23
23
|
spec.executables = %w(rivet)
|
24
|
-
spec.require_paths = [
|
24
|
+
spec.require_paths = ['lib']
|
25
25
|
|
26
|
-
spec.add_dependency
|
27
|
-
spec.
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
26
|
+
spec.add_dependency 'aws-sdk', '>= 1.11.1'
|
27
|
+
spec.add_dependency 'diff-lcs', '>= 1.2.5'
|
28
|
+
spec.add_development_dependency 'pry', '~> 0.9.12'
|
29
|
+
spec.add_development_dependency 'rake', '>= 10.1.0'
|
30
|
+
spec.add_development_dependency 'rspec', '~> 2.14.1'
|
30
31
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative '../spec_setup'
|
3
|
+
require_relative '../shared_examples/a_config'
|
4
|
+
|
5
|
+
include SpecHelpers
|
6
|
+
|
7
|
+
describe 'rivet autoscale config' do
|
8
|
+
let(:dsl_values) { ASG_DSL_VALUES }
|
9
|
+
let(:default_config) { Rivet::AutoscaleConfig.new('default_unit_test_config') }
|
10
|
+
let(:config) { Rivet::AutoscaleConfig.new('unit_test_config') { eval(ASG_CONFIG_CONTENT) } }
|
11
|
+
let(:config_from_file) { Rivet::AutoscaleConfig.from_file(File.join('.', 'unit_test.rb')) }
|
12
|
+
let(:config_content) { ASG_CONFIG_CONTENT }
|
13
|
+
|
14
|
+
it_behaves_like "a config"
|
15
|
+
|
16
|
+
context 'without DSL content' do
|
17
|
+
describe '#normalize_availability_zones' do
|
18
|
+
before do
|
19
|
+
default_config.region 'us-west-2'
|
20
|
+
default_config.availability_zones %w(c a b)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return a sorted array of zones with the region prepended' do
|
24
|
+
default_config.normalize_availability_zones.should == %w(us-west-2a us-west-2b us-west-2c)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#normalize_load_balancers' do
|
29
|
+
before do
|
30
|
+
default_config.load_balancers %w(balancer2 balancer1)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should return a sorted array of load balancers' do
|
34
|
+
default_config.normalize_load_balancers.should == %w(balancer1 balancer2)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#normalize_subnets' do
|
39
|
+
before do
|
40
|
+
default_config.subnets %w(192.168.1.2 192.168.1.3 192.168.1.1)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should return a sorted array of subnets' do
|
44
|
+
default_config.normalize_subnets.should == %w(192.168.1.1 192.168.1.2 192.168.1.3)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#normalize_tags' do
|
49
|
+
before do
|
50
|
+
default_config.tags [
|
51
|
+
{ key: 'Other', value: 'sasquatch', propagate_at_launch: false },
|
52
|
+
{ key: 'Name', value: 'unit test' }
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should return a normalized array of hashes' do
|
57
|
+
expected_result = [
|
58
|
+
{ propagate_at_launch: true, key: 'Name', value: 'unit test' },
|
59
|
+
{ propagate_at_launch: false, key: 'Other', value: 'sasquatch' }
|
60
|
+
]
|
61
|
+
default_config.normalize_tags.should == expected_result
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: UTf-8
|
2
|
+
require_relative './spec_setup'
|
3
|
+
|
4
|
+
include SpecHelpers
|
5
|
+
|
6
|
+
describe 'rivet awsutils' do
|
7
|
+
describe 'parse_profile_text' do
|
8
|
+
let(:profile_hash) do
|
9
|
+
{
|
10
|
+
'unit_test_profile1' => {
|
11
|
+
'option1' => 'unit_test_option1',
|
12
|
+
'option2' => 'unit_test_option2'
|
13
|
+
},
|
14
|
+
'unit_test_profile2' => {
|
15
|
+
'option1 ' => 'unit_test_option1',
|
16
|
+
'option2' => 'unit_test_option2 '
|
17
|
+
}
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
let(:profile_text) do
|
22
|
+
p = String.new
|
23
|
+
profile_hash.each_pair do |profile,options|
|
24
|
+
p << "[profile #{profile}]\n"
|
25
|
+
options.each_pair { |name,value| p << "#{name.chomp} = #{value.chomp}\n" }
|
26
|
+
end
|
27
|
+
p
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should contain the profile as top level keys' do
|
31
|
+
result = Rivet::AwsUtils.parse_profile_text(profile_text)
|
32
|
+
profile_hash.each_pair { |profile,_| result.should have_key profile }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should set all options properly inside the profile hash' do
|
36
|
+
result = Rivet::AwsUtils.parse_profile_text(profile_text)
|
37
|
+
profile_hash.each_pair do |profile,options|
|
38
|
+
options.each_pair do |name, value|
|
39
|
+
result[profile][name.strip.to_sym].should == value.strip
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative './spec_setup'
|
3
|
+
require_relative './shared_examples/a_config'
|
4
|
+
|
5
|
+
include SpecHelpers
|
6
|
+
|
7
|
+
describe 'rivet base config' do
|
8
|
+
let(:dsl_values) { COMMON_DSL_VALUES }
|
9
|
+
let(:default_config) { Rivet::BaseConfig.new('default_unit_test_config') }
|
10
|
+
let(:config) { Rivet::BaseConfig.new('unit_test_config') { eval(ASG_CONFIG_CONTENT) } }
|
11
|
+
let(:config_from_file) { Rivet::BaseConfig.from_file(File.join('.', 'unit_test.rb')) }
|
12
|
+
let(:config_content) { ASG_CONFIG_CONTENT }
|
13
|
+
|
14
|
+
it_behaves_like "a config"
|
15
|
+
|
16
|
+
context 'without DSL content' do
|
17
|
+
describe '#new' do
|
18
|
+
it 'returns a Rivet::BaseConfig object' do
|
19
|
+
default_config.should be_an_instance_of Rivet::BaseConfig
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'with DSL content' do
|
25
|
+
describe '#new' do
|
26
|
+
it 'returns a Rivet::BaseConfig object' do
|
27
|
+
config.should be_an_instance_of Rivet::BaseConfig
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/bootstrap_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative './spec_setup'
|
|
4
4
|
include SpecHelpers
|
5
5
|
|
6
6
|
describe 'rivet bootstrap' do
|
7
|
-
let(:config) { generate_config_mock(double('config_mock'),
|
7
|
+
let(:config) { generate_config_mock(double('config_mock'), ASG_DSL_VALUES) }
|
8
8
|
let(:bootstrap) { Rivet::Bootstrap.new(config) }
|
9
9
|
let(:blank_config) do
|
10
10
|
blank_config_mock = double('blank_config_mock')
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative '../spec_setup'
|
3
|
+
require_relative '../shared_examples/a_config'
|
4
|
+
|
5
|
+
include SpecHelpers
|
6
|
+
|
7
|
+
describe 'rivet ec2 config' do
|
8
|
+
let(:dsl_values) { EC2_DSL_VALUES }
|
9
|
+
let(:default_config) { Rivet::Ec2Config.new('default_unit_test_config') }
|
10
|
+
let(:config) { Rivet::Ec2Config.new('unit_test_config') { eval(EC2_CONFIG_CONTENT) } }
|
11
|
+
let(:config_from_file) { Rivet::Ec2Config.from_file(File.join('.', 'unit_test.rb')) }
|
12
|
+
let(:config_content) { EC2_CONFIG_CONTENT }
|
13
|
+
|
14
|
+
it_behaves_like "a config"
|
15
|
+
|
16
|
+
context 'without DSL content' do
|
17
|
+
describe '#normalize_availability_zone' do
|
18
|
+
before do
|
19
|
+
default_config.region 'us-west-2'
|
20
|
+
default_config.availability_zone 'a'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return a valid availability zone string' do
|
24
|
+
default_config.normalize_availability_zone.should == 'us-west-2a'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
data/spec/launch_config_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative './spec_setup'
|
|
4
4
|
include SpecHelpers
|
5
5
|
|
6
6
|
describe 'rivet launch config' do
|
7
|
-
let(:config) { generate_config_mock(double('config_mock'),
|
7
|
+
let(:config) { generate_config_mock(double('config_mock'), ASG_DSL_VALUES) }
|
8
8
|
let(:launch_config) { Rivet::LaunchConfig.new(config) }
|
9
9
|
|
10
10
|
context 'with a sane config' do
|