Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clean up CLI status and output messages #414

Merged
merged 4 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions lib/uffizzi/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def build_installation_options(uri)
end

def wait_ip
spinner = TTY::Spinner.new('[:spinner] Waiting IP addess...', format: :dots)
spinner = TTY::Spinner.new('[:spinner] Waiting on IP address...', format: :dots)
spinner.auto_spin

ip = nil
Expand All @@ -97,29 +97,6 @@ def wait_ip
ip
end

def wait_certificate_request_ready(uri)
spinner = TTY::Spinner.new('[:spinner] Waiting create certificate for controller host...', format: :dots)
spinner.auto_spin

try = 0

loop do
requests = InstallService.get_certificate_request(namespace, uri)
break if requests.all? { |r| r['status'].downcase == 'true' }

if try == 60
spinner.error

return Uffizzi.ui.say('Stop waiting creation certificate')
end

try += 1
sleep(2)
end

spinner.success
end

def build_helm_values(params)
{
global: {
Expand Down Expand Up @@ -220,7 +197,6 @@ def build_controller_setting_params(uri, installation_options)

def say_success(uri)
ip_address = wait_ip
wait_certificate_request_ready(uri)

msg = 'Your Uffizzi controller is ready. To configure DNS,'\
" create a record for the hostname '*.#{uri.host}' pointing to '#{ip_address}'"
Expand Down
2 changes: 1 addition & 1 deletion lib/uffizzi/cli/uninstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Cli::Uninstall < Thor
default_task :controller

desc 'controller [HOSTNAME]', 'Install uffizzi controller to cluster'
method_option :namespace, type: :string
method_option :namespace, type: :string, aliases: '-n'
method_option :context, type: :string
def controller
Uffizzi::AuthHelper.check_login
Expand Down
11 changes: 0 additions & 11 deletions lib/uffizzi/services/install_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,6 @@ def get_controller_ip(namespace)
load_balancers.map { |i| i['ip'] }[0]
end

def get_certificate_request(namespace, uri)
cmd = "kubectl get certificaterequests -n #{namespace} -o json"
res = execute_command(cmd, say: false)
certificate_request = JSON.parse(res)['items'].detect { |i| i['metadata']['name'].include?(uri.host) }

return [] if certificate_request.nil?

conditions = certificate_request.dig('status', 'conditions') || []
conditions.map { |c| c.slice('type', 'status') }
end

def build_controller_host(host)
[DEFAULT_CONTROLLER_DOMAIN_PREFIX, host].join('.')
end
Expand Down
Loading