summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-10-04 16:04:45 +0900
committerShinya Maeda <shinya@gitlab.com>2017-10-04 16:04:45 +0900
commit20abcbffae71f8177223f2b978c8ad56102da271 (patch)
tree629fb9a3af6015233bac78d19ecf2b01bb52bf84
parentc6d53250de7f439bc25740913d85ada6e3b2fed4 (diff)
downloadgitlab-ce-20abcbffae71f8177223f2b978c8ad56102da271.tar.gz
Add google_api to TOP_LEVEL_ROUTES. Import/Export model failure fix. Fix static analysys.
-rw-r--r--app/controllers/projects/clusters_controller.rb5
-rw-r--r--app/models/gcp/cluster.rb2
-rw-r--r--app/services/ci/fetch_gcp_operation_service.rb2
-rw-r--r--app/services/ci/finalize_cluster_creation_service.rb2
-rw-r--r--app/services/ci/provision_cluster_service.rb11
-rw-r--r--lib/gitlab/import_export/import_export.yml1
-rw-r--r--lib/gitlab/import_export/relation_factory.rb1
-rw-r--r--lib/gitlab/path_regex.rb1
-rw-r--r--lib/google_api/auth.rb2
-rw-r--r--lib/google_api/cloud_platform/client.rb15
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml5
11 files changed, 26 insertions, 21 deletions
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb
index 8d07f695e78..5dbabaf7813 100644
--- a/app/controllers/projects/clusters_controller.rb
+++ b/app/controllers/projects/clusters_controller.rb
@@ -9,9 +9,8 @@ class Projects::ClustersController < Projects::ApplicationController
def login
begin
@authorize_url = GoogleApi::CloudPlatform::Client.new(
- nil, callback_google_api_authorizations_url,
- state: namespace_project_clusters_url.to_s
- ).authorize_url
+ nil, callback_google_api_authorizations_url,
+ state: namespace_project_clusters_url.to_s).authorize_url
rescue GoogleApi::Auth::ConfigMissingError
# no-op
end
diff --git a/app/models/gcp/cluster.rb b/app/models/gcp/cluster.rb
index 74644207afd..81af8161b8f 100644
--- a/app/models/gcp/cluster.rb
+++ b/app/models/gcp/cluster.rb
@@ -48,7 +48,7 @@ module Gcp
validates :gcp_cluster_zone, presence: true
validates :gcp_cluster_size, presence: true,
- numericality: { only_integer: true, greater_than: 0 }
+ numericality: { only_integer: true, greater_than: 0 }
validates :project_namespace,
allow_blank: true,
diff --git a/app/services/ci/fetch_gcp_operation_service.rb b/app/services/ci/fetch_gcp_operation_service.rb
index 24892d1ab47..415afaf901f 100644
--- a/app/services/ci/fetch_gcp_operation_service.rb
+++ b/app/services/ci/fetch_gcp_operation_service.rb
@@ -1,7 +1,7 @@
module Ci
class FetchGcpOperationService
def execute(cluster)
- api_client =
+ api_client =
GoogleApi::CloudPlatform::Client.new(cluster.gcp_token, nil)
operation = api_client.projects_zones_operations(
diff --git a/app/services/ci/finalize_cluster_creation_service.rb b/app/services/ci/finalize_cluster_creation_service.rb
index 03cd761deb7..a469acc0467 100644
--- a/app/services/ci/finalize_cluster_creation_service.rb
+++ b/app/services/ci/finalize_cluster_creation_service.rb
@@ -1,7 +1,7 @@
module Ci
class FinalizeClusterCreationService
def execute(cluster)
- api_client =
+ api_client =
GoogleApi::CloudPlatform::Client.new(cluster.gcp_token, nil)
begin
diff --git a/app/services/ci/provision_cluster_service.rb b/app/services/ci/provision_cluster_service.rb
index 3e7e565b361..6fcbdd8b483 100644
--- a/app/services/ci/provision_cluster_service.rb
+++ b/app/services/ci/provision_cluster_service.rb
@@ -6,12 +6,11 @@ module Ci
begin
operation = api_client.projects_zones_clusters_create(
- cluster.gcp_project_id,
- cluster.gcp_cluster_zone,
- cluster.gcp_cluster_name,
- cluster.gcp_cluster_size,
- machine_type: cluster.gcp_machine_type
- )
+ cluster.gcp_project_id,
+ cluster.gcp_cluster_zone,
+ cluster.gcp_cluster_name,
+ cluster.gcp_cluster_size,
+ machine_type: cluster.gcp_machine_type)
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
return cluster.errored!("Failed to request to CloudPlatform; #{e.message}")
end
diff --git a/lib/gitlab/import_export/import_export.yml b/lib/gitlab/import_export/import_export.yml
index 2171c6c7bbb..a99183fe669 100644
--- a/lib/gitlab/import_export/import_export.yml
+++ b/lib/gitlab/import_export/import_export.yml
@@ -53,6 +53,7 @@ project_tree:
- :auto_devops
- :triggers
- :pipeline_schedules
+ - :clusters
- :services
- :hooks
- protected_branches:
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index 380b336395d..5938b927ff0 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -8,6 +8,7 @@ module Gitlab
triggers: 'Ci::Trigger',
pipeline_schedules: 'Ci::PipelineSchedule',
builds: 'Ci::Build',
+ clusters: 'Gcp::Cluster',
hooks: 'ProjectHook',
merge_access_levels: 'ProtectedBranch::MergeAccessLevel',
push_access_levels: 'ProtectedBranch::PushAccessLevel',
diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb
index 7c02c9c5c48..e68160c8faf 100644
--- a/lib/gitlab/path_regex.rb
+++ b/lib/gitlab/path_regex.rb
@@ -33,6 +33,7 @@ module Gitlab
explore
favicon.ico
files
+ google_api
groups
health_check
help
diff --git a/lib/google_api/auth.rb b/lib/google_api/auth.rb
index 8c962af51d7..99a82c849e0 100644
--- a/lib/google_api/auth.rb
+++ b/lib/google_api/auth.rb
@@ -46,7 +46,7 @@ module GoogleApi
config.app_id,
config.app_secret,
site: 'https://accounts.google.com',
- token_url: '/o/oauth2/token',
+ token_url: '/o/oauth2/token',
authorize_url: '/o/oauth2/auth'
)
end
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index f50c99578bc..d13e3290cf5 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -44,16 +44,15 @@ module GoogleApi
service.authorization = access_token
request_body = Google::Apis::ContainerV1::CreateClusterRequest.new(
- {
- "cluster": {
- "name": cluster_name,
- "initial_node_count": cluster_size,
- "node_config": {
- "machine_type": machine_type # Default 3.75 GB, if ommit
- }
+ {
+ "cluster": {
+ "name": cluster_name,
+ "initial_node_count": cluster_size,
+ "node_config": {
+ "machine_type": machine_type
}
}
- )
+ } )
service.create_cluster(project_id, zone, request_body)
end
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 3fb8edeb701..39fbd79372e 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -147,6 +147,10 @@ deploy_keys:
- user
- deploy_keys_projects
- projects
+clusters:
+- project
+- user
+- service
services:
- project
- service_hook
@@ -177,6 +181,7 @@ project:
- tag_taggings
- tags
- chat_services
+- cluster
- creator
- group
- namespace