uffizzi-cli 2.4.9 → 2.4.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 744480393ee81d335802bcb1008333c1e6c9b6f9870d7710dfff294698a1eb7a
4
- data.tar.gz: cf43c7519e0621f9be3fbb18d9fd89fd0cf2a6ea0dc56d0b41662428e6d4b46c
3
+ metadata.gz: 30f7c016d8af15ece13fcf170ef4b0cb244aba87837567b042e4d2d2cfba9512
4
+ data.tar.gz: 17ecf2ed0ba109eb515ad05695b92d0bccfe7ac535bd923e14d091ddc5feb814
5
5
  SHA512:
6
- metadata.gz: ef39ee4ce26c553068d279f3960ba924b7458fbf439a4ffd0abbed363fa359cbf9707df59e8ee439ff06f091894836f67d7bcdb8f2c78879caa7b52120e2dfb2
7
- data.tar.gz: 6c0471f16b076c5c8dedd2b714416c6514e03f9ee96b6d6aead5d5fca19556ac6f09e73b44a050ef07f7cdcfd3a72d9bb2b14902eda9931b5251830389aacc57
6
+ metadata.gz: 6482ab9cf846b47402a332de11f054c0c845efa472cf754e627c0b767c2926f5f9e5ffcbf604f34ccaa562fd551124c777e572b28a298cf96982d9cf7f0446c0
7
+ data.tar.gz: 685212d7f1102ed76976a330499e9ada8e0f9cf2e61a58fd01b65f240d2af66ac27f128c20bdc01d8b0dae06f014f947a7db2dd633481bce7471db616e43b6ee
@@ -20,9 +20,10 @@ module Uffizzi
20
20
  method_option :'node-selector-template', required: false, type: :string
21
21
  def controller(hostname)
22
22
  Uffizzi::AuthHelper.check_login
23
+ check_account_can_install
23
24
 
24
- # InstallService.kubectl_exists?
25
- # InstallService.helm_exists?
25
+ InstallService.kubectl_exists?
26
+ InstallService.helm_exists?
26
27
 
27
28
  if options[:context].present? && options[:context] != InstallService.kubeconfig_current_context
28
29
  InstallService.set_current_context(options[:context])
@@ -71,16 +72,16 @@ module Uffizzi
71
72
  }
72
73
  end
73
74
 
74
- def wait_ip
75
+ def wait_endpoint
75
76
  spinner = TTY::Spinner.new('[:spinner] Waiting on IP address...', format: :dots)
76
77
  spinner.auto_spin
77
78
 
78
- ip = nil
79
+ endpoint = nil
79
80
  try = 0
80
81
 
81
82
  loop do
82
- ip = InstallService.get_controller_ip(namespace)
83
- break if ip.present?
83
+ endpoint = InstallService.get_controller_endpoint(namespace)
84
+ break if endpoint.present?
84
85
 
85
86
  if try == 90
86
87
  spinner.error
@@ -94,7 +95,7 @@ module Uffizzi
94
95
 
95
96
  spinner.success
96
97
 
97
- ip
98
+ endpoint
98
99
  end
99
100
 
100
101
  def build_helm_values(params)
@@ -182,7 +183,18 @@ module Uffizzi
182
183
 
183
184
  def create_controller_settings(params)
184
185
  response = create_account_controller_settings(server, account_id, params)
185
- Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.created?(response)
186
+ unless Uffizzi::ResponseHelper.created?(response)
187
+ Uffizzi::ResponseHelper.handle_failed_response(response)
188
+ raise Uffizzi::Error.new
189
+ end
190
+ end
191
+
192
+ def check_account_can_install
193
+ response = check_can_install(server, account_id)
194
+ unless Uffizzi::ResponseHelper.ok?(response)
195
+ Uffizzi::ResponseHelper.handle_failed_response(response)
196
+ raise Uffizzi::Error.new
197
+ end
186
198
  end
187
199
 
188
200
  def build_controller_setting_params(uri, installation_options)
@@ -196,10 +208,10 @@ module Uffizzi
196
208
  end
197
209
 
198
210
  def say_success(uri)
199
- ip_address = wait_ip
211
+ endpoint = wait_endpoint
200
212
 
201
213
  msg = 'Your Uffizzi controller is ready. To configure DNS,'\
202
- " create a record for the hostname '*.#{uri.host}' pointing to '#{ip_address}'"
214
+ " create a record for the hostname '*.#{uri.host}' pointing to '#{endpoint}'"
203
215
  Uffizzi.ui.say(msg)
204
216
  end
205
217
 
@@ -44,6 +44,14 @@ module ApiClient
44
44
  build_response(response)
45
45
  end
46
46
 
47
+ def check_can_install(server, account_id)
48
+ uri = account_can_install_uri(server, account_id)
49
+
50
+ response = http_client.make_get_request(uri)
51
+
52
+ build_response(response)
53
+ end
54
+
47
55
  def fetch_projects(server)
48
56
  uri = projects_uri(server)
49
57
  response = http_client.make_get_request(uri)
@@ -11,6 +11,10 @@ module ApiRoutes
11
11
  "#{server}/api/cli/v1/accounts/#{account_name}"
12
12
  end
13
13
 
14
+ def account_can_install_uri(server, account_id)
15
+ "#{server}/api/cli/v1/accounts/#{account_id}/check_can_install"
16
+ end
17
+
14
18
  def compose_file_uri(server, project_slug)
15
19
  "#{server}/api/cli/v1/projects/#{project_slug}/compose_file"
16
20
  end
@@ -85,7 +85,7 @@ class InstallService
85
85
  execute_command(cmd, say: false) { |stdout| stdout.present? && stdout.chop }
86
86
  end
87
87
 
88
- def get_controller_ip(namespace)
88
+ def get_controller_endpoint(namespace)
89
89
  cmd = "kubectl get ingress -n #{namespace} -o json"
90
90
  res = execute_command(cmd, say: false)
91
91
  ingress = JSON.parse(res)['items'].detect { |i| i['metadata']['name'] = INGRESS_NAME }
@@ -95,7 +95,10 @@ class InstallService
95
95
  load_balancers = ingress.dig('status', 'loadBalancer', 'ingress')
96
96
  return if load_balancers.blank?
97
97
 
98
- load_balancers.map { |i| i['ip'] }[0]
98
+ ip = load_balancers.map { |i| i['ip'] }[0]
99
+ return ip if ip.present?
100
+
101
+ load_balancers.map { |i| i['hostname'] }[0]
99
102
  end
100
103
 
101
104
  def build_controller_host(host)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uffizzi
4
- VERSION = '2.4.9'
4
+ VERSION = '2.4.11'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uffizzi-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.9
4
+ version: 2.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Thurman
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2024-04-02 00:00:00.000000000 Z
12
+ date: 2024-08-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport