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
1
Merge Requests
1
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
nexedi
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
Hide 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
message:
Gitlab
::
Regex
.
kubernetes_namespace_regex_message
}
# TODO: when cluster.gcp? skip validation when create a record
# TODO: when cluster.user? validates always
# validates :api_url, url: true, presence: true
# validates :token, presence: true
validates
:api_url
,
url:
true
,
presence:
true
validates
:token
,
presence:
true
after_save
:clear_reactive_cache!
...
...
app/services/clusters/create_service.rb
View file @
6571efb6
...
...
@@ -2,6 +2,9 @@ module Clusters
class
CreateService
<
BaseService
attr_reader
:access_token
TEMPOLARY_API_URL
=
'http://tempolary_api_url'
.
freeze
TEMPOLARY_TOKEN
=
'tempolary_token'
.
freeze
def
execute
(
access_token
)
@access_token
=
access_token
...
...
@@ -28,8 +31,13 @@ module Clusters
def
cluster_params
return
@cluster_params
if
defined?
(
@cluster_params
)
params
[
:provider_gcp_attributes
].
try
do
|
h
|
h
[
:access_token
]
=
access_token
params
[
:provider_gcp_attributes
].
try
do
|
provider
|
provider
[
:access_token
]
=
access_token
params
[
:platform_kubernetes_attributes
].
try
do
|
platform
|
platform
[
:api_url
]
=
TEMPOLARY_API_URL
platform
[
:token
]
=
TEMPOLARY_TOKEN
end
end
@cluster_params
=
params
.
merge
(
user:
current_user
)
...
...
db/migrate/20171013094327_create_new_clusters_architectures.rb
View file @
6571efb6
...
...
@@ -22,7 +22,7 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration
t
.
datetime_with_timezone
:created_at
,
null:
false
t
.
datetime_with_timezone
:updated_at
,
null:
false
end
create_table
:cluster_platforms_kubernetes
do
|
t
|
t
.
references
:cluster
,
null:
false
,
index:
{
unique:
true
},
foreign_key:
{
on_delete: :cascade
}
...
...
lib/gitlab/import_export/relation_factory.rb
View file @
6571efb6
...
...
@@ -8,8 +8,8 @@ module Gitlab
triggers:
'Ci::Trigger'
,
pipeline_schedules:
'Ci::PipelineSchedule'
,
builds:
'Ci::Build'
,
cluster:
'
Gcp
::Cluster'
,
clusters:
'
Gcp
::Cluster'
,
cluster:
'
Clusters
::Cluster'
,
clusters:
'
Clusters
::Cluster'
,
hooks:
'ProjectHook'
,
merge_access_levels:
'ProtectedBranch::MergeAccessLevel'
,
push_access_levels:
'ProtectedBranch::PushAccessLevel'
,
...
...
lib/gitlab/usage_data.rb
View file @
6571efb6
...
...
@@ -48,9 +48,9 @@ module Gitlab
deploy_keys:
DeployKey
.
count
,
deployments:
Deployment
.
count
,
environments:
::
Environment
.
count
,
gcp_clusters:
::
Gcp
::
Cluster
.
count
,
gcp_clusters_enabled:
::
Gcp
::
Cluster
.
enabled
.
count
,
gcp_clusters_disabled:
::
Gcp
::
Cluster
.
disabled
.
count
,
clusters:
::
Clusters
::
Cluster
.
count
,
clusters_enabled:
::
Clusters
::
Cluster
.
enabled
.
count
,
clusters_disabled:
::
Clusters
::
Cluster
.
disabled
.
count
,
in_review_folder:
::
Environment
.
in_review_folder
.
count
,
groups:
Group
.
count
,
issues:
Issue
.
count
,
...
...
spec/controllers/projects/clusters_controller_spec.rb
View file @
6571efb6
...
...
@@ -72,7 +72,7 @@ describe Projects::ClustersController do
go
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
...
...
@@ -175,7 +175,7 @@ describe Projects::ClustersController do
platform_type: :kubernetes
,
provider_type: :gcp
,
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:
-
deleted_at
-
created_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:
-
id
-
project_id
...
...
spec/lib/gitlab/usage_data_spec.rb
View file @
6571efb6
...
...
@@ -60,9 +60,9 @@ describe Gitlab::UsageData do
deploy_keys
deployments
environments
gcp_
clusters
gcp_
clusters_enabled
gcp_
clusters_disabled
clusters
clusters_enabled
clusters_disabled
in_review_folder
groups
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
end
end
#
context 'when validates api_url' do
#
let(:kubernetes) { build(:platform_kubernetes, :configured) }
context
'when validates api_url'
do
let
(
:kubernetes
)
{
build
(
:platform_kubernetes
,
:configured
)
}
#
before do
#
kubernetes.api_url = api_url
#
end
before
do
kubernetes
.
api_url
=
api_url
end
#
context 'when api_url is invalid url' do
#
let(:api_url) { '!!!!!!' }
context
'when api_url is invalid url'
do
let
(
:api_url
)
{
'!!!!!!'
}
#
it { expect(kubernetes.save).to be_falsey }
#
end
it
{
expect
(
kubernetes
.
save
).
to
be_falsey
}
end
#
context 'when api_url is nil' do
#
let(:api_url) { nil }
context
'when api_url is nil'
do
let
(
:api_url
)
{
nil
}
#
it { expect(kubernetes.save).to be_falsey }
#
end
it
{
expect
(
kubernetes
.
save
).
to
be_falsey
}
end
#
context 'when api_url is valid url' do
#
let(:api_url) { 'https://111.111.111.111' }
context
'when api_url is valid url'
do
let
(
:api_url
)
{
'https://111.111.111.111'
}
#
it { expect(kubernetes.save).to be_truthy }
#
end
#
end
it
{
expect
(
kubernetes
.
save
).
to
be_truthy
}
end
end
#
context 'when validates token' do
#
let(:kubernetes) { build(:platform_kubernetes, :configured) }
context
'when validates token'
do
let
(
:kubernetes
)
{
build
(
:platform_kubernetes
,
:configured
)
}
#
before do
#
kubernetes.token = token
#
end
before
do
kubernetes
.
token
=
token
end
#
context 'when token is nil' do
#
let(:token) { nil }
context
'when token is nil'
do
let
(
:token
)
{
nil
}
#
it { expect(kubernetes.save).to be_falsey }
#
end
#
end
it
{
expect
(
kubernetes
.
save
).
to
be_falsey
}
end
end
end
describe
'#actual_namespace'
do
...
...
spec/services/clusters/create_service_spec.rb
View file @
6571efb6
...
...
@@ -42,7 +42,8 @@ describe Clusters::CreateService do
expect
(
result
.
provider
.
machine_type
).
to
eq
(
'machine_type-a'
)
expect
(
result
.
provider
.
access_token
).
to
eq
(
access_token
)
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
...
...
@@ -99,7 +100,6 @@ describe Clusters::CreateService do
expect
(
result
.
project
).
to
eq
(
project
)
expect
(
result
.
provider
).
to
be_nil
expect
(
result
.
platform
.
namespace
).
to
eq
(
'custom-namespace'
)
expect
(
result
.
platform
.
valid?
).
to
be_truthy
end
end
...
...
spec/services/clusters/gcp/finalize_creation_service_spec.rb
View file @
6571efb6
...
...
@@ -40,7 +40,7 @@ describe Clusters::Gcp::FinalizeCreationService do
{
endpoint:
endpoint
,
username:
username
,
password:
password
,
password:
password
}
)
...
...
spec/support/google_api/cloud_platform_helpers.rb
View file @
6571efb6
...
...
@@ -61,6 +61,11 @@ module GoogleApi
Base64
.
encode64
(
File
.
read
(
pem_file
))
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
)
{
"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