Sha256: 19811bf3e9cf4899ca9f91fbeb6fa156e19244b7acf04bd5b6c5b219048899d8

Contents?: true

Size: 1.11 KB

Versions: 17

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'uffizzi'
require 'uffizzi/auth_helper'
require 'uffizzi/response_helper'

module Uffizzi
  class Cli::Dev::Ingress < Thor
    include ApiClient

    desc 'open', 'Open dev environment hosts'
    def open
      Uffizzi::AuthHelper.check_login
      DevService.check_running_process!

      if DevService.startup?
        Uffizzi.ui.say_error_and_exit('Dev environment not started yet')
      end

      dev_environment = DevService.dev_environment
      cluster_name = dev_environment[:cluster_name]
      params = { cluster_name: cluster_name }
      response = get_cluster_ingresses(server, project_slug, params)

      return ResponseHelper.handle_failed_response(response) unless ResponseHelper.ok?(response)

      ingress_hosts = response.dig(:body, :ingresses)
      urls = ingress_hosts.map { |host| "https://#{host}" }
      urls.each { |url| Uffizzi.launchy.open(url) { Uffizzi.ui.say(url) } }
    end

    private

    def server
      @server ||= ConfigFile.read_option(:server)
    end

    def project_slug
      @project_slug ||= ConfigFile.read_option(:project)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
uffizzi-cli-2.4.11 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.10 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.9 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.8 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.7 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.6 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.5 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.4 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.3 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.2 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.1 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.4.0 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.3.4 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.3.3 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.3.2 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.3.1 lib/uffizzi/cli/dev/ingress.rb
uffizzi-cli-2.3.0 lib/uffizzi/cli/dev/ingress.rb