uffizzi-cli 2.4.8 → 2.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d357e75482392caf7a0dcf00cc15e527947af62ec9a00186ab79b94ccfc8b3e
4
- data.tar.gz: 3b8af8bc628b4ab6398cf4acfda863e7560e21861ae89dbcc82cdf0902e496bc
3
+ metadata.gz: 208b6ac1dfb59b5b76aac7cc0b4a21c8b4c725e8e843958fe10b98bdd50ec43f
4
+ data.tar.gz: 7335a86326e93a84dbf67f31b3182d18a6fbf88a9e4ce4a4c04af265c68f3809
5
5
  SHA512:
6
- metadata.gz: 3e0c676e7a8af1a2054e1155dea4b866447760d1b88ccea22cfed911a1231718f3f46d721d1a02c5df83e168c4b4f421343f9309b2cc35a4ad9283dacb2031c1
7
- data.tar.gz: d241444a8ee0e01406b42ff4797aed2e52c26fb386d330ed252ba94b7e2763d48224b55e6a00069386b05ee70c68b13e488901627f4a5a35c9555f583a936b8f
6
+ metadata.gz: 5302d2e8db9c5afb7c2550d45a15125d98efd472f8ae6902739b6900260719d213b1c71d79050e70018ad4381849155a2cc0730ae89d9af1f7268e10f08af7ab
7
+ data.tar.gz: fbaf9bdba63f98ce1811d70e1388f9823baa32bf6bb28469e6e48a41d41d8b4e477b99addef053b290acfdc606f7ae5600c4ba77c2a5db4fed7356bca28c158c
@@ -71,18 +71,18 @@ module Uffizzi
71
71
  }
72
72
  end
73
73
 
74
- def wait_ip
75
- spinner = TTY::Spinner.new('[:spinner] Waiting IP addess...', format: :dots)
74
+ def wait_endpoint
75
+ spinner = TTY::Spinner.new('[:spinner] Waiting on IP address...', format: :dots)
76
76
  spinner.auto_spin
77
77
 
78
- ip = nil
78
+ endpoint = nil
79
79
  try = 0
80
80
 
81
81
  loop do
82
- ip = InstallService.get_controller_ip(namespace)
83
- break if ip.present?
82
+ endpoint = InstallService.get_controller_endpoint(namespace)
83
+ break if endpoint.present?
84
84
 
85
- if try == 30
85
+ if try == 90
86
86
  spinner.error
87
87
 
88
88
  return 'unknown'
@@ -94,30 +94,7 @@ module Uffizzi
94
94
 
95
95
  spinner.success
96
96
 
97
- ip
98
- end
99
-
100
- def wait_certificate_request_ready(uri)
101
- spinner = TTY::Spinner.new('[:spinner] Waiting create certificate for controller host...', format: :dots)
102
- spinner.auto_spin
103
-
104
- try = 0
105
-
106
- loop do
107
- requests = InstallService.get_certificate_request(namespace, uri)
108
- break if requests.all? { |r| r['status'].downcase == 'true' }
109
-
110
- if try == 60
111
- spinner.error
112
-
113
- return Uffizzi.ui.say('Stop waiting creation certificate')
114
- end
115
-
116
- try += 1
117
- sleep(2)
118
- end
119
-
120
- spinner.success
97
+ endpoint
121
98
  end
122
99
 
123
100
  def build_helm_values(params)
@@ -219,11 +196,10 @@ module Uffizzi
219
196
  end
220
197
 
221
198
  def say_success(uri)
222
- ip_address = wait_ip
223
- wait_certificate_request_ready(uri)
199
+ endpoint = wait_endpoint
224
200
 
225
201
  msg = 'Your Uffizzi controller is ready. To configure DNS,'\
226
- " create a record for the hostname '*.#{uri.host}' pointing to '#{ip_address}'"
202
+ " create a record for the hostname '*.#{uri.host}' pointing to '#{endpoint}'"
227
203
  Uffizzi.ui.say(msg)
228
204
  end
229
205
 
@@ -12,7 +12,7 @@ module Uffizzi
12
12
  default_task :controller
13
13
 
14
14
  desc 'controller [HOSTNAME]', 'Install uffizzi controller to cluster'
15
- method_option :namespace, type: :string
15
+ method_option :namespace, type: :string, aliases: '-n'
16
16
  method_option :context, type: :string
17
17
  def controller
18
18
  Uffizzi::AuthHelper.check_login
@@ -86,7 +86,7 @@ module Uffizzi
86
86
  end
87
87
 
88
88
  def namespace
89
- options[:namespace] || InstallService::DEFAULT_NAMESPACE
89
+ options[:namespace] || InstallService.current_namespace
90
90
  end
91
91
 
92
92
  def server
@@ -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,18 +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]
99
- end
100
-
101
- def get_certificate_request(namespace, uri)
102
- cmd = "kubectl get certificaterequests -n #{namespace} -o json"
103
- res = execute_command(cmd, say: false)
104
- certificate_request = JSON.parse(res)['items'].detect { |i| i['metadata']['name'].include?(uri.host) }
105
-
106
- return [] if certificate_request.nil?
98
+ ip = load_balancers.map { |i| i['ip'] }[0]
99
+ return ip if ip.present?
107
100
 
108
- conditions = certificate_request.dig('status', 'conditions') || []
109
- conditions.map { |c| c.slice('type', 'status') }
101
+ load_balancers.map { |i| i['hostname'] }[0]
110
102
  end
111
103
 
112
104
  def build_controller_host(host)
@@ -130,6 +122,14 @@ class InstallService
130
122
  File.dirname(Uffizzi::ConfigFile.config_path)
131
123
  end
132
124
 
125
+ def current_namespace
126
+ path = KubeconfigService.default_path
127
+ kubeconfig = KubeconfigService.read_kubeconfig(path)
128
+ return if kubeconfig.nil?
129
+
130
+ KubeconfigService.get_current_namespace(kubeconfig) || DEFAULT_NAMESPACE
131
+ end
132
+
133
133
  private
134
134
 
135
135
  def execute_command(command, say: true, skip_error: false)
@@ -50,6 +50,12 @@ class KubeconfigService
50
50
  .dig('context', 'cluster')
51
51
  end
52
52
 
53
+ def get_current_namespace(kubeconfig)
54
+ get_cluster_contexts(kubeconfig)
55
+ .detect { |c| c['name'] == get_current_context(kubeconfig) }
56
+ .dig('context', 'namespace')
57
+ end
58
+
53
59
  def get_cluster_contexts(kubeconfig)
54
60
  kubeconfig.fetch('contexts', [])
55
61
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uffizzi
4
- VERSION = '2.4.8'
4
+ VERSION = '2.4.10'
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.8
4
+ version: 2.4.10
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-03-15 00:00:00.000000000 Z
12
+ date: 2024-06-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport