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
64be8d70
Commit
64be8d70
authored
Nov 02, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve backend structure of data
parent
461c385e
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
129 additions
and
77 deletions
+129
-77
app/controllers/projects/clusters/applications_controller.rb
app/controllers/projects/clusters/applications_controller.rb
+39
-0
app/models/clusters/applications/helm.rb
app/models/clusters/applications/helm.rb
+6
-5
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+18
-1
app/models/clusters/kubernetes.rb
app/models/clusters/kubernetes.rb
+0
-16
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+4
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/models/project_services/kubernetes_service.rb
app/models/project_services/kubernetes_service.rb
+2
-4
app/presenters/clusters/cluster_presenter.rb
app/presenters/clusters/cluster_presenter.rb
+6
-0
app/serializers/cluster_app_entity.rb
app/serializers/cluster_app_entity.rb
+5
-0
app/serializers/cluster_entity.rb
app/serializers/cluster_entity.rb
+1
-12
app/services/clusters/base_helm_service.rb
app/services/clusters/base_helm_service.rb
+9
-3
app/services/clusters/fetch_app_installation_status_service.rb
...ervices/clusters/fetch_app_installation_status_service.rb
+2
-2
app/services/clusters/finalize_app_installation_service.rb
app/services/clusters/finalize_app_installation_service.rb
+1
-1
app/services/clusters/install_app_service.rb
app/services/clusters/install_app_service.rb
+2
-2
app/workers/concerns/cluster_app.rb
app/workers/concerns/cluster_app.rb
+3
-2
config/routes/project.rb
config/routes/project.rb
+4
-0
db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb
...te/20171031100710_create_clusters_kubernetes_helm_apps.rb
+4
-4
db/schema.rb
db/schema.rb
+21
-14
spec/models/clusters/kubernetes/helm_app_spec.rb
spec/models/clusters/kubernetes/helm_app_spec.rb
+1
-1
spec/models/clusters/kubernetes_spec.rb
spec/models/clusters/kubernetes_spec.rb
+0
-9
spec/models/project_services/kubernetes_service_spec.rb
spec/models/project_services/kubernetes_service_spec.rb
+0
-1
No files found.
app/controllers/projects/clusters/applications_controller.rb
0 → 100644
View file @
64be8d70
class
Projects::Clusters::ApplicationsController
<
Projects
::
ApplicationController
before_action
:cluster
before_action
:application_class
,
only:
[
:create
]
before_action
:authorize_read_cluster!
before_action
:authorize_create_cluster!
,
only:
[
:create
]
def
new
end
def
create
return
render_404
if
application
new_application
=
application_class
.
create
(
cluster:
cluster
)
respond_to
do
|
format
|
format
.
json
do
if
new_application
.
persisted?
head
:ok
else
head
:bad_request
end
end
end
end
private
def
cluster
@cluster
||=
project
.
clusters
.
find_by
(
cluster_id:
params
[
:cluster_id
]).
present
(
current_user:
current_user
)
end
def
application_class
Clusters
::
Cluster
::
Applications
.
find
(
params
[
:application
])
end
def
application
application_class
.
find_by
(
cluster:
cluster
)
end
end
app/models/clusters/
kubernetes/helm_app
.rb
→
app/models/clusters/
applications/helm
.rb
View file @
64be8d70
module
Clusters
module
Clusters
module
Kubernetes
module
Applications
class
HelmApp
<
ActiveRecord
::
Base
class
Helm
<
ActiveRecord
::
Base
self
.
table_name
=
'clusters_applications_helm'
NAME
=
'helm'
.
freeze
NAME
=
'helm'
.
freeze
include
::
Clusters
::
Concerns
::
AppStatus
include
::
Clusters
::
Concerns
::
AppStatus
belongs_to
:kubernetes_service
,
class_name:
'KubernetesService'
,
foreign_key: :service_id
default_value_for
:version
,
Gitlab
::
Clusters
::
Helm
::
HELM_VERSION
belongs_to
:cluser
,
class_name:
'Clusters::Cluster'
,
foreign_key: :cluster_id
alias_method
:cluster
,
:kubernetes_service
default_value_for
:version
,
Gitlab
::
Clusters
::
Helm
::
HELM_VERSION
def
name
def
name
NAME
NAME
...
...
app/models/clusters/cluster.rb
View file @
64be8d70
...
@@ -4,6 +4,10 @@ module Clusters
...
@@ -4,6 +4,10 @@ module Clusters
self
.
table_name
=
'clusters'
self
.
table_name
=
'clusters'
APPLICATIONS
=
{
Clusters
::
Applications
::
Helm
::
NAME
=>
Clusters
::
Applications
::
Helm
}
belongs_to
:user
belongs_to
:user
has_many
:cluster_projects
,
class_name:
'Clusters::Project'
has_many
:cluster_projects
,
class_name:
'Clusters::Project'
...
@@ -15,13 +19,14 @@ module Clusters
...
@@ -15,13 +19,14 @@ module Clusters
# We have to ":destroy" it today to ensure that we clean also the Kubernetes Integration
# We have to ":destroy" it today to ensure that we clean also the Kubernetes Integration
has_one
:platform_kubernetes
,
class_name:
'Clusters::Platforms::Kubernetes'
,
autosave:
true
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_one
:platform_kubernetes
,
class_name:
'Clusters::Platforms::Kubernetes'
,
autosave:
true
,
dependent: :destroy
# rubocop:disable Cop/ActiveRecordDependent
has_one
:application_helm
,
class_name:
'Clusters::Applications::Helm'
accepts_nested_attributes_for
:provider_gcp
,
update_only:
true
accepts_nested_attributes_for
:provider_gcp
,
update_only:
true
accepts_nested_attributes_for
:platform_kubernetes
,
update_only:
true
accepts_nested_attributes_for
:platform_kubernetes
,
update_only:
true
validates
:name
,
cluster_name:
true
validates
:name
,
cluster_name:
true
validate
:restrict_modification
,
on: :update
validate
:restrict_modification
,
on: :update
delegate
:status
,
to: :provider
,
allow_nil:
true
delegate
:status_reason
,
to: :provider
,
allow_nil:
true
delegate
:status_reason
,
to: :provider
,
allow_nil:
true
delegate
:status_name
,
to: :provider
,
allow_nil:
true
delegate
:status_name
,
to: :provider
,
allow_nil:
true
delegate
:on_creation?
,
to: :provider
,
allow_nil:
true
delegate
:on_creation?
,
to: :provider
,
allow_nil:
true
...
@@ -38,6 +43,14 @@ module Clusters
...
@@ -38,6 +43,14 @@ module Clusters
scope
:enabled
,
->
{
where
(
enabled:
true
)
}
scope
:enabled
,
->
{
where
(
enabled:
true
)
}
scope
:disabled
,
->
{
where
(
enabled:
false
)
}
scope
:disabled
,
->
{
where
(
enabled:
false
)
}
def
status_name
if
provider
provider
.
status_name
else
:created
end
end
def
provider
def
provider
return
provider_gcp
if
gcp?
return
provider_gcp
if
gcp?
end
end
...
@@ -53,6 +66,10 @@ module Clusters
...
@@ -53,6 +66,10 @@ module Clusters
end
end
alias_method
:project
,
:first_project
alias_method
:project
,
:first_project
def
kubeclient
platform_kubernetes
.
kubeclient
if
kubernetes?
end
private
private
def
restrict_modification
def
restrict_modification
...
...
app/models/clusters/kubernetes.rb
deleted
100644 → 0
View file @
461c385e
module
Clusters
module
Kubernetes
def
self
.
table_name_prefix
'clusters_kubernetes_'
end
def
self
.
app
(
app_name
)
case
app_name
when
HelmApp
::
NAME
HelmApp
else
raise
ArgumentError
,
"Unknown app
#{
app_name
}
"
end
end
end
end
app/models/clusters/platforms/kubernetes.rb
View file @
64be8d70
...
@@ -60,6 +60,10 @@ module Clusters
...
@@ -60,6 +60,10 @@ module Clusters
self
.
class
.
namespace_for_project
(
project
)
if
project
self
.
class
.
namespace_for_project
(
project
)
if
project
end
end
def
kubeclient
@kubeclient
||=
kubernetes_service
.
kubeclient
if
manages_kubernetes_service?
end
private
private
def
enforce_namespace_to_lower_case
def
enforce_namespace_to_lower_case
...
...
app/models/project.rb
View file @
64be8d70
...
@@ -189,6 +189,7 @@ class Project < ActiveRecord::Base
...
@@ -189,6 +189,7 @@ class Project < ActiveRecord::Base
has_one
:cluster_project
,
class_name:
'Clusters::Project'
has_one
:cluster_project
,
class_name:
'Clusters::Project'
has_one
:cluster
,
through: :cluster_project
,
class_name:
'Clusters::Cluster'
has_one
:cluster
,
through: :cluster_project
,
class_name:
'Clusters::Cluster'
has_many
:clusters
,
through: :cluster_project
,
class_name:
'Clusters::Cluster'
# Container repositories need to remove data from the container registry,
# Container repositories need to remove data from the container registry,
# which is not managed by the DB. Hence we're still using dependent: :destroy
# which is not managed by the DB. Hence we're still using dependent: :destroy
...
...
app/models/project_services/kubernetes_service.rb
View file @
64be8d70
...
@@ -3,8 +3,6 @@ class KubernetesService < DeploymentService
...
@@ -3,8 +3,6 @@ class KubernetesService < DeploymentService
include
Gitlab
::
Kubernetes
include
Gitlab
::
Kubernetes
include
ReactiveCaching
include
ReactiveCaching
has_one
:helm_app
,
class_name:
'Clusters::Kubernetes::HelmApp'
,
foreign_key: :service_id
self
.
reactive_cache_key
=
->
(
service
)
{
[
service
.
class
.
model_name
.
singular
,
service
.
project_id
]
}
self
.
reactive_cache_key
=
->
(
service
)
{
[
service
.
class
.
model_name
.
singular
,
service
.
project_id
]
}
# Namespace defaults to the project path, but can be overridden in case that
# Namespace defaults to the project path, but can be overridden in case that
...
@@ -138,8 +136,8 @@ class KubernetesService < DeploymentService
...
@@ -138,8 +136,8 @@ class KubernetesService < DeploymentService
{
pods:
read_pods
}
{
pods:
read_pods
}
end
end
def
helm
def
kubeclient
Gitlab
::
Clusters
::
Helm
.
new
(
build_kubeclient!
)
@kubeclient
||=
build_kubeclient!
end
end
TEMPLATE_PLACEHOLDER
=
'Kubernetes namespace'
.
freeze
TEMPLATE_PLACEHOLDER
=
'Kubernetes namespace'
.
freeze
...
...
app/presenters/clusters/cluster_presenter.rb
View file @
64be8d70
...
@@ -5,5 +5,11 @@ module Clusters
...
@@ -5,5 +5,11 @@ module Clusters
def
gke_cluster_url
def
gke_cluster_url
"https://console.cloud.google.com/kubernetes/clusters/details/
#{
provider
.
zone
}
/
#{
name
}
"
if
gcp?
"https://console.cloud.google.com/kubernetes/clusters/details/
#{
provider
.
zone
}
/
#{
name
}
"
if
gcp?
end
end
def
applications
Clusters
::
Cluster
::
APPLICATIONS
.
map
do
|
key
,
value
|
value
.
find_by
(
cluster_id:
id
)
end
.
compact
end
end
end
end
end
app/serializers/cluster_app_entity.rb
0 → 100644
View file @
64be8d70
class
ClusterAppEntity
<
Grape
::
Entity
expose
:name
expose
:status_name
,
as: :status
expose
:status_reason
end
app/serializers/cluster_entity.rb
View file @
64be8d70
...
@@ -3,16 +3,5 @@ class ClusterEntity < Grape::Entity
...
@@ -3,16 +3,5 @@ class ClusterEntity < Grape::Entity
expose
:status_name
,
as: :status
expose
:status_name
,
as: :status
expose
:status_reason
expose
:status_reason
expose
:applications
do
|
cluster
,
options
|
expose
:applications
,
using:
ClusterAppEntity
if
cluster
.
created?
{
helm:
{
status:
'installed'
},
ingress:
{
status:
'error'
,
status_reason:
'Missing namespace'
},
runner:
{
status:
'installing'
},
prometheus:
{
status:
'installable'
}
}
else
{}
end
end
end
end
app/services/clusters/base_helm_service.rb
View file @
64be8d70
...
@@ -8,10 +8,16 @@ module Clusters
...
@@ -8,10 +8,16 @@ module Clusters
protected
protected
def
helm
def
cluster
return
@helm
if
defined?
(
@helm
)
app
.
cluster
end
def
kubeclient
cluster
.
kubeclient
end
@helm
=
@app
.
cluster
.
helm
def
helm_api
@helm
||=
Gitlab
::
Clusters
::
Helm
.
new
(
kubeclient
)
end
end
end
end
end
end
app/services/clusters/fetch_app_installation_status_service.rb
View file @
64be8d70
...
@@ -3,8 +3,8 @@ module Clusters
...
@@ -3,8 +3,8 @@ module Clusters
def
execute
def
execute
return
unless
app
.
installing?
return
unless
app
.
installing?
phase
=
helm
.
installation_status
(
app
)
phase
=
helm
_api
.
installation_status
(
app
)
log
=
helm
.
installation_log
(
app
)
if
phase
==
'Failed'
log
=
helm
_api
.
installation_log
(
app
)
if
phase
==
'Failed'
yield
(
phase
,
log
)
if
block_given?
yield
(
phase
,
log
)
if
block_given?
rescue
KubeException
=>
ke
rescue
KubeException
=>
ke
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
unless
app
.
errored?
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
unless
app
.
errored?
...
...
app/services/clusters/finalize_app_installation_service.rb
View file @
64be8d70
module
Clusters
module
Clusters
class
FinalizeAppInstallationService
<
BaseHelmService
class
FinalizeAppInstallationService
<
BaseHelmService
def
execute
def
execute
helm
.
delete_installation_pod!
(
app
)
helm
_api
.
delete_installation_pod!
(
app
)
app
.
make_errored!
(
'Installation aborted'
)
if
aborted?
app
.
make_errored!
(
'Installation aborted'
)
if
aborted?
end
end
...
...
app/services/clusters/install_app_service.rb
View file @
64be8d70
...
@@ -4,14 +4,14 @@ module Clusters
...
@@ -4,14 +4,14 @@ module Clusters
return
unless
app
.
scheduled?
return
unless
app
.
scheduled?
begin
begin
helm
.
install
(
app
)
helm_api
.
install
(
app
)
if
app
.
make_installing
if
app
.
make_installing
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
.
perform_in
(
ClusterWaitForAppInstallationWorker
::
INITIAL_INTERVAL
,
app
.
name
,
app
.
id
)
ClusterWaitForAppInstallationWorker
::
INITIAL_INTERVAL
,
app
.
name
,
app
.
id
)
else
else
app
.
make_errored!
(
"Failed to update app record;
#{
app
.
errors
}
"
)
app
.
make_errored!
(
"Failed to update app record;
#{
app
.
errors
}
"
)
end
end
rescue
KubeException
=>
ke
rescue
KubeException
=>
ke
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
app
.
make_errored!
(
"Kubernetes error:
#{
ke
.
message
}
"
)
rescue
StandardError
=>
e
rescue
StandardError
=>
e
...
...
app/workers/concerns/cluster_app.rb
View file @
64be8d70
...
@@ -3,8 +3,9 @@ module ClusterApp
...
@@ -3,8 +3,9 @@ module ClusterApp
included
do
included
do
def
find_app
(
app_name
,
id
)
def
find_app
(
app_name
,
id
)
app
=
Clusters
::
Kubernetes
.
app
(
app_name
).
find
(
id
)
Clusters
::
Applications
.
const_get
(
app_name
.
classify
).
find
(
id
).
try
do
|
app
|
yield
(
app
)
if
block_given?
yield
(
app
)
if
block_given?
end
end
end
end
end
end
end
config/routes/project.rb
View file @
64be8d70
...
@@ -190,6 +190,10 @@ constraints(ProjectUrlConstrainer.new) do
...
@@ -190,6 +190,10 @@ constraints(ProjectUrlConstrainer.new) do
member
do
member
do
get
:status
,
format: :json
get
:status
,
format: :json
scope
'*application'
do
resource
:applications
,
only:
[
:create
]
end
end
end
end
end
...
...
db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb
View file @
64be8d70
class
CreateClustersKubernetesHelmApps
<
ActiveRecord
::
Migration
class
CreateClustersKubernetesHelmApps
<
ActiveRecord
::
Migration
def
change
def
change
create_table
:clusters_
kubernetes_helm_apps
do
|
t
|
create_table
:clusters_
applications_helm
do
|
t
|
t
.
integer
:status
,
null:
false
t
.
references
:cluster
,
null:
false
,
unique:
true
,
foreign_key:
{
on_delete: :cascade
}
t
.
datetime_with_timezone
:created_at
,
null:
false
t
.
datetime_with_timezone
:created_at
,
null:
false
t
.
datetime_with_timezone
:updated_at
,
null:
false
t
.
datetime_with_timezone
:updated_at
,
null:
false
t
.
references
:service
,
index:
true
,
null:
false
,
foreign_key:
{
on_delete: :cascade
}
t
.
integer
:status
,
null:
false
t
.
string
:version
,
null:
false
t
.
string
:version
,
null:
false
t
.
text
:status_reason
t
.
text
:status_reason
end
end
...
...
db/schema.rb
View file @
64be8d70
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201710
17145932
)
do
ActiveRecord
::
Schema
.
define
(
version:
201710
31100710
)
do
# These are extensions that must be enabled in order to support this database
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
enable_extension
"plpgsql"
...
@@ -464,9 +464,7 @@ ActiveRecord::Schema.define(version: 20171017145932) do
...
@@ -464,9 +464,7 @@ ActiveRecord::Schema.define(version: 20171017145932) do
create_table
"cluster_platforms_kubernetes"
,
force: :cascade
do
|
t
|
create_table
"cluster_platforms_kubernetes"
,
force: :cascade
do
|
t
|
t
.
integer
"cluster_id"
,
null:
false
t
.
integer
"cluster_id"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
string
"api_url"
t
.
datetime
"updated_at"
,
null:
false
t
.
text
"api_url"
t
.
text
"ca_cert"
t
.
text
"ca_cert"
t
.
string
"namespace"
t
.
string
"namespace"
t
.
string
"username"
t
.
string
"username"
...
@@ -474,6 +472,8 @@ ActiveRecord::Schema.define(version: 20171017145932) do
...
@@ -474,6 +472,8 @@ ActiveRecord::Schema.define(version: 20171017145932) do
t
.
string
"encrypted_password_iv"
t
.
string
"encrypted_password_iv"
t
.
text
"encrypted_token"
t
.
text
"encrypted_token"
t
.
string
"encrypted_token_iv"
t
.
string
"encrypted_token_iv"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
end
end
add_index
"cluster_platforms_kubernetes"
,
[
"cluster_id"
],
name:
"index_cluster_platforms_kubernetes_on_cluster_id"
,
unique:
true
,
using: :btree
add_index
"cluster_platforms_kubernetes"
,
[
"cluster_id"
],
name:
"index_cluster_platforms_kubernetes_on_cluster_id"
,
unique:
true
,
using: :btree
...
@@ -491,33 +491,39 @@ ActiveRecord::Schema.define(version: 20171017145932) do
...
@@ -491,33 +491,39 @@ ActiveRecord::Schema.define(version: 20171017145932) do
create_table
"cluster_providers_gcp"
,
force: :cascade
do
|
t
|
create_table
"cluster_providers_gcp"
,
force: :cascade
do
|
t
|
t
.
integer
"cluster_id"
,
null:
false
t
.
integer
"cluster_id"
,
null:
false
t
.
integer
"status"
t
.
integer
"status"
t
.
integer
"num_nodes"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
text
"status_reason"
t
.
text
"status_reason"
t
.
string
"gcp_project_id"
,
null:
false
t
.
string
"gcp_project_id"
,
null:
false
t
.
string
"zone"
,
null:
false
t
.
string
"zone"
,
null:
false
t
.
integer
"num_nodes"
,
null:
false
t
.
string
"machine_type"
t
.
string
"machine_type"
t
.
string
"operation_id"
t
.
string
"operation_id"
t
.
string
"endpoint"
t
.
string
"endpoint"
t
.
text
"encrypted_access_token"
t
.
text
"encrypted_access_token"
t
.
string
"encrypted_access_token_iv"
t
.
string
"encrypted_access_token_iv"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
end
end
add_index
"cluster_providers_gcp"
,
[
"cluster_id"
],
name:
"index_cluster_providers_gcp_on_cluster_id"
,
unique:
true
,
using: :btree
add_index
"cluster_providers_gcp"
,
[
"cluster_id"
],
name:
"index_cluster_providers_gcp_on_cluster_id"
,
unique:
true
,
using: :btree
create_table
"clusters"
,
force: :cascade
do
|
t
|
create_table
"clusters"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
,
null:
false
t
.
integer
"user_id"
t
.
integer
"provider_type"
t
.
integer
"platform_type"
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
boolean
"enabled"
,
default:
true
t
.
boolean
"enabled"
,
default:
true
t
.
string
"name"
,
null:
false
t
.
string
"name"
,
null:
false
t
.
integer
"provider_type"
t
.
integer
"platform_type"
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
end
end
add_index
"clusters"
,
[
"enabled"
],
name:
"index_clusters_on_enabled"
,
using: :btree
create_table
"clusters_applications_helm"
,
force: :cascade
do
|
t
|
add_index
"clusters"
,
[
"user_id"
],
name:
"index_clusters_on_user_id"
,
using: :btree
t
.
integer
"cluster_id"
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
integer
"status"
,
null:
false
t
.
string
"version"
,
null:
false
t
.
text
"status_reason"
end
create_table
"container_repositories"
,
force: :cascade
do
|
t
|
create_table
"container_repositories"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
,
null:
false
t
.
integer
"project_id"
,
null:
false
...
@@ -1872,6 +1878,7 @@ ActiveRecord::Schema.define(version: 20171017145932) do
...
@@ -1872,6 +1878,7 @@ ActiveRecord::Schema.define(version: 20171017145932) do
add_foreign_key
"cluster_projects"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"cluster_projects"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"cluster_providers_gcp"
,
"clusters"
,
on_delete: :cascade
add_foreign_key
"cluster_providers_gcp"
,
"clusters"
,
on_delete: :cascade
add_foreign_key
"clusters"
,
"users"
,
on_delete: :nullify
add_foreign_key
"clusters"
,
"users"
,
on_delete: :nullify
add_foreign_key
"clusters_applications_helm"
,
"clusters"
,
on_delete: :cascade
add_foreign_key
"container_repositories"
,
"projects"
add_foreign_key
"container_repositories"
,
"projects"
add_foreign_key
"deploy_keys_projects"
,
"projects"
,
name:
"fk_58a901ca7e"
,
on_delete: :cascade
add_foreign_key
"deploy_keys_projects"
,
"projects"
,
name:
"fk_58a901ca7e"
,
on_delete: :cascade
add_foreign_key
"deployments"
,
"projects"
,
name:
"fk_b9a3851b82"
,
on_delete: :cascade
add_foreign_key
"deployments"
,
"projects"
,
name:
"fk_b9a3851b82"
,
on_delete: :cascade
...
...
spec/models/clusters/kubernetes/helm_app_spec.rb
View file @
64be8d70
require
'rails_helper'
require
'rails_helper'
require_relative
'../kubernetes_spec'
require_relative
'../kubernetes_spec'
RSpec
.
describe
Clusters
::
Kubernetes
::
HelmApp
,
type: :model
do
RSpec
.
describe
Clusters
::
Applications
::
Helm
,
type: :model
do
it_behaves_like
'a registered kubernetes app'
it_behaves_like
'a registered kubernetes app'
it
{
is_expected
.
to
belong_to
(
:kubernetes_service
)
}
it
{
is_expected
.
to
belong_to
(
:kubernetes_service
)
}
...
...
spec/models/clusters/kubernetes_spec.rb
deleted
100644 → 0
View file @
461c385e
require
'rails_helper'
RSpec
.
shared_examples
'a registered kubernetes app'
do
let
(
:name
)
{
described_class
::
NAME
}
it
'can be retrieved with Clusters::Kubernetes.app'
do
expect
(
Clusters
::
Kubernetes
.
app
(
name
)).
to
eq
(
described_class
)
end
end
spec/models/project_services/kubernetes_service_spec.rb
View file @
64be8d70
...
@@ -9,7 +9,6 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
...
@@ -9,7 +9,6 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
describe
'Associations'
do
describe
'Associations'
do
it
{
is_expected
.
to
belong_to
:project
}
it
{
is_expected
.
to
belong_to
:project
}
it
{
is_expected
.
to
have_one
(
:helm_app
)
}
end
end
describe
'Validations'
do
describe
'Validations'
do
...
...
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