diff options
author | Matt Kasa <mkasa@gitlab.com> | 2019-09-11 23:36:24 -0700 |
---|---|---|
committer | Matt Kasa <mkasa@gitlab.com> | 2019-09-11 23:36:24 -0700 |
commit | d4fe18516f18e585a100eda5442eab7a96b859a2 (patch) | |
tree | 3ea49dc787838e716ed13969e31b7e467989eaf5 | |
parent | 09aa15fbd4760ce5a5c87bf405a470b2d709615b (diff) | |
download | gitlab-ce-d4fe18516f18e585a100eda5442eab7a96b859a2.tar.gz |
Refactor make_cluster_options and enable_addons! into one
-rw-r--r-- | lib/google_api/cloud_platform/client.rb | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb index cb5448b91da..e61fbdcea64 100644 --- a/lib/google_api/cloud_platform/client.rb +++ b/lib/google_api/cloud_platform/client.rb @@ -58,8 +58,7 @@ module GoogleApi service = Google::Apis::ContainerV1beta1::ContainerService.new service.authorization = access_token - cluster_options = make_cluster_options(cluster_name, cluster_size, machine_type, legacy_abac) - enable_addons!(cluster_options, enable_addons) + cluster_options = make_cluster_options(cluster_name, cluster_size, machine_type, legacy_abac, enable_addons) request_body = Google::Apis::ContainerV1beta1::CreateClusterRequest.new(cluster_options) @@ -80,7 +79,7 @@ module GoogleApi private - def make_cluster_options(cluster_name, cluster_size, machine_type, legacy_abac) + def make_cluster_options(cluster_name, cluster_size, machine_type, legacy_abac, enable_addons) { cluster: { name: cluster_name, @@ -96,21 +95,14 @@ module GoogleApi }, legacy_abac: { enabled: legacy_abac - } + }, + addons_config: enable_addons.each_with_object({}) do |addon, hash| + hash[addon] = { disabled: false } + end } } end - def enable_addons!(cluster_options, enable_addons) - (cluster_options[:cluster][:addons_config] ||= {}).tap do |addons_config| - enable_addons.each do |addon| - (addons_config[addon] ||= {}).tap do |addon_config| - addon_config[:disabled] = false - end - end - end - end - def token_life_time(expires_at) DateTime.strptime(expires_at, '%s').to_time.utc - Time.now.utc end |