Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
lidiamokevnina committed Aug 5, 2024
2 parents bca51b5 + af065a9 commit abd154b
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
uffizzi-cli (2.4.10)
uffizzi-cli (2.4.11)
activesupport
awesome_print
faker
Expand Down Expand Up @@ -38,7 +38,7 @@ GEM
factory_bot (6.2.0)
activesupport (>= 5.0.0)
fakefs (1.8.0)
faker (3.4.1)
faker (3.4.2)
i18n (>= 1.8.11, < 2)
hashdiff (1.0.1)
i18n (1.8.11)
Expand Down Expand Up @@ -103,7 +103,7 @@ GEM
rubocop (~> 1.0)
ruby-progressbar (1.11.0)
securerandom (0.3.1)
sentry-ruby (5.18.0)
sentry-ruby (5.18.2)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
thor (1.3.1)
Expand Down
18 changes: 15 additions & 3 deletions lib/uffizzi/cli/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ class Cli::Install < Thor
method_option :'node-selector-template', required: false, type: :string
def controller(hostname)
Uffizzi::AuthHelper.check_login
check_account_can_install

# InstallService.kubectl_exists?
# InstallService.helm_exists?
InstallService.kubectl_exists?
InstallService.helm_exists?

if options[:context].present? && options[:context] != InstallService.kubeconfig_current_context
InstallService.set_current_context(options[:context])
Expand Down Expand Up @@ -182,7 +183,18 @@ def update_controller_settings(controller_setting_id, params)

def create_controller_settings(params)
response = create_account_controller_settings(server, account_id, params)
Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.created?(response)
unless Uffizzi::ResponseHelper.created?(response)
Uffizzi::ResponseHelper.handle_failed_response(response)
raise Uffizzi::Error.new
end
end

def check_account_can_install
response = check_can_install(server, account_id)
unless Uffizzi::ResponseHelper.ok?(response)
Uffizzi::ResponseHelper.handle_failed_response(response)
raise Uffizzi::Error.new
end
end

def build_controller_setting_params(uri, installation_options)
Expand Down
8 changes: 8 additions & 0 deletions lib/uffizzi/clients/api/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ def fetch_accounts(server)
build_response(response)
end

def check_can_install(server, account_id)
uri = account_can_install_uri(server, account_id)

response = http_client.make_get_request(uri)

build_response(response)
end

def fetch_projects(server)
uri = projects_uri(server)
response = http_client.make_get_request(uri)
Expand Down
4 changes: 4 additions & 0 deletions lib/uffizzi/clients/api/api_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def account_uri(server, account_name)
"#{server}/api/cli/v1/accounts/#{account_name}"
end

def account_can_install_uri(server, account_id)
"#{server}/api/cli/v1/accounts/#{account_id}/check_can_install"
end

def compose_file_uri(server, project_slug)
"#{server}/api/cli/v1/projects/#{project_slug}/compose_file"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/uffizzi/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Uffizzi
VERSION = '2.4.10'
VERSION = '2.4.11'
end
6 changes: 6 additions & 0 deletions test/support/uffizzi_stub_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def stub_uffizzi_accounts_success(body)
stub_request(:get, url).to_return(status: 200, body: body.to_json)
end

def stub_uffizzi_check_can_install_success(account_id)
url = account_can_install_uri(Uffizzi.configuration.server, account_id)

stub_request(:get, url).to_return(status: 200)
end

def stub_uffizzi_account_success(body, account_name)
url = account_uri(Uffizzi.configuration.server, account_name)

Expand Down
2 changes: 2 additions & 0 deletions test/uffizzi/cli/install_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def test_install
stub_get_account_controller_settings_request(empty_controller_settings_body, account_id)
stub_create_account_controller_settings_request({}, account_id)
stub_update_account_success(account_body, account_name)
stub_uffizzi_check_can_install_success(account_id)

@install.options = command_options(email: '[email protected]')
@install.controller(host)
Expand Down Expand Up @@ -116,6 +117,7 @@ def test_install_if_settgins_exists
stub_get_account_controller_settings_request(account_controller_settings_body, account_id)
stub_update_account_controller_settings_request(account_controller_settings_body, account_id,
account_controller_settings_body[:controller_settings][0][:id])
stub_uffizzi_check_can_install_success(account_id)

@install.options = command_options(email: '[email protected]')
@install.controller(host)
Expand Down

0 comments on commit abd154b

Please sign in to comment.