Commit 20abcbff authored by Shinya Maeda's avatar Shinya Maeda

Add google_api to TOP_LEVEL_ROUTES. Import/Export model failure fix. Fix static analysys.

parent c6d53250
......@@ -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
......
......@@ -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,
......
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(
......
module Ci
class FinalizeClusterCreationService
def execute(cluster)
api_client =
api_client =
GoogleApi::CloudPlatform::Client.new(cluster.gcp_token, nil)
begin
......
......@@ -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
......
......@@ -53,6 +53,7 @@ project_tree:
- :auto_devops
- :triggers
- :pipeline_schedules
- :clusters
- :services
- :hooks
- protected_branches:
......
......@@ -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',
......
......@@ -33,6 +33,7 @@ module Gitlab
explore
favicon.ico
files
google_api
groups
health_check
help
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment