Commit fc0b8252 authored by Thong Kuah's avatar Thong Kuah

Do not allow applications for group clusters

These applications will need further work in future issues to enable
them to work with groups of projects.
parent 2109cb99
...@@ -42,7 +42,16 @@ module Clusters ...@@ -42,7 +42,16 @@ module Clusters
def builders def builders
{ {
"helm" => -> (cluster) { cluster.application_helm || cluster.build_application_helm }, "helm" => -> (cluster) { cluster.application_helm || cluster.build_application_helm },
"ingress" => -> (cluster) { cluster.application_ingress || cluster.build_application_ingress }, "ingress" => -> (cluster) { cluster.application_ingress || cluster.build_application_ingress }
}.tap do |hash|
hash.merge!(project_builders) if cluster.project_type?
end
end
# These applications will need extra configuration to enable them to work
# with groups of projects
def project_builders
{
"prometheus" => -> (cluster) { cluster.application_prometheus || cluster.build_application_prometheus }, "prometheus" => -> (cluster) { cluster.application_prometheus || cluster.build_application_prometheus },
"runner" => -> (cluster) { cluster.application_runner || cluster.build_application_runner }, "runner" => -> (cluster) { cluster.application_runner || cluster.build_application_runner },
"jupyter" => -> (cluster) { cluster.application_jupyter || cluster.build_application_jupyter }, "jupyter" => -> (cluster) { cluster.application_jupyter || cluster.build_application_jupyter },
......
...@@ -60,14 +60,6 @@ describe Clusters::Applications::CreateService do ...@@ -60,14 +60,6 @@ describe Clusters::Applications::CreateService do
end end
end end
context 'invalid application' do
let(:params) { { application: 'non-existent' } }
it 'raises an error' do
expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError)
end
end
context 'knative application' do context 'knative application' do
let(:params) do let(:params) do
{ {
...@@ -100,5 +92,39 @@ describe Clusters::Applications::CreateService do ...@@ -100,5 +92,39 @@ describe Clusters::Applications::CreateService do
expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError) expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError)
end end
end end
context 'group cluster' do
let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
using RSpec::Parameterized::TableSyntax
before do
allow_any_instance_of(Clusters::Applications::ScheduleInstallationService).to receive(:execute)
end
where(:application, :association, :allowed) do
'helm' | :application_helm | true
'ingress' | :application_ingress | true
'runner' | :application_runner | false
'jupyter' | :application_jupyter | false
'prometheus' | :application_prometheus | false
end
with_them do
let(:params) { { application: application } }
it 'executes for each application' do
if allowed
expect do
subject
cluster.reload
end.to change(cluster, association)
else
expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError)
end
end
end
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment