Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
GitLab FOSS
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
Packages
Packages
Container Registry
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
GitLab.org
GitLab FOSS
Commits
9b7719b6
Commit
9b7719b6
authored
Jan 03, 2018
by
Shinya Maeda
1
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
...
@@ -5,16 +5,17 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
class
Project
<
ActiveRecord
::
Base
class
Project
<
ActiveRecord
::
Base
self
.
table_name
=
'projects'
self
.
table_name
=
'projects'
has_many
:cluster_projects
,
class_name:
'ClustersProject'
has_many
:cluster_projects
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject'
has_many
:clusters
,
through: :cluster_projects
,
class_name:
'Cluster'
has_many
:clusters
,
through: :cluster_projects
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::Cluster'
has_many
:services
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::Service'
end
end
class
Cluster
<
ActiveRecord
::
Base
class
Cluster
<
ActiveRecord
::
Base
self
.
table_name
=
'clusters'
self
.
table_name
=
'clusters'
has_many
:cluster_projects
,
class_name:
'ClustersProject'
has_many
:cluster_projects
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
ClustersProject'
has_many
:projects
,
through: :cluster_projects
,
class_name:
'Project'
has_many
:projects
,
through: :cluster_projects
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
Project'
has_one
:platform_kubernetes
,
class_name:
'PlatformsKubernetes'
has_one
:platform_kubernetes
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
PlatformsKubernetes'
accepts_nested_attributes_for
:platform_kubernetes
accepts_nested_attributes_for
:platform_kubernetes
...
@@ -31,13 +32,15 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
...
@@ -31,13 +32,15 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
class
ClustersProject
<
ActiveRecord
::
Base
class
ClustersProject
<
ActiveRecord
::
Base
self
.
table_name
=
'cluster_projects'
self
.
table_name
=
'cluster_projects'
belongs_to
:cluster
,
class_name:
'Cluster'
belongs_to
:cluster
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
Cluster'
belongs_to
:project
,
class_name:
'Project'
belongs_to
:project
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
Project'
end
end
class
PlatformsKubernetes
<
ActiveRecord
::
Base
class
PlatformsKubernetes
<
ActiveRecord
::
Base
self
.
table_name
=
'cluster_platforms_kubernetes'
self
.
table_name
=
'cluster_platforms_kubernetes'
belongs_to
:cluster
,
class_name:
'MigrateKubernetesServiceToNewClustersArchitectures::Cluster'
attr_encrypted
:token
,
attr_encrypted
:token
,
mode: :per_attribute_iv
,
mode: :per_attribute_iv
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
,
...
@@ -49,7 +52,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
...
@@ -49,7 +52,7 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
self
.
table_name
=
'services'
self
.
table_name
=
'services'
belongs_to
:project
,
class_name:
'Project'
belongs_to
:project
,
class_name:
'
MigrateKubernetesServiceToNewClustersArchitectures::
Project'
scope
:kubernetes_service
,
->
do
scope
:kubernetes_service
,
->
do
where
(
"services.category = 'deployment'"
)
where
(
"services.category = 'deployment'"
)
...
@@ -84,15 +87,15 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
...
@@ -84,15 +87,15 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
end
end
def
up
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
)
unless
managed_by_clusters?
(
kubernetes_service
)
Cluster
.
create
(
MigrateKubernetesServiceToNewClustersArchitectures
::
Cluster
.
create
(
enabled:
kubernetes_service
.
active
,
enabled:
kubernetes_service
.
active
,
user_id:
nil
,
# KubernetesService doesn't have
user_id:
nil
,
# KubernetesService doesn't have
name:
DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME
,
name:
DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME
,
provider_type:
Cluster
.
provider_types
[
:user
],
provider_type:
MigrateKubernetesServiceToNewClustersArchitectures
::
Cluster
.
provider_types
[
:user
],
platform_type:
Cluster
.
platform_types
[
:kubernetes
],
platform_type:
MigrateKubernetesServiceToNewClustersArchitectures
::
Cluster
.
platform_types
[
:kubernetes
],
projects:
[
kubernetes_service
.
project
],
projects:
[
kubernetes_service
.
project
.
becomes
(
MigrateKubernetesServiceToNewClustersArchitectures
::
Project
)
],
environment_scope:
find_dedicated_environement_scope
(
kubernetes_service
.
project
),
environment_scope:
find_dedicated_environement_scope
(
kubernetes_service
.
project
),
platform_kubernetes_attributes:
{
platform_kubernetes_attributes:
{
api_url:
kubernetes_service
.
api_url
,
api_url:
kubernetes_service
.
api_url
,
...
...
Yorick Peterse
@yorickpeterse
mentioned in commit
7b030bcd
·
Jan 11, 2018
mentioned in commit
7b030bcd
mentioned in commit 7b030bcd6b4b435e9d9f510a0c7b6e25c76a3ba8
Toggle commit list
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