Commit 25ff795f authored by Thong Kuah's avatar Thong Kuah

Merge branch 'cilium-cluster-application' into 'master'

Add Cluster::Applications::Cilium model

See merge request gitlab-org/gitlab!34688
parents 0ccea59d b434377f
# frozen_string_literal: true
module Clusters
module Applications
class Cilium < ApplicationRecord
self.table_name = 'clusters_applications_cilium'
include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus
def allowed_to_uninstall?
false
end
end
end
end
......@@ -21,7 +21,8 @@ module Clusters
Clusters::Applications::Jupyter.application_name => Clusters::Applications::Jupyter,
Clusters::Applications::Knative.application_name => Clusters::Applications::Knative,
Clusters::Applications::ElasticStack.application_name => Clusters::Applications::ElasticStack,
Clusters::Applications::Fluentd.application_name => Clusters::Applications::Fluentd
Clusters::Applications::Fluentd.application_name => Clusters::Applications::Fluentd,
Clusters::Applications::Cilium.application_name => Clusters::Applications::Cilium
}.freeze
DEFAULT_ENVIRONMENT = '*'
KUBE_INGRESS_BASE_DOMAIN = 'KUBE_INGRESS_BASE_DOMAIN'
......@@ -65,6 +66,7 @@ module Clusters
has_one_cluster_application :knative
has_one_cluster_application :elastic_stack
has_one_cluster_application :fluentd
has_one_cluster_application :cilium
has_many :kubernetes_namespaces
has_many :metrics_dashboard_annotations, class_name: 'Metrics::Dashboard::Annotation', inverse_of: :cluster
......
......@@ -4,7 +4,7 @@ class ClusterApplicationEntity < Grape::Entity
expose :name
expose :status_name, as: :status
expose :status_reason
expose :version
expose :version, if: -> (e, _) { e.respond_to?(:version) }
expose :external_ip, if: -> (e, _) { e.respond_to?(:external_ip) }
expose :external_hostname, if: -> (e, _) { e.respond_to?(:external_hostname) }
expose :hostname, if: -> (e, _) { e.respond_to?(:hostname) }
......
......@@ -172,5 +172,13 @@ FactoryBot.define do
cluster factory: %i(cluster provided_by_gcp)
end
end
factory :clusters_applications_cilium, class: 'Clusters::Applications::Cilium' do
cluster factory: %i(cluster with_installed_helm provided_by_gcp)
trait :no_helm_installed do
cluster factory: %i(cluster provided_by_gcp)
end
end
end
end
......@@ -101,6 +101,7 @@ FactoryBot.define do
application_knative factory: %i(clusters_applications_knative installed)
application_elastic_stack factory: %i(clusters_applications_elastic_stack installed)
application_fluentd factory: %i(clusters_applications_fluentd installed)
application_cilium factory: %i(clusters_applications_cilium installed)
end
trait :with_domain do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Clusters::Applications::Cilium do
let(:cilium) { create(:clusters_applications_cilium) }
include_examples 'cluster application core specs', :clusters_applications_cilium
include_examples 'cluster application status specs', :clusters_applications_cilium
include_examples 'cluster application initial status specs'
describe '#allowed_to_uninstall?' do
subject { cilium.allowed_to_uninstall? }
it { is_expected.to be false }
end
end
......@@ -88,16 +88,6 @@ RSpec.shared_examples 'cluster application status specs' do |application_name|
end
end
it 'sets the correct version of the application' do
subject.update!(version: '0.0.0')
subject.make_installed!
subject.reload
expect(subject.version).to eq(subject.class.const_get(:VERSION, false))
end
context 'application is updating' do
subject { create(application_name, :updating) }
......@@ -146,16 +136,6 @@ RSpec.shared_examples 'cluster application status specs' do |application_name|
end
end
end
it 'updates the version of the application' do
subject.update!(version: '0.0.0')
subject.make_installed!
subject.reload
expect(subject.version).to eq(subject.class.const_get(:VERSION, false))
end
end
end
......
......@@ -19,4 +19,32 @@ RSpec.shared_examples 'cluster application version specs' do |application_name|
it { is_expected.to be_falsey }
end
end
describe '#make_installed' do
subject { create(application_name, :installing) }
it 'sets the correct version of the application' do
subject.update!(version: '0.0.0')
subject.make_installed!
subject.reload
expect(subject.version).to eq(subject.class.const_get(:VERSION, false))
end
context 'application is updating' do
subject { create(application_name, :updating) }
it 'updates the version of the application' do
subject.update!(version: '0.0.0')
subject.make_installed!
subject.reload
expect(subject.version).to eq(subject.class.const_get(:VERSION, false))
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