2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
FactoryBot.define do
|
2020-03-09 13:42:32 +05:30
|
|
|
factory :cluster, class: 'Clusters::Cluster' do
|
2018-03-17 18:26:18 +05:30
|
|
|
user
|
2019-12-21 20:55:43 +05:30
|
|
|
name { 'test-cluster' }
|
|
|
|
cluster_type { :project_type }
|
|
|
|
managed { true }
|
|
|
|
namespace_per_environment { true }
|
2019-10-12 21:52:04 +05:30
|
|
|
|
|
|
|
factory :cluster_for_group, traits: [:provided_by_gcp, :group]
|
2018-12-13 13:39:08 +05:30
|
|
|
|
|
|
|
trait :instance do
|
|
|
|
cluster_type { Clusters::Cluster.cluster_types[:instance_type] }
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
trait :project do
|
2018-12-13 13:39:08 +05:30
|
|
|
cluster_type { Clusters::Cluster.cluster_types[:project_type] }
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
before(:create) do |cluster, evaluator|
|
2019-09-30 21:07:59 +05:30
|
|
|
cluster.projects << create(:project) unless cluster.projects.present?
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
trait :group do
|
|
|
|
cluster_type { Clusters::Cluster.cluster_types[:group_type] }
|
|
|
|
|
|
|
|
before(:create) do |cluster, evalutor|
|
2019-07-07 11:18:12 +05:30
|
|
|
cluster.groups << create(:group) unless cluster.groups.present?
|
2018-12-13 13:39:08 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
trait :management_project do
|
|
|
|
management_project factory: :project
|
|
|
|
end
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
trait :namespace_per_environment_disabled do
|
2019-12-21 20:55:43 +05:30
|
|
|
namespace_per_environment { false }
|
2019-10-12 21:52:04 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :provided_by_user do
|
2019-12-21 20:55:43 +05:30
|
|
|
provider_type { :user }
|
|
|
|
platform_type { :kubernetes }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :provided_by_gcp do
|
2019-12-21 20:55:43 +05:30
|
|
|
provider_type { :gcp }
|
|
|
|
platform_type { :kubernetes }
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
provider_gcp factory: [:cluster_provider_gcp, :created]
|
|
|
|
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured]
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
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
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :providing_by_gcp do
|
2019-12-21 20:55:43 +05:30
|
|
|
provider_type { :gcp }
|
2018-03-17 18:26:18 +05:30
|
|
|
provider_gcp factory: [:cluster_provider_gcp, :creating]
|
|
|
|
end
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
trait :rbac_disabled do
|
|
|
|
platform_kubernetes factory: [:cluster_platform_kubernetes, :configured, :rbac_disabled]
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
trait :cloud_run_enabled do
|
|
|
|
provider_gcp factory: [:cluster_provider_gcp, :created, :cloud_run_enabled]
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
trait :disabled do
|
2019-12-21 20:55:43 +05:30
|
|
|
enabled { false }
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2018-05-01 15:08:00 +05:30
|
|
|
|
|
|
|
trait :production_environment do
|
|
|
|
sequence(:environment_scope) { |n| "production#{n}/*" }
|
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
trait :with_installed_helm do
|
|
|
|
application_helm factory: %i(clusters_applications_helm installed)
|
|
|
|
end
|
2019-03-02 22:35:43 +05:30
|
|
|
|
|
|
|
trait :with_domain do
|
2019-12-21 20:55:43 +05:30
|
|
|
domain { 'example.com' }
|
2019-03-02 22:35:43 +05:30
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
|
2020-01-01 13:55:28 +05:30
|
|
|
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-07-31 22:56:46 +05:30
|
|
|
trait :not_managed do
|
2019-12-21 20:55:43 +05:30
|
|
|
managed { false }
|
2019-07-07 11:18:12 +05:30
|
|
|
end
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
trait :cleanup_not_started do
|
|
|
|
cleanup_status { 1 }
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :cleanup_uninstalling_applications do
|
|
|
|
cleanup_status { 2 }
|
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|