Commit 9c5050b1 authored by Thong Kuah's avatar Thong Kuah

Drive creation of a rbac platform_kubernetes off provider#legacy_abac so that...

Drive creation of a rbac platform_kubernetes off provider#legacy_abac so that there is one single source of truth.
parent 577c79bb
...@@ -25,7 +25,7 @@ module Clusters ...@@ -25,7 +25,7 @@ module Clusters
private private
def create_gitlab_service_account! def create_gitlab_service_account!
if rbac_clusters_feature_enabled? if create_rbac_cluster?
Clusters::Gcp::Kubernetes::CreateServiceAccountService.new(kube_client).execute Clusters::Gcp::Kubernetes::CreateServiceAccountService.new(kube_client).execute
end end
end end
...@@ -47,17 +47,17 @@ module Clusters ...@@ -47,17 +47,17 @@ module Clusters
end end
def request_kubernetes_token def request_kubernetes_token
service_account_name = rbac_clusters_feature_enabled? ? Clusters::Gcp::Kubernetes::SERVICE_ACCOUNT_NAME : 'default' service_account_name = create_rbac_cluster? ? Clusters::Gcp::Kubernetes::SERVICE_ACCOUNT_NAME : 'default'
Clusters::Gcp::Kubernetes::FetchKubernetesTokenService.new(kube_client, service_account_name).execute Clusters::Gcp::Kubernetes::FetchKubernetesTokenService.new(kube_client, service_account_name).execute
end end
def authorization_type def authorization_type
rbac_clusters_feature_enabled? ? 'rbac' : 'abac' create_rbac_cluster? ? 'rbac' : 'abac'
end end
def rbac_clusters_feature_enabled? def create_rbac_cluster?
Feature.enabled?(:rbac_clusters) !provider.legacy_abac?
end end
def kube_client def kube_client
......
...@@ -28,10 +28,6 @@ describe Clusters::Gcp::FinalizeCreationService do ...@@ -28,10 +28,6 @@ describe Clusters::Gcp::FinalizeCreationService do
end end
end end
before do
stub_feature_flags(rbac_clusters: false)
end
context 'when suceeded to fetch gke cluster info' do context 'when suceeded to fetch gke cluster info' do
let(:endpoint) { '111.111.111.111' } let(:endpoint) { '111.111.111.111' }
let(:api_url) { 'https://' + endpoint } let(:api_url) { 'https://' + endpoint }
...@@ -85,7 +81,8 @@ describe Clusters::Gcp::FinalizeCreationService do ...@@ -85,7 +81,8 @@ describe Clusters::Gcp::FinalizeCreationService do
let(:secret_name) { 'gitlab-token-Y1a' } let(:secret_name) { 'gitlab-token-Y1a' }
before do before do
stub_feature_flags(rbac_clusters: true) provider.legacy_abac = false
stub_kubeclient_create_service_account(api_url) stub_kubeclient_create_service_account(api_url)
stub_kubeclient_create_cluster_role_binding(api_url) stub_kubeclient_create_cluster_role_binding(api_url)
end end
...@@ -118,7 +115,8 @@ describe Clusters::Gcp::FinalizeCreationService do ...@@ -118,7 +115,8 @@ describe Clusters::Gcp::FinalizeCreationService do
context 'rbac_clusters feature enabled' do context 'rbac_clusters feature enabled' do
before do before do
stub_feature_flags(rbac_clusters: true) provider.legacy_abac = false
stub_kubeclient_create_service_account(api_url) stub_kubeclient_create_service_account(api_url)
stub_kubeclient_create_cluster_role_binding(api_url) stub_kubeclient_create_cluster_role_binding(api_url)
end end
...@@ -140,7 +138,8 @@ describe Clusters::Gcp::FinalizeCreationService do ...@@ -140,7 +138,8 @@ describe Clusters::Gcp::FinalizeCreationService do
let(:secret_name) { 'gitlab-token-321' } let(:secret_name) { 'gitlab-token-321' }
before do before do
stub_feature_flags(rbac_clusters: true) provider.legacy_abac = false
stub_kubeclient_create_service_account(api_url) stub_kubeclient_create_service_account(api_url)
stub_kubeclient_create_cluster_role_binding(api_url) stub_kubeclient_create_cluster_role_binding(api_url)
end end
...@@ -158,7 +157,8 @@ describe Clusters::Gcp::FinalizeCreationService do ...@@ -158,7 +157,8 @@ describe Clusters::Gcp::FinalizeCreationService do
context 'rbac_clusters feature enabled' do context 'rbac_clusters feature enabled' do
before do before do
stub_feature_flags(rbac_clusters: true) provider.legacy_abac = false
stub_kubeclient_create_service_account(api_url) stub_kubeclient_create_service_account(api_url)
stub_kubeclient_create_cluster_role_binding(api_url) stub_kubeclient_create_cluster_role_binding(api_url)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment