bosh-deployer 0.0.6 → 0.0.7
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/Gemfile.lock +43 -26
- data/bosh-deployer.gemspec +1 -0
- data/lib/bosh/cli/commands/deployer.rb +2 -2
- data/lib/bosh-deployer/bosh_settings.rb +78 -0
- data/lib/bosh-deployer/bosh_stub.rb +6 -105
- data/lib/bosh-deployer/cf_stub.rb +16 -0
- data/lib/bosh-deployer/cli/commands/generate_stub.rb +6 -1
- data/lib/bosh-deployer/microbosh_settings.rb +22 -0
- data/lib/bosh-deployer/stub.rb +47 -0
- data/lib/bosh-deployer/version.rb +1 -1
- data/lib/bosh-deployer.rb +2 -0
- data/spec/bosh_stub_spec.rb +9 -66
- data/spec/cf_stub_spec.rb +39 -0
- data/spec/fixtures/stubs/cloudfoundry.yml +274 -0
- data/spec/microbosh_settings_spec.rb +23 -0
- data/spec/stub_spec.rb +56 -0
- data/spec/support/helper.rb +24 -0
- data/stubs/cloudfoundry.yml.erb +274 -0
- metadata +33 -5
- data/lib/bosh/cli/commands/bosh_deployer.rb +0 -23
- data/spec/fixtures/stubs/cloudfoundry.stub.yml +0 -145
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bosh-deployer (0.0.
|
4
|
+
bosh-deployer (0.0.7)
|
5
5
|
cancun
|
6
6
|
readwritesettings
|
7
|
+
recursive-open-struct
|
7
8
|
redcard
|
8
9
|
thor (~> 0.18)
|
9
10
|
|
@@ -13,19 +14,19 @@ GEM
|
|
13
14
|
aws-sdk (1.44.0)
|
14
15
|
json (~> 1.4)
|
15
16
|
nokogiri (>= 1.4.4)
|
16
|
-
blobstore_client (1.
|
17
|
+
blobstore_client (1.2719.0)
|
17
18
|
aws-sdk (= 1.44.0)
|
18
|
-
bosh_common (~> 1.
|
19
|
-
fog (~> 1.
|
19
|
+
bosh_common (~> 1.2719.0)
|
20
|
+
fog (~> 1.23.0)
|
20
21
|
httpclient (= 2.4.0)
|
21
22
|
multi_json (~> 1.1)
|
22
23
|
ruby-atmos-pure (~> 1.0.5)
|
23
|
-
bosh-template (1.
|
24
|
+
bosh-template (1.2719.0)
|
24
25
|
semi_semantic (~> 1.1.0)
|
25
|
-
bosh_cli (1.
|
26
|
-
blobstore_client (~> 1.
|
27
|
-
bosh-template (~> 1.
|
28
|
-
bosh_common (~> 1.
|
26
|
+
bosh_cli (1.2719.0)
|
27
|
+
blobstore_client (~> 1.2719.0)
|
28
|
+
bosh-template (~> 1.2719.0)
|
29
|
+
bosh_common (~> 1.2719.0)
|
29
30
|
highline (~> 1.6.2)
|
30
31
|
httpclient (= 2.4.0)
|
31
32
|
json_pure (~> 1.7)
|
@@ -36,7 +37,7 @@ GEM
|
|
36
37
|
netaddr (~> 1.5.0)
|
37
38
|
progressbar (~> 0.9.0)
|
38
39
|
terminal-table (~> 1.4.3)
|
39
|
-
bosh_common (1.
|
40
|
+
bosh_common (1.2719.0)
|
40
41
|
semi_semantic (~> 1.1.0)
|
41
42
|
builder (3.2.2)
|
42
43
|
cancun (0.2.2)
|
@@ -44,23 +45,38 @@ GEM
|
|
44
45
|
highline-color
|
45
46
|
sourcify
|
46
47
|
diff-lcs (1.2.5)
|
47
|
-
excon (0.
|
48
|
-
file-tail (1.0
|
49
|
-
tins (~> 0
|
50
|
-
fog (1.
|
48
|
+
excon (0.39.6)
|
49
|
+
file-tail (1.1.0)
|
50
|
+
tins (~> 1.0)
|
51
|
+
fog (1.23.0)
|
52
|
+
fog-brightbox
|
53
|
+
fog-core (~> 1.23)
|
54
|
+
fog-json
|
55
|
+
fog-softlayer
|
56
|
+
ipaddress (~> 0.5)
|
57
|
+
nokogiri (~> 1.5, >= 1.5.11)
|
58
|
+
fog-brightbox (0.5.1)
|
59
|
+
fog-core (~> 1.22)
|
60
|
+
fog-json
|
61
|
+
inflecto
|
62
|
+
fog-core (1.24.0)
|
51
63
|
builder
|
52
|
-
excon (~> 0.
|
53
|
-
formatador (~> 0.2
|
64
|
+
excon (~> 0.38)
|
65
|
+
formatador (~> 0.2)
|
54
66
|
mime-types
|
55
|
-
multi_json (~> 1.0)
|
56
67
|
net-scp (~> 1.1)
|
57
68
|
net-ssh (>= 2.1.3)
|
58
|
-
|
59
|
-
|
69
|
+
fog-json (1.0.0)
|
70
|
+
multi_json (~> 1.0)
|
71
|
+
fog-softlayer (0.3.18)
|
72
|
+
fog-core
|
73
|
+
fog-json
|
60
74
|
formatador (0.2.5)
|
61
75
|
highline (1.6.21)
|
62
|
-
highline-color (0.0.
|
76
|
+
highline-color (0.0.5)
|
63
77
|
httpclient (2.4.0)
|
78
|
+
inflecto (0.0.2)
|
79
|
+
ipaddress (0.8.0)
|
64
80
|
json (1.8.1)
|
65
81
|
json_pure (1.8.1)
|
66
82
|
log4r (1.1.10)
|
@@ -79,6 +95,7 @@ GEM
|
|
79
95
|
progressbar (0.9.2)
|
80
96
|
rake (10.3.2)
|
81
97
|
readwritesettings (3.0.1)
|
98
|
+
recursive-open-struct (0.5.0)
|
82
99
|
redcard (1.1.0)
|
83
100
|
rspec (3.1.0)
|
84
101
|
rspec-core (~> 3.1.0)
|
@@ -86,20 +103,20 @@ GEM
|
|
86
103
|
rspec-mocks (~> 3.1.0)
|
87
104
|
rspec-core (3.1.4)
|
88
105
|
rspec-support (~> 3.1.0)
|
89
|
-
rspec-expectations (3.1.
|
106
|
+
rspec-expectations (3.1.2)
|
90
107
|
diff-lcs (>= 1.2.0, < 2.0)
|
91
108
|
rspec-support (~> 3.1.0)
|
92
|
-
rspec-mocks (3.1.
|
109
|
+
rspec-mocks (3.1.2)
|
93
110
|
rspec-support (~> 3.1.0)
|
94
|
-
rspec-support (3.1.
|
111
|
+
rspec-support (3.1.1)
|
95
112
|
ruby-atmos-pure (1.0.5)
|
96
113
|
log4r (>= 1.1.9)
|
97
114
|
ruby-hmac (>= 0.4.0)
|
98
115
|
ruby-hmac (0.4.0)
|
99
|
-
ruby2ruby (2.1.
|
116
|
+
ruby2ruby (2.1.3)
|
100
117
|
ruby_parser (~> 3.1)
|
101
118
|
sexp_processor (~> 4.0)
|
102
|
-
ruby_parser (3.6.
|
119
|
+
ruby_parser (3.6.3)
|
103
120
|
sexp_processor (~> 4.1)
|
104
121
|
semi_semantic (1.1.0)
|
105
122
|
sexp_processor (4.4.4)
|
@@ -110,7 +127,7 @@ GEM
|
|
110
127
|
sexp_processor (>= 3.0.5)
|
111
128
|
terminal-table (1.4.5)
|
112
129
|
thor (0.19.1)
|
113
|
-
tins (
|
130
|
+
tins (1.3.3)
|
114
131
|
|
115
132
|
PLATFORMS
|
116
133
|
ruby
|
data/bosh-deployer.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |gem|
|
|
29
29
|
gem.add_dependency "redcard"
|
30
30
|
gem.add_dependency 'readwritesettings'
|
31
31
|
gem.add_dependency "cancun"
|
32
|
+
gem.add_dependency "recursive-open-struct"
|
32
33
|
gem.add_development_dependency "rake"
|
33
34
|
gem.add_development_dependency "rspec"
|
34
35
|
end
|
@@ -20,8 +20,8 @@ module Bosh::Cli::Command
|
|
20
20
|
Bosh::Deployer::Cli::Commands::ProvisionStemcells.new.perform
|
21
21
|
end
|
22
22
|
|
23
|
-
usage "generate
|
24
|
-
desc "Creates stub file"
|
23
|
+
usage "deployer generate stub"
|
24
|
+
desc "Creates stub file to be compile with Spiff."
|
25
25
|
def generate_stub(name, path=nil)
|
26
26
|
require "bosh-deployer/cli/commands/generate_stub"
|
27
27
|
Bosh::Deployer::Cli::Commands::GenerateStub.new(name,path).perform
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'bosh-deployer/microbosh_settings'
|
2
|
+
|
3
|
+
module Bosh::Deployer::BoshSettings
|
4
|
+
def microbosh
|
5
|
+
@microbosh ||= Bosh::Deployer::MicroboshSettings.load
|
6
|
+
end
|
7
|
+
|
8
|
+
def default_key_name
|
9
|
+
@default_key_name ||= ask('Key name:') do |q|
|
10
|
+
q.default = 'firstbosh'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def private_key
|
15
|
+
@private_key ||= ask('Private key:') do |q|
|
16
|
+
q.default = '~/.microbosh/ssh/firstbosh.pem'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def static_ip_from
|
21
|
+
@static_ip_from ||= ask 'Intial available static ip for deployment:'
|
22
|
+
end
|
23
|
+
|
24
|
+
def static_ip_to
|
25
|
+
@static_ip_to ||= ask 'Last available static ip for deployment:'
|
26
|
+
end
|
27
|
+
|
28
|
+
def openstack_auth_url
|
29
|
+
@openstack_auth_url ||= ask('Openstack auth url:') do |q|
|
30
|
+
q.default = microbosh.provider.credentials.openstack_auth_url.gsub('/tokens', '') if microbosh
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def openstack_username
|
35
|
+
@openstack_username ||= ask('Openstack username:') do |q|
|
36
|
+
q.default = microbosh.provider.credentials.openstack_username if microbosh
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def openstack_api_key
|
41
|
+
@openstack_api_key ||= ask('Openstack api key:') do |q|
|
42
|
+
q.default = microbosh.provider.credentials.openstack_api_key if microbosh
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def openstack_tenant
|
47
|
+
@openstack_tenant ||= ask('Openstack tenant:') do |q|
|
48
|
+
q.default = microbosh.provider.credentials.openstack_tenant if microbosh
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def recursor_ip
|
53
|
+
@recursor_ip ||= ask('Recursor ip or host:') do |q|
|
54
|
+
q.default = microbosh.address.ip if microbosh
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def subnet_id
|
59
|
+
@subnet_id ||= ask('Subnet ID where it will be deployed:') do |q|
|
60
|
+
q.default = microbosh.address.subnet_id if microbosh
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def gateway
|
65
|
+
@gateway ||= ask('Gateway IP:') do |q|
|
66
|
+
#UGLY REPLACE ME WITH A REGEX
|
67
|
+
q.default = (static_ip_from.split('.')[0..-2] + ['1']).join('.')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def range
|
72
|
+
@range ||= ask('Ip Range where it will be deployed:') do |q|
|
73
|
+
#UGLY REPLACE ME WITH A REGEX
|
74
|
+
q.default = (static_ip_from.split('.')[0..-2] + ['0']).join('.') + '/24'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -1,111 +1,12 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'cancun/highline'
|
4
|
-
require 'readwritesettings'
|
1
|
+
require 'bosh-deployer/stub'
|
2
|
+
require 'bosh-deployer/bosh_settings'
|
5
3
|
|
6
4
|
module Bosh; module Deployer; end ;end
|
7
5
|
|
8
|
-
class Bosh::Deployer::BoshStub
|
9
|
-
include ::
|
10
|
-
attr_reader :filename
|
6
|
+
class Bosh::Deployer::BoshStub < Bosh::Deployer::Stub
|
7
|
+
include Bosh::Deployer::BoshSettings
|
11
8
|
|
12
|
-
def
|
13
|
-
|
14
|
-
@filename = "#{path}/bosh.yml"
|
15
|
-
end
|
16
|
-
|
17
|
-
def generate
|
18
|
-
if File.exists?(filename) and !agree "#{filename} already exists, do you want to overwrite it?"
|
19
|
-
say 'Stub generation cancelled!'
|
20
|
-
return
|
21
|
-
end
|
22
|
-
say_bold 'Provide the following information for your bosh configuration:'
|
23
|
-
stub = template.result(binding)
|
24
|
-
say "Saving stub at #{filename}"
|
25
|
-
File.open(filename, 'w') { |f| f.write(stub) }
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
def static_ip_from
|
30
|
-
@static_ip_from ||= ask 'Intial available static ip for deploying bosh:'
|
31
|
-
end
|
32
|
-
|
33
|
-
def static_ip_to
|
34
|
-
@static_ip_to ||= ask 'Last available static ip for deploying bosh:'
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
def openstack_auth_url
|
39
|
-
@openstack_auth_url ||= ask('Openstack auth url:') do |q|
|
40
|
-
q.default = microbosh.provider.credentials.openstack_auth_url.gsub('/tokens', '') if microbosh
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def openstack_username
|
45
|
-
@openstack_username ||= ask('Openstack username:') do |q|
|
46
|
-
q.default = microbosh.provider.credentials.openstack_username if microbosh
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def openstack_api_key
|
51
|
-
@openstack_api_key ||= ask('Openstack api key:') do |q|
|
52
|
-
q.default = microbosh.provider.credentials.openstack_api_key if microbosh
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def openstack_tenant
|
57
|
-
@openstack_tenant ||= ask('Openstack tenant:') do |q|
|
58
|
-
q.default = microbosh.provider.credentials.openstack_tenant if microbosh
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def recursor_ip
|
63
|
-
@recursor_ip ||= ask('Recursor ip or host:') do |q|
|
64
|
-
q.default = microbosh.address.ip if microbosh
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def subnet_id
|
69
|
-
@subnet_id ||= ask('Subnet ID where bosh will be deployed:') do |q|
|
70
|
-
q.default = microbosh.address.subnet_id if microbosh
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def gateway
|
75
|
-
@gateway ||= ask('Gateway IP for bosh:') do |q|
|
76
|
-
#UGLY REPLACE ME WITH A REGEX
|
77
|
-
q.default = (static_ip_from.split('.')[0..-2] + ['1']).join('.')
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def range
|
82
|
-
@range ||= ask('Gateway IP for bosh:') do |q|
|
83
|
-
#UGLY REPLACE ME WITH A REGEX
|
84
|
-
q.default = (static_ip_from.split('.')[0..-2] + ['0']).join('.') + '/24'
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
def default_key_name
|
89
|
-
@default_key_name ||= ask('Key name:') do |q|
|
90
|
-
q.default = 'firstbosh'
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def private_key
|
95
|
-
@private_key ||= ask('Private key:') do |q|
|
96
|
-
q.default = '~/.microbosh/ssh/firstbosh.pem'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
protected
|
101
|
-
|
102
|
-
def template
|
103
|
-
@template ||= ERB.new( File.read(File.expand_path('../../../stubs/bosh.yml.erb', __FILE__)))
|
104
|
-
end
|
105
|
-
|
106
|
-
def microbosh
|
107
|
-
if File.exists?('~/.bootstrap/settings.yml')
|
108
|
-
@microbosh ||= ReadWriteSettings.new('~/.bootstrap/settings.yml')
|
109
|
-
end
|
9
|
+
def name
|
10
|
+
'bosh'
|
110
11
|
end
|
111
12
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bosh-deployer/stub'
|
2
|
+
require 'bosh-deployer/bosh_settings'
|
3
|
+
|
4
|
+
module Bosh; module Deployer; end ;end
|
5
|
+
|
6
|
+
class Bosh::Deployer::CFStub < Bosh::Deployer::Stub
|
7
|
+
include Bosh::Deployer::BoshSettings
|
8
|
+
|
9
|
+
def name
|
10
|
+
'cloudfoundry'
|
11
|
+
end
|
12
|
+
|
13
|
+
def floating_static_ip
|
14
|
+
@floating_static_ip ||= ask('Available floating ip for cf:')
|
15
|
+
end
|
16
|
+
end
|
@@ -15,6 +15,11 @@ class Bosh::Deployer::Cli::Commands::GenerateStub
|
|
15
15
|
|
16
16
|
protected
|
17
17
|
def stub
|
18
|
-
|
18
|
+
case name
|
19
|
+
when 'bosh'
|
20
|
+
Bosh::Deployer::BoshStub.new(path)
|
21
|
+
when 'cf'
|
22
|
+
Bosh::Deployer::CFStub.new(path)
|
23
|
+
end
|
19
24
|
end
|
20
25
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'recursive-open-struct'
|
3
|
+
|
4
|
+
class Bosh::Deployer::MicroboshSettings < RecursiveOpenStruct
|
5
|
+
attr_reader :filepath
|
6
|
+
|
7
|
+
def initialize(h=nil, args={})
|
8
|
+
if h && h.is_a?(String)
|
9
|
+
@filepath ||= h
|
10
|
+
super(YAML.load_file(filepath)) if File.exists?(filepath)
|
11
|
+
else
|
12
|
+
@filepath ||= '~/.bootstrap/settings.yml'
|
13
|
+
super(h, args)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.load(filepath = nil)
|
18
|
+
new(filepath).tap do |settings|
|
19
|
+
return unless settings.to_a
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'bosh-deployer/stub'
|
3
|
+
require 'cancun'
|
4
|
+
require 'cancun/highline'
|
5
|
+
|
6
|
+
module Bosh; module Deployer; end ;end
|
7
|
+
|
8
|
+
class Bosh::Deployer::Stub
|
9
|
+
include ::Cancun::Highline
|
10
|
+
|
11
|
+
attr_reader :filename
|
12
|
+
|
13
|
+
def initialize(path = '~/.bosh-deployer/stubs')
|
14
|
+
path = path[0..-2] if path[-1] == '/'
|
15
|
+
@filename = "#{path}/#{name}.yml"
|
16
|
+
end
|
17
|
+
|
18
|
+
def name
|
19
|
+
raise NotImplementedError
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate
|
23
|
+
if File.exists?(filename) and !agree "#{filename} already exists, do you want to overwrite it?"
|
24
|
+
say 'Stub generation cancelled!'
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
save_stub
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
def save_stub
|
33
|
+
stub.tap do |s|
|
34
|
+
say "Saving stub at #{filename}"
|
35
|
+
File.open(filename, 'w') { |f| f.write(s) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def template
|
40
|
+
@template ||= ERB.new( File.read(File.expand_path("../../../stubs/#{name}.yml.erb", __FILE__)))
|
41
|
+
end
|
42
|
+
|
43
|
+
def stub
|
44
|
+
say_bold "Provide the following information for #{name} configuration:"
|
45
|
+
template.result(binding)
|
46
|
+
end
|
47
|
+
end
|
data/lib/bosh-deployer.rb
CHANGED
data/spec/bosh_stub_spec.rb
CHANGED
@@ -1,29 +1,8 @@
|
|
1
|
-
|
1
|
+
require_relative 'support/helper'
|
2
2
|
require 'bosh-deployer/bosh_stub'
|
3
|
+
require 'cancun'
|
3
4
|
require 'yaml'
|
4
5
|
|
5
|
-
class Hash
|
6
|
-
def sort_by_key(recursive = false, &block)
|
7
|
-
self.keys.sort(&block).reduce({}) do |seed, key|
|
8
|
-
seed[key] = self[key]
|
9
|
-
if recursive && seed[key].is_a?(Hash)
|
10
|
-
seed[key] = seed[key].sort_by_key(true, &block)
|
11
|
-
end
|
12
|
-
seed
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def equal_yaml(expected_file, actual_file)
|
18
|
-
@expected_content = File.read(expected_file)
|
19
|
-
@actual_content = File.read(actual_file)
|
20
|
-
|
21
|
-
expected = YAML.load(@expected_content).sort_by_key(true).to_a
|
22
|
-
actual = YAML.load(@actual_content).sort_by_key(true).to_a
|
23
|
-
|
24
|
-
expect(expected).to eq(actual)
|
25
|
-
end
|
26
|
-
|
27
6
|
describe Bosh::Deployer::BoshStub do
|
28
7
|
include ::Cancun::Test
|
29
8
|
before{ init_cancun_test }
|
@@ -31,25 +10,12 @@ describe Bosh::Deployer::BoshStub do
|
|
31
10
|
let(:path){ 'tmp/'}
|
32
11
|
let(:bosh_stub){ described_class.new(path) }
|
33
12
|
|
34
|
-
describe '#new' do
|
35
|
-
describe 'when path is given' do
|
36
|
-
it 'sets the filename to PATH/stubs' do
|
37
|
-
expect(bosh_stub.filename).to eq('tmp/bosh.yml')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe 'when path is not given' do
|
42
|
-
let(:bosh_stub){ described_class.new }
|
43
|
-
|
44
|
-
it 'sets the filename to ~/.bosh-deployer/stubs' do
|
45
|
-
expect(bosh_stub.filename).to eq('~/.bosh-deployer/stubs/bosh.yml')
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
13
|
describe '#generate' do
|
51
|
-
let(:
|
52
|
-
|
14
|
+
let(:microbosh_settings) do
|
15
|
+
Bosh::Deployer::MicroboshSettings.new(
|
16
|
+
'spec/fixtures/bosh-bootstrap/settings.yml'
|
17
|
+
)
|
18
|
+
|
53
19
|
end
|
54
20
|
|
55
21
|
let(:args) do
|
@@ -59,14 +25,8 @@ describe Bosh::Deployer::BoshStub do
|
|
59
25
|
describe 'when .bootstrap/settings.yml exist' do
|
60
26
|
before do
|
61
27
|
`rm -rf tmp ; mkdir tmp`
|
62
|
-
allow(
|
63
|
-
|
64
|
-
.with('~/.bootstrap/settings.yml').and_return(true)
|
65
|
-
allow_any_instance_of(ReadWriteSettings)
|
66
|
-
.to receive(:open).and_call_original
|
67
|
-
allow_any_instance_of(ReadWriteSettings)
|
68
|
-
.to receive(:open).with('~/.bootstrap/settings.yml')
|
69
|
-
.and_return(settings_file)
|
28
|
+
allow(Bosh::Deployer::MicroboshSettings)
|
29
|
+
.to receive(:load).and_return(microbosh_settings)
|
70
30
|
end
|
71
31
|
|
72
32
|
|
@@ -95,22 +55,5 @@ describe Bosh::Deployer::BoshStub do
|
|
95
55
|
equal_yaml('spec/fixtures/stubs/bosh.yml', 'tmp/bosh.yml')
|
96
56
|
end
|
97
57
|
end
|
98
|
-
|
99
|
-
describe 'when stub already exists' do
|
100
|
-
before do
|
101
|
-
`rm -rf tmp ; mkdir tmp`
|
102
|
-
`echo 'something' > tmp/bosh.yml`
|
103
|
-
end
|
104
|
-
|
105
|
-
let(:args){ %w{ n } }
|
106
|
-
|
107
|
-
it 'should not change stub if user does not want to edit it' do
|
108
|
-
execute do
|
109
|
-
bosh_stub.generate
|
110
|
-
end.and_type *args
|
111
|
-
expect(output).to include('Stub generation cancelled!')
|
112
|
-
end
|
113
|
-
end
|
114
58
|
end
|
115
|
-
|
116
59
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'cancun'
|
2
|
+
require 'bosh-deployer/cf_stub'
|
3
|
+
require_relative 'support/helper'
|
4
|
+
|
5
|
+
|
6
|
+
describe Bosh::Deployer::CFStub do
|
7
|
+
include ::Cancun::Test
|
8
|
+
before{ init_cancun_test }
|
9
|
+
|
10
|
+
let(:path){ 'tmp/'}
|
11
|
+
let(:cf_stub){ described_class.new(path) }
|
12
|
+
|
13
|
+
describe '#generate' do
|
14
|
+
let(:microbosh_settings) do
|
15
|
+
Bosh::Deployer::MicroboshSettings.new(
|
16
|
+
'spec/fixtures/bosh-bootstrap/settings.yml'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
let(:args) do
|
20
|
+
['2.2.2.2', '10.0.0.0/8', '1.2.3.4', 'MICROBOSH_SUBNET_ID', '3.3.3.3']
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'when .bootstrap/settings.yml exist' do
|
24
|
+
before do
|
25
|
+
`rm -rf tmp ; mkdir tmp`
|
26
|
+
allow(Bosh::Deployer::MicroboshSettings)
|
27
|
+
.to receive(:load).and_return(microbosh_settings)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should generate the stub correctly' do
|
31
|
+
execute do
|
32
|
+
cf_stub.generate
|
33
|
+
end.and_type *args
|
34
|
+
sleep 1 #TODO: develop wait for cmd after and type
|
35
|
+
equal_yaml('spec/fixtures/stubs/cloudfoundry.yml', 'tmp/cloudfoundry.yml')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|