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
Jérome Perrin
gitlab-ce
Commits
6571efb6
Commit
6571efb6
authored
Nov 01, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spec. Fix usage ping. Fix warnings by adding new models and attributes.
parent
ef3ebed6
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
102 additions
and
48 deletions
+102
-48
app/models/clusters/platforms/kubernetes.rb
app/models/clusters/platforms/kubernetes.rb
+2
-4
app/services/clusters/create_service.rb
app/services/clusters/create_service.rb
+10
-2
db/migrate/20171013094327_create_new_clusters_architectures.rb
...grate/20171013094327_create_new_clusters_architectures.rb
+1
-1
lib/gitlab/import_export/relation_factory.rb
lib/gitlab/import_export/relation_factory.rb
+2
-2
lib/gitlab/usage_data.rb
lib/gitlab/usage_data.rb
+3
-3
spec/controllers/projects/clusters_controller_spec.rb
spec/controllers/projects/clusters_controller_spec.rb
+2
-2
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+43
-0
spec/lib/gitlab/usage_data_spec.rb
spec/lib/gitlab/usage_data_spec.rb
+3
-3
spec/models/clusters/platforms/kubernetes_spec.rb
spec/models/clusters/platforms/kubernetes_spec.rb
+28
-28
spec/services/clusters/create_service_spec.rb
spec/services/clusters/create_service_spec.rb
+2
-2
spec/services/clusters/gcp/finalize_creation_service_spec.rb
spec/services/clusters/gcp/finalize_creation_service_spec.rb
+1
-1
spec/support/google_api/cloud_platform_helpers.rb
spec/support/google_api/cloud_platform_helpers.rb
+5
-0
No files found.
app/models/clusters/platforms/kubernetes.rb
View file @
6571efb6
...
@@ -30,10 +30,8 @@ module Clusters
...
@@ -30,10 +30,8 @@ module Clusters
message:
Gitlab
::
Regex
.
kubernetes_namespace_regex_message
message:
Gitlab
::
Regex
.
kubernetes_namespace_regex_message
}
}
# TODO: when cluster.gcp? skip validation when create a record
validates
:api_url
,
url:
true
,
presence:
true
# TODO: when cluster.user? validates always
validates
:token
,
presence:
true
# validates :api_url, url: true, presence: true
# validates :token, presence: true
after_save
:clear_reactive_cache!
after_save
:clear_reactive_cache!
...
...
app/services/clusters/create_service.rb
View file @
6571efb6
...
@@ -2,6 +2,9 @@ module Clusters
...
@@ -2,6 +2,9 @@ module Clusters
class
CreateService
<
BaseService
class
CreateService
<
BaseService
attr_reader
:access_token
attr_reader
:access_token
TEMPOLARY_API_URL
=
'http://tempolary_api_url'
.
freeze
TEMPOLARY_TOKEN
=
'tempolary_token'
.
freeze
def
execute
(
access_token
)
def
execute
(
access_token
)
@access_token
=
access_token
@access_token
=
access_token
...
@@ -28,8 +31,13 @@ module Clusters
...
@@ -28,8 +31,13 @@ module Clusters
def
cluster_params
def
cluster_params
return
@cluster_params
if
defined?
(
@cluster_params
)
return
@cluster_params
if
defined?
(
@cluster_params
)
params
[
:provider_gcp_attributes
].
try
do
|
h
|
params
[
:provider_gcp_attributes
].
try
do
|
provider
|
h
[
:access_token
]
=
access_token
provider
[
:access_token
]
=
access_token
params
[
:platform_kubernetes_attributes
].
try
do
|
platform
|
platform
[
:api_url
]
=
TEMPOLARY_API_URL
platform
[
:token
]
=
TEMPOLARY_TOKEN
end
end
end
@cluster_params
=
params
.
merge
(
user:
current_user
)
@cluster_params
=
params
.
merge
(
user:
current_user
)
...
...
db/migrate/20171013094327_create_new_clusters_architectures.rb
View file @
6571efb6
lib/gitlab/import_export/relation_factory.rb
View file @
6571efb6
...
@@ -8,8 +8,8 @@ module Gitlab
...
@@ -8,8 +8,8 @@ module Gitlab
triggers:
'Ci::Trigger'
,
triggers:
'Ci::Trigger'
,
pipeline_schedules:
'Ci::PipelineSchedule'
,
pipeline_schedules:
'Ci::PipelineSchedule'
,
builds:
'Ci::Build'
,
builds:
'Ci::Build'
,
cluster:
'
Gcp
::Cluster'
,
cluster:
'
Clusters
::Cluster'
,
clusters:
'
Gcp
::Cluster'
,
clusters:
'
Clusters
::Cluster'
,
hooks:
'ProjectHook'
,
hooks:
'ProjectHook'
,
merge_access_levels:
'ProtectedBranch::MergeAccessLevel'
,
merge_access_levels:
'ProtectedBranch::MergeAccessLevel'
,
push_access_levels:
'ProtectedBranch::PushAccessLevel'
,
push_access_levels:
'ProtectedBranch::PushAccessLevel'
,
...
...
lib/gitlab/usage_data.rb
View file @
6571efb6
...
@@ -48,9 +48,9 @@ module Gitlab
...
@@ -48,9 +48,9 @@ module Gitlab
deploy_keys:
DeployKey
.
count
,
deploy_keys:
DeployKey
.
count
,
deployments:
Deployment
.
count
,
deployments:
Deployment
.
count
,
environments:
::
Environment
.
count
,
environments:
::
Environment
.
count
,
gcp_clusters:
::
Gcp
::
Cluster
.
count
,
clusters:
::
Clusters
::
Cluster
.
count
,
gcp_clusters_enabled:
::
Gcp
::
Cluster
.
enabled
.
count
,
clusters_enabled:
::
Clusters
::
Cluster
.
enabled
.
count
,
gcp_clusters_disabled:
::
Gcp
::
Cluster
.
disabled
.
count
,
clusters_disabled:
::
Clusters
::
Cluster
.
disabled
.
count
,
in_review_folder:
::
Environment
.
in_review_folder
.
count
,
in_review_folder:
::
Environment
.
in_review_folder
.
count
,
groups:
Group
.
count
,
groups:
Group
.
count
,
issues:
Issue
.
count
,
issues:
Issue
.
count
,
...
...
spec/controllers/projects/clusters_controller_spec.rb
View file @
6571efb6
...
@@ -72,7 +72,7 @@ describe Projects::ClustersController do
...
@@ -72,7 +72,7 @@ describe Projects::ClustersController do
go
go
expect
(
assigns
(
:authorize_url
)).
to
include
(
key
)
expect
(
assigns
(
:authorize_url
)).
to
include
(
key
)
expect
(
session
[
session_key_for_redirect_uri
]).
to
eq
(
namespace_project_clusters_url
(
project
.
namespace
,
project
))
expect
(
session
[
session_key_for_redirect_uri
]).
to
eq
(
project_clusters_url
(
project
))
end
end
end
end
...
@@ -175,7 +175,7 @@ describe Projects::ClustersController do
...
@@ -175,7 +175,7 @@ describe Projects::ClustersController do
platform_type: :kubernetes
,
platform_type: :kubernetes
,
provider_type: :gcp
,
provider_type: :gcp
,
provider_gcp_attributes:
{
provider_gcp_attributes:
{
gcp_project_id:
'111'
,
gcp_project_id:
'111'
}
}
}
}
}
}
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
6571efb6
...
@@ -313,6 +313,49 @@ Ci::PipelineSchedule:
...
@@ -313,6 +313,49 @@ Ci::PipelineSchedule:
-
deleted_at
-
deleted_at
-
created_at
-
created_at
-
updated_at
-
updated_at
Clusters::Cluster:
-
id
-
user_id
-
enabled
-
name
-
provider_type
-
platform_type
-
created_at
-
updated_at
Clusters::Project:
-
id
-
project_id
-
cluster_id
-
created_at
-
updated_at
Clusters::Providers::Gcp:
-
id
-
cluster_id
-
status
-
status_reason
-
gcp_project_id
-
zone
-
num_nodes
-
machine_type
-
operation_id
-
endpoint
-
encrypted_access_token
-
encrypted_access_token_iv
-
created_at
-
updated_at
Clusters::Platforms::Kubernetes:
-
id
-
cluster_id
-
api_url
-
ca_cert
-
namespace
-
username
-
encrypted_password
-
encrypted_password_iv
-
encrypted_token
-
encrypted_token_iv
-
created_at
-
updated_at
Gcp::Cluster:
Gcp::Cluster:
-
id
-
id
-
project_id
-
project_id
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
6571efb6
...
@@ -60,9 +60,9 @@ describe Gitlab::UsageData do
...
@@ -60,9 +60,9 @@ describe Gitlab::UsageData do
deploy_keys
deploy_keys
deployments
deployments
environments
environments
gcp_
clusters
clusters
gcp_
clusters_enabled
clusters_enabled
gcp_
clusters_disabled
clusters_disabled
in_review_folder
in_review_folder
groups
groups
issues
issues
...
...
spec/models/clusters/platforms/kubernetes_spec.rb
View file @
6571efb6
...
@@ -51,45 +51,45 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
...
@@ -51,45 +51,45 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
end
end
#
context 'when validates api_url' do
context
'when validates api_url'
do
#
let(:kubernetes) { build(:platform_kubernetes, :configured) }
let
(
:kubernetes
)
{
build
(
:platform_kubernetes
,
:configured
)
}
#
before do
before
do
#
kubernetes.api_url = api_url
kubernetes
.
api_url
=
api_url
#
end
end
#
context 'when api_url is invalid url' do
context
'when api_url is invalid url'
do
#
let(:api_url) { '!!!!!!' }
let
(
:api_url
)
{
'!!!!!!'
}
#
it { expect(kubernetes.save).to be_falsey }
it
{
expect
(
kubernetes
.
save
).
to
be_falsey
}
#
end
end
#
context 'when api_url is nil' do
context
'when api_url is nil'
do
#
let(:api_url) { nil }
let
(
:api_url
)
{
nil
}
#
it { expect(kubernetes.save).to be_falsey }
it
{
expect
(
kubernetes
.
save
).
to
be_falsey
}
#
end
end
#
context 'when api_url is valid url' do
context
'when api_url is valid url'
do
#
let(:api_url) { 'https://111.111.111.111' }
let
(
:api_url
)
{
'https://111.111.111.111'
}
#
it { expect(kubernetes.save).to be_truthy }
it
{
expect
(
kubernetes
.
save
).
to
be_truthy
}
#
end
end
#
end
end
#
context 'when validates token' do
context
'when validates token'
do
#
let(:kubernetes) { build(:platform_kubernetes, :configured) }
let
(
:kubernetes
)
{
build
(
:platform_kubernetes
,
:configured
)
}
#
before do
before
do
#
kubernetes.token = token
kubernetes
.
token
=
token
#
end
end
#
context 'when token is nil' do
context
'when token is nil'
do
#
let(:token) { nil }
let
(
:token
)
{
nil
}
#
it { expect(kubernetes.save).to be_falsey }
it
{
expect
(
kubernetes
.
save
).
to
be_falsey
}
#
end
end
#
end
end
end
end
describe
'#actual_namespace'
do
describe
'#actual_namespace'
do
...
...
spec/services/clusters/create_service_spec.rb
View file @
6571efb6
...
@@ -42,7 +42,8 @@ describe Clusters::CreateService do
...
@@ -42,7 +42,8 @@ describe Clusters::CreateService do
expect
(
result
.
provider
.
machine_type
).
to
eq
(
'machine_type-a'
)
expect
(
result
.
provider
.
machine_type
).
to
eq
(
'machine_type-a'
)
expect
(
result
.
provider
.
access_token
).
to
eq
(
access_token
)
expect
(
result
.
provider
.
access_token
).
to
eq
(
access_token
)
expect
(
result
.
platform
.
namespace
).
to
eq
(
'custom-namespace'
)
expect
(
result
.
platform
.
namespace
).
to
eq
(
'custom-namespace'
)
expect
(
result
.
platform
.
valid?
).
to
be_falsey
expect
(
result
.
platform
.
api_url
).
to
eq
(
Clusters
::
CreateService
::
TEMPOLARY_API_URL
)
expect
(
result
.
platform
.
token
).
to
eq
(
Clusters
::
CreateService
::
TEMPOLARY_TOKEN
)
end
end
end
end
...
@@ -99,7 +100,6 @@ describe Clusters::CreateService do
...
@@ -99,7 +100,6 @@ describe Clusters::CreateService do
expect
(
result
.
project
).
to
eq
(
project
)
expect
(
result
.
project
).
to
eq
(
project
)
expect
(
result
.
provider
).
to
be_nil
expect
(
result
.
provider
).
to
be_nil
expect
(
result
.
platform
.
namespace
).
to
eq
(
'custom-namespace'
)
expect
(
result
.
platform
.
namespace
).
to
eq
(
'custom-namespace'
)
expect
(
result
.
platform
.
valid?
).
to
be_truthy
end
end
end
end
...
...
spec/services/clusters/gcp/finalize_creation_service_spec.rb
View file @
6571efb6
...
@@ -40,7 +40,7 @@ describe Clusters::Gcp::FinalizeCreationService do
...
@@ -40,7 +40,7 @@ describe Clusters::Gcp::FinalizeCreationService do
{
{
endpoint:
endpoint
,
endpoint:
endpoint
,
username:
username
,
username:
username
,
password:
password
,
password:
password
}
}
)
)
...
...
spec/support/google_api/cloud_platform_helpers.rb
View file @
6571efb6
...
@@ -61,6 +61,11 @@ module GoogleApi
...
@@ -61,6 +61,11 @@ module GoogleApi
Base64
.
encode64
(
File
.
read
(
pem_file
))
Base64
.
encode64
(
File
.
read
(
pem_file
))
end
end
##
# gcloud container clusters create
# https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters/create
# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/PerceivedComplexity
def
cloud_platform_cluster_body
(
**
options
)
def
cloud_platform_cluster_body
(
**
options
)
{
{
"name"
:
options
[
:name
]
||
'string'
,
"name"
:
options
[
:name
]
||
'string'
,
...
...
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