summaryrefslogtreecommitdiff
path: root/lib/google_api
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-09-29 00:08:11 +0900
committerShinya Maeda <shinya@gitlab.com>2017-09-29 00:08:11 +0900
commitbda1b0a878205ac99bf10c0b4f0e63f2d4e3a25f (patch)
tree09d5318034ed17966be0fa74a7a4e07fde0b2c05 /lib/google_api
parentfabc359e77c39aea86f0eaa9f19b17b2a609dd99 (diff)
downloadgitlab-ce-bda1b0a878205ac99bf10c0b4f0e63f2d4e3a25f.tar.gz
Databse foreing key, index, encrypt password. Use short path. Improve error handling. Polish.
Diffstat (limited to 'lib/google_api')
-rw-r--r--lib/google_api/cloud_platform/client.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index 61176e39464..0bc306a24e6 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -13,11 +13,22 @@ module GoogleApi
'https://www.googleapis.com/auth/cloud-platform'
end
+ ##
+ # Exception
+ # Google::Apis::ClientError:
+ # Google::Apis::AuthorizationError:
+ ##
+
def projects_zones_clusters_get(project_id, zone, cluster_id)
service = Google::Apis::ContainerV1::ContainerService.new
service.authorization = access_token
- cluster = service.get_zone_cluster(project_id, zone, cluster_id)
+ begin
+ cluster = service.get_zone_cluster(project_id, zone, cluster_id)
+ rescue Google::Apis::ClientError, Google::Apis::AuthorizationError => e
+ return nil
+ end
+
puts "#{self.class.name} - #{__callee__}: cluster: #{cluster.inspect}"
cluster
end
@@ -40,9 +51,9 @@ module GoogleApi
begin
operation = service.create_cluster(project_id, zone, request_body)
rescue Google::Apis::ClientError, Google::Apis::AuthorizationError => e
- puts "#{self.class.name} - #{__callee__}: Could not create cluster #{cluster_name}: #{e}"
- # TODO: Error
+ return nil
end
+
puts "#{self.class.name} - #{__callee__}: operation: #{operation.inspect}"
operation
end
@@ -51,7 +62,12 @@ module GoogleApi
service = Google::Apis::ContainerV1::ContainerService.new
service.authorization = access_token
- operation = service.get_zone_operation(project_id, zone, operation_id)
+ begin
+ operation = service.get_zone_operation(project_id, zone, operation_id)
+ rescue Google::Apis::ClientError, Google::Apis::AuthorizationError => e
+ return nil
+ end
+
puts "#{self.class.name} - #{__callee__}: operation: #{operation.inspect}"
operation
end