Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
9c140b7d
Commit
9c140b7d
authored
Dec 04, 2018
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DRY up refresh service
The two pieces of code are identical so use a private method
parent
885ea5c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
app/services/clusters/refresh_service.rb
app/services/clusters/refresh_service.rb
+13
-12
No files found.
app/services/clusters/refresh_service.rb
View file @
9c140b7d
...
@@ -7,12 +7,7 @@ module Clusters
...
@@ -7,12 +7,7 @@ module Clusters
# Create all namespaces that are missing for each project
# Create all namespaces that are missing for each project
cluster
.
all_projects
.
missing_kubernetes_namespace
(
cluster_namespaces
).
each
do
|
project
|
cluster
.
all_projects
.
missing_kubernetes_namespace
(
cluster_namespaces
).
each
do
|
project
|
kubernetes_namespace
=
cluster
.
find_or_initialize_kubernetes_namespace_for_project
(
project
)
create_or_update_namespace
(
cluster
,
project
)
::
Clusters
::
Gcp
::
Kubernetes
::
CreateOrUpdateNamespaceService
.
new
(
cluster:
cluster
,
kubernetes_namespace:
kubernetes_namespace
).
execute
end
end
end
end
...
@@ -21,6 +16,13 @@ module Clusters
...
@@ -21,6 +16,13 @@ module Clusters
# Create all namespaces that are missing for each cluster
# Create all namespaces that are missing for each cluster
project
.
all_clusters
.
missing_kubernetes_namespace
(
project_namespaces
).
each
do
|
cluster
|
project
.
all_clusters
.
missing_kubernetes_namespace
(
project_namespaces
).
each
do
|
cluster
|
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
)
kubernetes_namespace
=
cluster
.
find_or_initialize_kubernetes_namespace_for_project
(
project
)
::
Clusters
::
Gcp
::
Kubernetes
::
CreateOrUpdateNamespaceService
.
new
(
::
Clusters
::
Gcp
::
Kubernetes
::
CreateOrUpdateNamespaceService
.
new
(
...
@@ -29,5 +31,4 @@ module Clusters
...
@@ -29,5 +31,4 @@ module Clusters
).
execute
).
execute
end
end
end
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment