Skip to content
Snippets Groups Projects
Unverified Commit b0dced27 authored by Gilbert Roulot's avatar Gilbert Roulot
Browse files

Port EE changes to CE

Add a upgrade command method to the Ingress application.
parent 093629fe
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -45,6 +45,24 @@ module Clusters
)
end
 
def upgrade_command(values)
::Gitlab::Kubernetes::Helm::InstallCommand.new(
name: name,
version: VERSION,
rbac: cluster.platform_kubernetes_rbac?,
chart: chart,
files: files_with_replaced_values(values)
)
end
# Returns a copy of files where the values of 'values.yaml'
# are replaced by the argument.
#
# See #values for the data format required
def files_with_replaced_values(replaced_values)
files.merge('values.yaml': replaced_values)
end
def schedule_status_update
return unless installed?
return if external_ip
Loading
Loading
Loading
Loading
@@ -96,6 +96,46 @@ describe Clusters::Applications::Ingress do
end
end
 
describe '#upgrade_command' do
let(:ingress) { build(:clusters_applications_ingress) }
let(:values) { ingress.values }
it 'returns an instance of Gitlab::Kubernetes::Helm::InstallCommand' do
expect(ingress.upgrade_command(values)).to be_an_instance_of(::Gitlab::Kubernetes::Helm::InstallCommand)
end
it 'should be initialized with ingress arguments' do
command = ingress.upgrade_command(values)
expect(command.name).to eq('ingress')
expect(command.chart).to eq('stable/nginx-ingress')
expect(command.version).to eq('1.1.2')
expect(command.files).to eq(ingress.files)
end
end
describe '#update_in_progress?' do
context 'when app is updating' do
it 'returns true' do
cluster = create(:cluster)
ingress_app = build(:clusters_applications_ingress, :updating, cluster: cluster)
expect(ingress_app.update_in_progress?).to be true
end
end
end
describe '#update_errored?' do
context 'when app errored' do
it 'returns true' do
cluster = create(:cluster)
ingress_app = build(:clusters_applications_ingress, :update_errored, cluster: cluster)
expect(ingress_app.update_errored?).to be true
end
end
end
describe '#files' do
let(:application) { ingress }
let(:values) { subject[:'values.yaml'] }
Loading
Loading
@@ -109,4 +149,43 @@ describe Clusters::Applications::Ingress do
expect(values).to include('podAnnotations')
end
end
describe '#files_with_replaced_values' do
let(:application) { build(:clusters_applications_ingress) }
let(:files) { application.files }
subject { application.files_with_replaced_values({ hello: :world }) }
it 'does not modify #files' do
expect(subject[:'values.yaml']).not_to eq(files)
expect(files[:'values.yaml']).to eq(application.values)
end
it 'returns values.yaml with replaced values' do
expect(subject[:'values.yaml']).to eq({ hello: :world })
end
it 'should include cert files' do
expect(subject[:'ca.pem']).to be_present
expect(subject[:'ca.pem']).to eq(application.cluster.application_helm.ca_cert)
expect(subject[:'cert.pem']).to be_present
expect(subject[:'key.pem']).to be_present
cert = OpenSSL::X509::Certificate.new(subject[:'cert.pem'])
expect(cert.not_after).to be < 60.minutes.from_now
end
context 'when the helm application does not have a ca_cert' do
before do
application.cluster.application_helm.ca_cert = nil
end
it 'should not include cert files' do
expect(subject[:'ca.pem']).not_to be_present
expect(subject[:'cert.pem']).not_to be_present
expect(subject[:'key.pem']).not_to be_present
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment