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
Léo-Paul Géneau
gitlab-ce
Commits
9b7719b6
Commit
9b7719b6
authored
Jan 03, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use explicit namespace for avoiding reference from application code
parent
f083739e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
13 deletions
+16
-13
db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
...grate_kubernetes_service_to_new_clusters_architectures.rb
+16
-13
No files found.
db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
View file @
9b7719b6
...
...
@@ -5,16 +5,17 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
class
Project
<
ActiveRecord
::
Base
self
.
table_name
=
'projects'
has_many
:cluster_projects
,
class_name:
'ClustersProject'
has_many
:clusters
,
through: :cluster_projects
,
class_name:
'Cluster'
has_many
:cluster_projects
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject'
has_many
:clusters
,
through: :cluster_projects
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::Cluster'
has_many
:services
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::Service'
end
class
Cluster
<
ActiveRecord
::
Base
self
.
table_name
=
'clusters'
has_many
:cluster_projects
,
class_name:
'ClustersProject'
has_many
:projects
,
through: :cluster_projects
,
class_name:
'Project'
has_one
:platform_kubernetes
,
class_name:
'PlatformsKubernetes'
has_many
:cluster_projects
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
ClustersProject'
has_many
:projects
,
through: :cluster_projects
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
Project'
has_one
:platform_kubernetes
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
PlatformsKubernetes'
accepts_nested_attributes_for
:platform_kubernetes
...
...
@@ -31,13 +32,15 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
class
ClustersProject
<
ActiveRecord
::
Base
self
.
table_name
=
'cluster_projects'
belongs_to
:cluster
,
class_name:
'Cluster'
belongs_to
:project
,
class_name:
'Project'
belongs_to
:cluster
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
Cluster'
belongs_to
:project
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
Project'
end
class
PlatformsKubernetes
<
ActiveRecord
::
Base
self
.
table_name
=
'cluster_platforms_kubernetes'
belongs_to
:cluster
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::Cluster'
attr_encrypted
:token
,
mode: :per_attribute_iv
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
,
...
...
@@ -49,7 +52,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
self
.
table_name
=
'services'
belongs_to
:project
,
class_name:
'Project'
belongs_to
:project
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
Project'
scope
:kubernetes_service
,
->
do
where
(
"services.category = 'deployment'"
)
...
...
@@ -84,15 +87,15 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
end
def
up
Service
.
kubernetes_service
.
find_each
(
batch_size:
1
)
do
|
kubernetes_service
|
MigrateKubernetesServiceToNewClustersArchitectures
::
Service
.
kubernetes_service
.
find_each
(
batch_size:
1
)
do
|
kubernetes_service
|
unless
managed_by_clusters?
(
kubernetes_service
)
Cluster
.
create
(
MigrateKubernetesServiceToNewClustersArchitectures
::
Cluster
.
create
(
enabled:
kubernetes_service
.
active
,
user_id:
nil
,
# KubernetesService doesn't have
name:
DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME
,
provider_type:
Cluster
.
provider_types
[
:user
],
platform_type:
Cluster
.
platform_types
[
:kubernetes
],
projects:
[
kubernetes_service
.
project
],
provider_type:
MigrateKubernetesServiceToNewClustersArchitectures
::
Cluster
.
provider_types
[
:user
],
platform_type:
MigrateKubernetesServiceToNewClustersArchitectures
::
Cluster
.
platform_types
[
:kubernetes
],
projects:
[
kubernetes_service
.
project
.
becomes
(
MigrateKubernetesServiceToNewClustersArchitectures
::
Project
)
],
environment_scope:
find_dedicated_environement_scope
(
kubernetes_service
.
project
),
platform_kubernetes_attributes:
{
api_url:
kubernetes_service
.
api_url
,
...
...
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