diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-03-29 21:24:10 +0200 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-03-29 21:24:10 +0200 |
commit | 982e5436e1ef9b309f8ee3a205f1e168273386b3 (patch) | |
tree | 4038eae5223df2e2135f3cb99b631796436524dc | |
parent | a5f9e49f1317345d1b72566ecff188dff5f74913 (diff) | |
download | gitlab-ce-982e5436e1ef9b309f8ee3a205f1e168273386b3.tar.gz |
Add installed scope to cluster applications
-rw-r--r-- | app/models/clusters/applications/helm.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/applications/ingress.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/applications/prometheus.rb | 2 | ||||
-rw-r--r-- | app/models/clusters/applications/runner.rb | 2 | ||||
-rw-r--r-- | spec/models/clusters/applications/helm_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/clusters/applications/ingress_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/clusters/applications/prometheus_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/clusters/applications/runner_spec.rb | 12 |
8 files changed, 56 insertions, 0 deletions
diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb index 58de3448577..f7dfae56df6 100644 --- a/app/models/clusters/applications/helm.rb +++ b/app/models/clusters/applications/helm.rb @@ -8,6 +8,8 @@ module Clusters default_value_for :version, Gitlab::Kubernetes::Helm::HELM_VERSION + scope :installed, -> { where(status: ::Clusters::Applications::Helm.state_machines[:status].states[:installed].value) } + def set_initial_status return unless not_installable? diff --git a/app/models/clusters/applications/ingress.rb b/app/models/clusters/applications/ingress.rb index 27fc3b85465..8cd88e8aeaf 100644 --- a/app/models/clusters/applications/ingress.rb +++ b/app/models/clusters/applications/ingress.rb @@ -11,6 +11,8 @@ module Clusters default_value_for :ingress_type, :nginx default_value_for :version, :nginx + scope :installed, -> { where(status: ::Clusters::Applications::Ingress.state_machines[:status].states[:installed].value) } + enum ingress_type: { nginx: 1 } diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb index 7b25d8c4089..2ae3e006047 100644 --- a/app/models/clusters/applications/prometheus.rb +++ b/app/models/clusters/applications/prometheus.rb @@ -13,6 +13,8 @@ module Clusters default_value_for :version, VERSION + scope :installed, -> { where(status: ::Clusters::Applications::Prometheus.state_machines[:status].states[:installed].value) } + state_machine :status do after_transition any => [:installed] do |application| application.cluster.projects.each do |project| diff --git a/app/models/clusters/applications/runner.rb b/app/models/clusters/applications/runner.rb index 16efe90fa27..6dc51d1baa4 100644 --- a/app/models/clusters/applications/runner.rb +++ b/app/models/clusters/applications/runner.rb @@ -14,6 +14,8 @@ module Clusters default_value_for :version, VERSION + scope :installed, -> { where(status: ::Clusters::Applications::Runner.state_machines[:status].states[:installed].value) } + def chart "#{name}/gitlab-runner" end diff --git a/spec/models/clusters/applications/helm_spec.rb b/spec/models/clusters/applications/helm_spec.rb index ba7bad617b4..0eb1e3876e2 100644 --- a/spec/models/clusters/applications/helm_spec.rb +++ b/spec/models/clusters/applications/helm_spec.rb @@ -3,6 +3,18 @@ require 'rails_helper' describe Clusters::Applications::Helm do include_examples 'cluster application core specs', :clusters_applications_helm + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_helm, :installed) } + + before do + create(:clusters_applications_helm, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#install_command' do let(:helm) { create(:clusters_applications_helm) } diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb index 03f5b88a525..a47a07d908d 100644 --- a/spec/models/clusters/applications/ingress_spec.rb +++ b/spec/models/clusters/applications/ingress_spec.rb @@ -11,6 +11,18 @@ describe Clusters::Applications::Ingress do allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async) end + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_ingress, :installed) } + + before do + create(:clusters_applications_ingress, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#make_installed!' do before do application.make_installed! diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb index 2905b58066b..aeca6ee903a 100644 --- a/spec/models/clusters/applications/prometheus_spec.rb +++ b/spec/models/clusters/applications/prometheus_spec.rb @@ -4,6 +4,18 @@ describe Clusters::Applications::Prometheus do include_examples 'cluster application core specs', :clusters_applications_prometheus include_examples 'cluster application status specs', :cluster_application_prometheus + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_prometheus, :installed) } + + before do + create(:clusters_applications_prometheus, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe 'transition to installed' do let(:project) { create(:project) } let(:cluster) { create(:cluster, projects: [project]) } diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb index a574779e39d..64d995a73c1 100644 --- a/spec/models/clusters/applications/runner_spec.rb +++ b/spec/models/clusters/applications/runner_spec.rb @@ -8,6 +8,18 @@ describe Clusters::Applications::Runner do it { is_expected.to belong_to(:runner) } + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_runner, :installed) } + + before do + create(:clusters_applications_runner, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#install_command' do let(:kubeclient) { double('kubernetes client') } let(:gitlab_runner) { create(:clusters_applications_runner, runner: ci_runner) } |