2017-12-13 19:13:44 -05:00
|
|
|
FactoryBot.define do
|
2017-10-29 14:48:45 -04:00
|
|
|
factory :cluster, class: Clusters::Cluster do
|
|
|
|
user
|
|
|
|
name 'test-cluster'
|
2018-10-14 16:42:29 -04:00
|
|
|
cluster_type :project_type
|
2019-04-02 02:54:54 -04:00
|
|
|
managed true
|
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-03-03 20:14:47 -05:00
|
|
|
cluster.projects << create(:project, :repository) 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
|
|
|
|
|
2017-10-29 14:48:45 -04:00
|
|
|
trait :provided_by_user do
|
|
|
|
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
|
|
|
|
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
|
|
|
|
|
|
|
|
trait :providing_by_gcp do
|
|
|
|
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
|
|
|
|
|
2017-12-01 10:27:53 -05:00
|
|
|
trait :disabled do
|
|
|
|
enabled false
|
|
|
|
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
|
|
|
|
|
|
|
trait :with_domain do
|
|
|
|
domain 'example.com'
|
|
|
|
end
|
2019-04-02 02:54:54 -04:00
|
|
|
|
|
|
|
trait :user_managed do
|
|
|
|
managed false
|
|
|
|
end
|
2017-10-29 14:48:45 -04:00
|
|
|
end
|
|
|
|
end
|