2019-07-25 01:11:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2020-01-09 13:07:52 -05:00
|
|
|
factory :cluster, class: 'Clusters::Cluster' do
|
2017-10-29 14:48:45 -04:00
|
|
|
user
|
2019-10-01 20:06:26 -04:00
|
|
|
name { 'test-cluster' }
|
|
|
|
cluster_type { :project_type }
|
|
|
|
managed { true }
|
|
|
|
namespace_per_environment { true }
|
2018-10-14 16:42:29 -04:00
|
|
|
|
2019-07-16 19:32:04 -04:00
|
|
|
factory :cluster_for_group, traits: [:provided_by_gcp, :group]
|
|
|
|
|
2018-10-14 16:42:29 -04:00
|
|
|
trait :instance do
|
|
|
|
cluster_type { Clusters::Cluster.cluster_types[:instance_type] }
|
|
|
|
end
|
2017-10-29 14:48:45 -04:00
|
|
|
|
|
|
|
trait :project do
|
2018-10-14 16:42:29 -04:00
|
|
|
cluster_type { Clusters::Cluster.cluster_types[:project_type] }
|
|
|
|
|
2018-05-13 06:36:51 -04:00
|
|
|
before(:create) do |cluster, evaluator|
|
2019-06-28 03:10:26 -04:00
|
|
|
cluster.projects << create(:project) unless cluster.projects.present?
|
2017-10-29 14:48:45 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-14 16:42:29 -04:00
|
|
|
trait :group do
|
|
|
|
cluster_type { Clusters::Cluster.cluster_types[:group_type] }
|
|
|
|
|
|
|
|
before(:create) do |cluster, evalutor|
|
2019-03-03 20:14:47 -05:00
|
|
|
cluster.groups << create(:group) unless cluster.groups.present?
|
2018-10-14 16:42:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-14 08:06:14 -04:00
|
|
|
trait :management_project do
|
|
|
|
management_project factory: :project
|
|
|
|
end
|
|
|
|
|
2019-08-07 00:40:29 -04:00
|
|
|
trait :namespace_per_environment_disabled do
|
2019-10-01 20:06:26 -04:00
|
|
|
namespace_per_environment { false }
|
2019-08-07 00:40:29 -04:00
|
|
|
end
|
|
|
|
|
2017-10-29 14:48:45 -04:00
|
|
|
trait :provided_by_user do
|
2019-10-01 20:06:26 -04:00
|
|
|
provider_type { :user }
|
|
|
|
platform_type { :kubernetes }
|
2017-10-30 08:55:18 -04:00
|
|
|
|
2017-12-03 15:36:01 -05:00
|
|
|
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
|
2017-10-29 14:48:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
trait :provided_by_gcp do
|
2019-10-01 20:06:26 -04:00
|
|
|
provider_type { :gcp }
|
|
|
|
platform_type { :kubernetes }
|
2017-10-30 08:55:18 -04:00
|
|
|
|
2017-12-03 15:36:01 -05:00
|
|
|
provider_gcp factory: [:cluster_provider_gcp, :created]
|
|
|
|
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
|
2017-10-29 14:48:45 -04:00
|
|
|
end
|
|
|
|
|
2019-10-16 17:07:22 -04:00
|
|
|
trait :provided_by_aws do
|
|
|
|
provider_type { :aws }
|
|
|
|
platform_type { :kubernetes }
|
|
|
|
|
|
|
|
provider_aws factory: [:cluster_provider_aws, :created]
|
|
|
|
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
|
|
|
|
end
|
|
|
|
|
2017-10-29 14:48:45 -04:00
|
|
|
trait :providing_by_gcp do
|
2019-10-01 20:06:26 -04:00
|
|
|
provider_type { :gcp }
|
2017-12-03 15:36:01 -05:00
|
|
|
provider_gcp factory: [:cluster_provider_gcp, :creating]
|
2017-10-29 14:48:45 -04:00
|
|
|
end
|
2017-12-01 10:27:53 -05:00
|
|
|
|
2018-12-13 10:39:44 -05:00
|
|
|
trait :rbac_disabled do
|
|
|
|
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured, :rbac_disabled]
|
|
|
|
end
|
|
|
|
|
2019-09-22 20:06:29 -04:00
|
|
|
trait :cloud_run_enabled do
|
|
|
|
provider_gcp factory: [:cluster_provider_gcp, :created, :cloud_run_enabled]
|
|
|
|
end
|
|
|
|
|
2017-12-01 10:27:53 -05:00
|
|
|
trait :disabled do
|
2019-10-01 20:06:26 -04:00
|
|
|
enabled { false }
|
2017-12-01 10:27:53 -05:00
|
|
|
end
|
2018-03-21 10:59:40 -04:00
|
|
|
|
|
|
|
trait :production_environment do
|
|
|
|
sequence(:environment_scope) { |n| "production#{n}/*" }
|
|
|
|
end
|
2018-08-07 08:39:38 -04:00
|
|
|
|
|
|
|
trait :with_installed_helm do
|
|
|
|
application_helm factory: %i(clusters_applications_helm installed)
|
|
|
|
end
|
2019-01-14 12:59:35 -05:00
|
|
|
|
2020-06-10 02:08:18 -04:00
|
|
|
trait :with_installed_prometheus do
|
|
|
|
application_prometheus factory: %i(clusters_applications_prometheus installed)
|
2021-06-03 08:10:18 -04:00
|
|
|
integration_prometheus factory: %i(clusters_integrations_prometheus)
|
2020-06-10 02:08:18 -04:00
|
|
|
end
|
|
|
|
|
2020-05-29 08:08:19 -04:00
|
|
|
trait :with_all_applications do
|
|
|
|
application_helm factory: %i(clusters_applications_helm installed)
|
|
|
|
application_ingress factory: %i(clusters_applications_ingress installed)
|
|
|
|
application_cert_manager factory: %i(clusters_applications_cert_manager installed)
|
|
|
|
application_crossplane factory: %i(clusters_applications_crossplane installed)
|
|
|
|
application_prometheus factory: %i(clusters_applications_prometheus installed)
|
|
|
|
application_runner factory: %i(clusters_applications_runner installed)
|
|
|
|
application_jupyter factory: %i(clusters_applications_jupyter installed)
|
|
|
|
application_knative factory: %i(clusters_applications_knative installed)
|
2020-07-09 02:09:37 -04:00
|
|
|
application_cilium factory: %i(clusters_applications_cilium installed)
|
2020-05-29 08:08:19 -04:00
|
|
|
end
|
|
|
|
|
2019-01-14 12:59:35 -05:00
|
|
|
trait :with_domain do
|
2019-10-01 20:06:26 -04:00
|
|
|
domain { 'example.com' }
|
2019-01-14 12:59:35 -05:00
|
|
|
end
|
2019-04-02 02:54:54 -04:00
|
|
|
|
2019-11-18 22:06:07 -05:00
|
|
|
trait :with_environments do
|
|
|
|
transient do
|
|
|
|
environments { %i(staging production) }
|
|
|
|
end
|
|
|
|
|
|
|
|
cluster_type { Clusters::Cluster.cluster_types[:project_type] }
|
|
|
|
|
|
|
|
before(:create) do |cluster, evaluator|
|
|
|
|
cluster_project = create(:cluster_project, cluster: cluster)
|
|
|
|
|
|
|
|
evaluator.environments.each do |env_name|
|
|
|
|
environment = create(:environment, name: env_name, project: cluster_project.project)
|
|
|
|
|
|
|
|
cluster.kubernetes_namespaces << create(:cluster_kubernetes_namespace,
|
|
|
|
cluster: cluster,
|
|
|
|
cluster_project: cluster_project,
|
|
|
|
project: cluster_project.project,
|
|
|
|
environment: environment)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-05-02 21:05:53 -04:00
|
|
|
trait :not_managed do
|
2019-10-01 20:06:26 -04:00
|
|
|
managed { false }
|
2019-04-02 02:54:54 -04:00
|
|
|
end
|
2019-10-29 08:06:40 -04:00
|
|
|
|
|
|
|
trait :cleanup_not_started do
|
|
|
|
cleanup_status { 1 }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :cleanup_removing_project_namespaces do
|
|
|
|
cleanup_status { 3 }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :cleanup_removing_service_account do
|
|
|
|
cleanup_status { 4 }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :cleanup_errored do
|
|
|
|
cleanup_status { 5 }
|
|
|
|
end
|
2017-10-29 14:48:45 -04:00
|
|
|
end
|
|
|
|
end
|