CID-340: set deployers list for sandbox projects
This commit is contained in:
parent
4144161089
commit
fce9231acc
@ -196,6 +196,9 @@ module Devops
|
||||
# "groups": [], -> specify special security groups, overrides value from project env
|
||||
# "key": "ssh key" -> specify ssh key for server, overrides value from project env
|
||||
# "private_ip": null -> should be string like "172.31.31.203" if present
|
||||
# "project_info": {
|
||||
# "deployers": ['user1'] -> currently it's used only in sandbox projects
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# * *Returns* : text stream
|
||||
|
||||
@ -119,9 +119,11 @@ module Devops
|
||||
schedule_expiration()
|
||||
|
||||
unless options["without_bootstrap"]
|
||||
bootstrap_options = {
|
||||
bootstrap_template: i.bootstrap_template
|
||||
}
|
||||
bootstrap_options = { bootstrap_template: i.bootstrap_template }
|
||||
if @project.is_sandbox?
|
||||
bootstrap_options[:deployers] = [options['created_by']]
|
||||
bootstrap_options[:deployers] += (options['project_info']['deployers'] || []) if options['project_info']
|
||||
end
|
||||
return two_phase_bootstrap(bootstrap_options)
|
||||
else
|
||||
return 0
|
||||
@ -287,6 +289,7 @@ module Devops
|
||||
@out.flush
|
||||
knife_instance.set_run_list(@server.chef_node_name, run_list)
|
||||
deploy_info = options[:deploy_info] || @project.deploy_info(@deploy_env)
|
||||
deploy_info['project_info']['deployers'] = options[:deployers] if options[:deployers]
|
||||
deploy_status = deploy_server(deploy_info)
|
||||
if deploy_status == 0
|
||||
0
|
||||
|
||||
@ -80,7 +80,7 @@ RSpec.describe Devops::Executor::ServerExecutor, type: :executor, stubbed_connec
|
||||
describe '#create_server' do
|
||||
let(:image) { double('Image instance', remote_user: 'remote_user') }
|
||||
let(:create_server_options) { {
|
||||
'created_by' => 'user',
|
||||
'created_by' => 'me',
|
||||
'run_list' => @run_list,
|
||||
'name' => 'node_name',
|
||||
'key' => @key,
|
||||
@ -92,14 +92,16 @@ RSpec.describe Devops::Executor::ServerExecutor, type: :executor, stubbed_connec
|
||||
allow(provider).to receive(:create_server) { true }
|
||||
allow(stubbed_connector).to receive(:image) { image }
|
||||
allow(stubbed_connector).to receive(:server_insert)
|
||||
@without_bootstrap = true
|
||||
@run_list = %w(role[asd])
|
||||
@key = 'key'
|
||||
|
||||
allow(image).to receive(:bootstrap_template) { 'template' }
|
||||
allow(executor).to receive(:two_phase_bootstrap)
|
||||
end
|
||||
|
||||
it 'builds server model from given options' do
|
||||
create_server
|
||||
expect(executor.server.created_by).to eq 'user'
|
||||
expect(executor.server.created_by).to eq 'me'
|
||||
expect(executor.server.chef_node_name).to eq 'node_name'
|
||||
expect(executor.server.key).to eq @key
|
||||
expect(executor.server.run_list).to eq @run_list
|
||||
@ -149,26 +151,25 @@ RSpec.describe Devops::Executor::ServerExecutor, type: :executor, stubbed_connec
|
||||
create_server
|
||||
end
|
||||
|
||||
context 'without_bootstrap option is false or nil' do
|
||||
it 'launches bootstrap' do
|
||||
@without_bootstrap = false
|
||||
allow(image).to receive(:bootstrap_template) { 'template' }
|
||||
allow(executor).to receive(:two_phase_bootstrap)
|
||||
expect(executor).to receive(:two_phase_bootstrap)
|
||||
create_server
|
||||
end
|
||||
|
||||
it 'launches bootstrap' do
|
||||
@without_bootstrap = nil
|
||||
allow(image).to receive(:bootstrap_template) { 'template' }
|
||||
allow(executor).to receive(:two_phase_bootstrap)
|
||||
expect(executor).to receive(:two_phase_bootstrap)
|
||||
create_server
|
||||
end
|
||||
|
||||
# it 'passes additional deployers to bootstrap' do
|
||||
# executor = described_class.new(server, output)
|
||||
# end
|
||||
it 'launches bootstrap without_bootstrap option is false' do
|
||||
@without_bootstrap = false
|
||||
expect(executor).to receive(:two_phase_bootstrap)
|
||||
create_server
|
||||
end
|
||||
|
||||
context "when project is sandbox" do
|
||||
it 'it sets deployers to owner and passed deployers' do
|
||||
allow(project).to receive(:is_sandbox?) { true }
|
||||
create_server_options['project_info'] = {'deployers' => %w(user1 user2)}
|
||||
expect(executor).to receive(:two_phase_bootstrap).with(hash_including(deployers: %w(me user1 user2)))
|
||||
create_server
|
||||
end
|
||||
end
|
||||
|
||||
context 'without_bootstrap option is true' do
|
||||
@ -332,6 +333,13 @@ RSpec.describe Devops::Executor::ServerExecutor, type: :executor, stubbed_connec
|
||||
two_phase_bootstrap
|
||||
end
|
||||
|
||||
it 'it sets deployers passed deployers if present' do
|
||||
expect(executor).to receive(:deploy_server) do |param|
|
||||
expect(param['project_info']['deployers']).to match_array %w(user1 user2)
|
||||
end
|
||||
executor.two_phase_bootstrap(deployers: %w(user1 user2))
|
||||
end
|
||||
|
||||
context 'if deploy was successful' do
|
||||
it 'returns 0' do
|
||||
allow(executor).to receive(:deploy_server) { 0 }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user