summaryrefslogtreecommitdiff
path: root/lib/google_api
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-09-23 00:06:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-09-23 00:06:29 +0000
commit98dbb0a488d7b0093f352938210d9578b0f7a8a6 (patch)
tree25654204f8de2672556a696199fa209b8f8ff1b3 /lib/google_api
parent9ce26d3dfdf4194f32c470cd3102b4376a53ef2f (diff)
downloadgitlab-ce-98dbb0a488d7b0093f352938210d9578b0f7a8a6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/google_api')
-rw-r--r--lib/google_api/cloud_platform/client.rb52
1 files changed, 30 insertions, 22 deletions
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index 9f01a3f97ce..eaf94708282 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -2,6 +2,7 @@
require 'google/apis/compute_v1'
require 'google/apis/container_v1'
+require 'google/apis/container_v1beta1'
require 'google/apis/cloudbilling_v1'
require 'google/apis/cloudresourcemanager_v1'
@@ -53,30 +54,13 @@ module GoogleApi
service.get_zone_cluster(project_id, zone, cluster_id, options: user_agent_header)
end
- def projects_zones_clusters_create(project_id, zone, cluster_name, cluster_size, machine_type:, legacy_abac:)
- service = Google::Apis::ContainerV1::ContainerService.new
+ def projects_zones_clusters_create(project_id, zone, cluster_name, cluster_size, machine_type:, legacy_abac:, enable_addons: [])
+ service = Google::Apis::ContainerV1beta1::ContainerService.new
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
- },
- "master_auth": {
- "username": CLUSTER_MASTER_AUTH_USERNAME,
- "client_certificate_config": {
- issue_client_certificate: true
- }
- },
- "legacy_abac": {
- "enabled": legacy_abac
- }
- }
- }
- )
+ cluster_options = make_cluster_options(cluster_name, cluster_size, machine_type, legacy_abac, enable_addons)
+
+ request_body = Google::Apis::ContainerV1beta1::CreateClusterRequest.new(cluster_options)
service.create_cluster(project_id, zone, request_body, options: user_agent_header)
end
@@ -95,6 +79,30 @@ module GoogleApi
private
+ def make_cluster_options(cluster_name, cluster_size, machine_type, legacy_abac, enable_addons)
+ {
+ cluster: {
+ name: cluster_name,
+ initial_node_count: cluster_size,
+ node_config: {
+ machine_type: machine_type
+ },
+ master_auth: {
+ username: CLUSTER_MASTER_AUTH_USERNAME,
+ client_certificate_config: {
+ issue_client_certificate: true
+ }
+ },
+ legacy_abac: {
+ enabled: legacy_abac
+ },
+ addons_config: enable_addons.each_with_object({}) do |addon, hash|
+ hash[addon] = { disabled: false }
+ end
+ }
+ }
+ end
+
def token_life_time(expires_at)
DateTime.strptime(expires_at, '%s').to_time.utc - Time.now.utc
end