diff options
author | Thong Kuah <tkuah@gitlab.com> | 2018-12-04 23:47:27 +1300 |
---|---|---|
committer | Thong Kuah <tkuah@gitlab.com> | 2018-12-05 10:16:44 +1300 |
commit | 9c140b7d26faaaa939dc3f2461fafc8cc434e47c (patch) | |
tree | efa13d40df4ddadb0fa88e191da6d20c4c515858 /app/services | |
parent | 885ea5c33c8e99935e04b6f929f0bafcf3f8eed8 (diff) | |
download | gitlab-ce-9c140b7d26faaaa939dc3f2461fafc8cc434e47c.tar.gz |
DRY up refresh service
The two pieces of code are identical so use a private method
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/clusters/refresh_service.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/app/services/clusters/refresh_service.rb b/app/services/clusters/refresh_service.rb index 51859a002c0..c203f495b7c 100644 --- a/app/services/clusters/refresh_service.rb +++ b/app/services/clusters/refresh_service.rb @@ -7,12 +7,7 @@ module Clusters # Create all namespaces that are missing for each project cluster.all_projects.missing_kubernetes_namespace(cluster_namespaces).each do |project| - kubernetes_namespace = cluster.find_or_initialize_kubernetes_namespace_for_project(project) - - ::Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService.new( - cluster: cluster, - kubernetes_namespace: kubernetes_namespace - ).execute + create_or_update_namespace(cluster, project) end end @@ -21,13 +16,19 @@ module Clusters # Create all namespaces that are missing for each cluster project.all_clusters.missing_kubernetes_namespace(project_namespaces).each do |cluster| - kubernetes_namespace = cluster.find_or_initialize_kubernetes_namespace_for_project(project) - - ::Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService.new( - cluster: cluster, - kubernetes_namespace: kubernetes_namespace - ).execute + create_or_update_namespace(cluster, project) end end + + private + + def create_or_update_namespace(cluster, project) + kubernetes_namespace = cluster.find_or_initialize_kubernetes_namespace_for_project(project) + + ::Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService.new( + cluster: cluster, + kubernetes_namespace: kubernetes_namespace + ).execute + end end end |