debian-mirror-gitlab/spec/factories/clusters/kubernetes_namespaces.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2018-12-13 13:39:08 +05:30
# frozen_string_literal: true
FactoryBot.define do
2020-03-13 15:44:24 +05:30
factory :cluster_kubernetes_namespace, class: 'Clusters::KubernetesNamespace' do
2018-12-13 13:39:08 +05:30
association :cluster, :project, :provided_by_gcp
after(:build) do |kubernetes_namespace|
2019-10-12 21:52:04 +05:30
cluster = kubernetes_namespace.cluster
if cluster.project_type?
cluster_project = cluster.cluster_project
2018-12-13 13:39:08 +05:30
2020-11-24 15:15:51 +05:30
kubernetes_namespace.project = cluster_project&.project
2019-02-15 15:39:39 +05:30
kubernetes_namespace.cluster_project = cluster_project
end
2019-10-12 21:52:04 +05:30
2020-11-24 15:15:51 +05:30
if kubernetes_namespace.project
kubernetes_namespace.namespace ||=
Gitlab::Kubernetes::DefaultNamespace.new(
cluster,
project: kubernetes_namespace.project
).from_environment_slug(kubernetes_namespace.environment&.slug)
end
2019-10-12 21:52:04 +05:30
kubernetes_namespace.service_account_name ||= "#{kubernetes_namespace.namespace}-service-account"
2018-12-13 13:39:08 +05:30
end
trait :with_token do
service_account_token { FFaker::Lorem.characters(10) }
end
2019-09-04 21:01:54 +05:30
trait :without_token do
2019-12-21 20:55:43 +05:30
service_account_token { nil }
2019-09-04 21:01:54 +05:30
end
2018-12-13 13:39:08 +05:30
end
end