diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-10-03 23:44:06 +0900 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-10-03 23:44:06 +0900 |
commit | 6b7889f750c56962c0674467c3fbfd7976b9b44f (patch) | |
tree | 1491f42c332465194630417afc138010e23fc163 /lib/google_api | |
parent | fd6776214abb2603ce2fb5dfb078229f0a0195e5 (diff) | |
download | gitlab-ce-6b7889f750c56962c0674467c3fbfd7976b9b44f.tar.gz |
Implement Policy. Use show instead of edit. Chnage db column. fix comments. dry up workers
Diffstat (limited to 'lib/google_api')
-rw-r--r-- | lib/google_api/cloud_platform/client.rb | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb index aa85fcdabef..f50c99578bc 100644 --- a/lib/google_api/cloud_platform/client.rb +++ b/lib/google_api/cloud_platform/client.rb @@ -3,7 +3,8 @@ require 'google/apis/container_v1' module GoogleApi module CloudPlatform class Client < GoogleApi::Auth - DEFAULT_MACHINE_TYPE = 'n1-standard-1' + DEFAULT_MACHINE_TYPE = 'n1-standard-1'.freeze + SCOPE = 'https://www.googleapis.com/auth/cloud-platform'.freeze class << self def session_key_for_token @@ -16,7 +17,7 @@ module GoogleApi end def scope - 'https://www.googleapis.com/auth/cloud-platform' + SCOPE end def validate_token(expires_at) @@ -35,14 +36,7 @@ module GoogleApi service = Google::Apis::ContainerV1::ContainerService.new service.authorization = access_token - begin - cluster = service.get_zone_cluster(project_id, zone, cluster_id) - rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e - return e - end - - puts "#{self.class.name} - #{__callee__}: cluster: #{cluster.inspect}" - cluster + service.get_zone_cluster(project_id, zone, cluster_id) end def projects_zones_clusters_create(project_id, zone, cluster_name, cluster_size, machine_type:) @@ -61,28 +55,14 @@ module GoogleApi } ) - begin - operation = service.create_cluster(project_id, zone, request_body) - rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e - return e - end - - puts "#{self.class.name} - #{__callee__}: operation: #{operation.inspect}" - operation + service.create_cluster(project_id, zone, request_body) end def projects_zones_operations(project_id, zone, operation_id) service = Google::Apis::ContainerV1::ContainerService.new service.authorization = access_token - begin - operation = service.get_zone_operation(project_id, zone, operation_id) - rescue Google::Apis::ClientError, Google::Apis::AuthorizationError => e - return e - end - - puts "#{self.class.name} - #{__callee__}: operation: #{operation.inspect}" - operation + service.get_zone_operation(project_id, zone, operation_id) end def parse_operation_id(self_link) |