uffizzi-cli 2.4.3 → 2.4.5

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: 12aba3a7c9cb35a284582d4d15614c2c54bc3e79320ae57484cdc838f5e427f7
4
- data.tar.gz: d55fe3842347380c8c3a26bef9db40a95cd83ecb2a3fa3d7ff31ecc2b9322394
3
+ metadata.gz: 1ef83eb18cf4f320ac6b596cc3b2d9ba72b6ed5a60e90e7dc54f61fa1e042630
4
+ data.tar.gz: 0a93840aa290162c4dc58a8ff3614fac4d58d988bd5296da5614db69524d0b43
5
5
  SHA512:
6
- metadata.gz: 8750abc88b5ef8deb83d2a60edde1ff06866ec1d4404aae56518b970d3ec78b300ed69fd3f2675b0f2a96fd5c09dd937038c5a45d856a90f49fa8bfdc0400c84
7
- data.tar.gz: 7ca46fbf05024d1e0cfa9eb969502453f8439cc0e7e80f25d711d48a4a3782b13b3331969fb1a626fdbd17eb13d717f17778e35832f3749abbf03e1825167e16
6
+ metadata.gz: 215e24c7486176be02a14265492195334b096c20458f3ab926cb4bc76a82955f3f05f5ead2f9d812ca622a07e28d8747b580e47a8ac7f50c7a017c4674addb21
7
+ data.tar.gz: ad0e2178d3ad1d440d8b29cc2e1abc031b2ee5bdb5a6ac7119db36d287d69c7b8ae648ea817013c7fc1ad1d96dcd575ed0df956b6ed24f9da993acc41ccae577
@@ -3,6 +3,7 @@
3
3
  require 'uffizzi'
4
4
  require 'uffizzi/config_file'
5
5
  require 'uffizzi/services/kubeconfig_service'
6
+ require 'uffizzi/services/account_service'
6
7
 
7
8
  module Uffizzi
8
9
  class Cli::Install < Thor
@@ -10,7 +11,7 @@ module Uffizzi
10
11
 
11
12
  default_task :controller
12
13
 
13
- desc 'controller [HOSTNMAE]', 'Install uffizzi controller to cluster'
14
+ desc 'controller [HOSTNAME]', 'Install uffizzi controller to cluster'
14
15
  method_option :namespace, type: :string
15
16
  method_option :email, type: :string, required: true
16
17
  method_option :context, type: :string
@@ -19,14 +20,14 @@ module Uffizzi
19
20
  def controller(hostname)
20
21
  Uffizzi::AuthHelper.check_login
21
22
 
22
- InstallService.kubectl_exists?
23
- InstallService.helm_exists?
23
+ # InstallService.kubectl_exists?
24
+ # InstallService.helm_exists?
24
25
 
25
26
  if options[:context].present? && options[:context] != InstallService.kubeconfig_current_context
26
27
  InstallService.set_current_context(options[:context])
27
28
  end
28
29
 
29
- ask_confirmation
30
+ ask_confirmation(options[:namespace])
30
31
 
31
32
  uri = parse_hostname(hostname)
32
33
  installation_options = build_installation_options(uri)
@@ -40,7 +41,12 @@ module Uffizzi
40
41
  Uffizzi.ui.say('Helm release is deployed')
41
42
 
42
43
  controller_setting_params = build_controller_setting_params(uri, installation_options)
43
- create_controller_settings(controller_setting_params) if existing_controller_setting.blank?
44
+
45
+ if existing_controller_setting.blank?
46
+ create_controller_settings(controller_setting_params)
47
+ set_account_installation
48
+ end
49
+
44
50
  Uffizzi.ui.say('Controller settings are saved')
45
51
  say_success(uri)
46
52
  end
@@ -153,16 +159,8 @@ module Uffizzi
153
159
  update_controller_settings(existing_controller_setting[:id], controller_setting_params)
154
160
  end
155
161
 
156
- def ask_confirmation
157
- msg = "\r\n"\
158
- 'This command will install Uffizzi into the default namespace of'\
159
- " the '#{InstallService.kubeconfig_current_context}' context."\
160
- "\r\n"\
161
- "To install in a different place, use options '--namespace' and/or '--context'."\
162
- "\r\n\r\n"\
163
- "After installation, new environments created for account '#{account_name}' will be deployed to this host cluster."\
164
- "\r\n\r\n"
165
-
162
+ def ask_confirmation(namespace)
163
+ msg = namespace.present? ? custom_namespace_installation_message(namespace) : default_installation_message
166
164
  Uffizzi.ui.say(msg)
167
165
 
168
166
  question = 'Okay to proceed?'
@@ -189,6 +187,15 @@ module Uffizzi
189
187
  response.dig(:body, :controller_settings)
190
188
  end
191
189
 
190
+ def set_account_installation
191
+ params = {
192
+ installation_type: AccountService::SELF_HOSTED_CONTROLLER_INSTALLATION_TYPE,
193
+ }
194
+
195
+ response = update_account(server, account_name, params)
196
+ Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.ok?(response)
197
+ end
198
+
192
199
  def update_controller_settings(controller_setting_id, params)
193
200
  response = update_account_controller_settings(server, account_id, controller_setting_id, params)
194
201
  Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.ok?(response)
@@ -248,5 +255,25 @@ module Uffizzi
248
255
  def existing_controller_setting
249
256
  @existing_controller_setting ||= fetch_controller_settings[0]
250
257
  end
258
+
259
+ def default_installation_message
260
+ "\r\n"\
261
+ "This command will install Uffizzi into the 'default' namespace of"\
262
+ " the '#{InstallService.kubeconfig_current_context}' context."\
263
+ "\r\n"\
264
+ "To install in a different place, use options '--namespace' and/or '--context'."\
265
+ "\r\n\r\n"\
266
+ "After installation, new environments created for account '#{account_name}' will be deployed to this host cluster."\
267
+ "\r\n\r\n"
268
+ end
269
+
270
+ def custom_namespace_installation_message(namespace)
271
+ "\r\n"\
272
+ "This command will install Uffizzi into the '#{namespace}' namespace of"\
273
+ " the '#{InstallService.kubeconfig_current_context}' context."\
274
+ "\r\n\r\n"\
275
+ "After installation, new environments created for account '#{account_name}' will be deployed to this host cluster."\
276
+ "\r\n\r\n"
277
+ end
251
278
  end
252
279
  end
@@ -11,7 +11,7 @@ module Uffizzi
11
11
 
12
12
  default_task :controller
13
13
 
14
- desc 'controller [HOSTNMAE]', 'Install uffizzi controller to cluster'
14
+ desc 'controller [HOSTNAME]', 'Install uffizzi controller to cluster'
15
15
  method_option :namespace, type: :string
16
16
  method_option :context, type: :string
17
17
  def controller
@@ -26,6 +26,7 @@ module Uffizzi
26
26
 
27
27
  ask_confirmation
28
28
  delete_controller_settings
29
+ unset_account_installation
29
30
  InstallService.helm_uninstall!(namespace)
30
31
 
31
32
  helm_unset_repo
@@ -75,6 +76,15 @@ module Uffizzi
75
76
  end
76
77
  end
77
78
 
79
+ def unset_account_installation
80
+ params = {
81
+ installation_type: nil,
82
+ }
83
+
84
+ response = update_account(server, account_name, params)
85
+ Uffizzi::ResponseHelper.handle_failed_response(response) unless Uffizzi::ResponseHelper.ok?(response)
86
+ end
87
+
78
88
  def namespace
79
89
  options[:namespace] || InstallService::DEFAULT_NAMESPACE
80
90
  end
@@ -87,6 +87,13 @@ module ApiClient
87
87
  build_response(response)
88
88
  end
89
89
 
90
+ def update_account(server, account_name, params)
91
+ uri = account_uri(server, account_name)
92
+ response = http_client.make_put_request(uri, params)
93
+
94
+ build_response(response)
95
+ end
96
+
90
97
  def create_project(server, account_id, params)
91
98
  uri = create_projects_uri(server, account_id)
92
99
  response = http_client.make_post_request(uri, params)
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AccountService
4
+ SELF_HOSTED_CONTROLLER_INSTALLATION_TYPE = 'self_hosted_controller'
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uffizzi
4
- VERSION = '2.4.3'
4
+ VERSION = '2.4.5'
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.3
4
+ version: 2.4.5
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: 2023-12-21 00:00:00.000000000 Z
12
+ date: 2024-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -450,6 +450,7 @@ files:
450
450
  - lib/uffizzi/helpers/project_helper.rb
451
451
  - lib/uffizzi/promt.rb
452
452
  - lib/uffizzi/response_helper.rb
453
+ - lib/uffizzi/services/account_service.rb
453
454
  - lib/uffizzi/services/cluster/common_service.rb
454
455
  - lib/uffizzi/services/cluster/create_service.rb
455
456
  - lib/uffizzi/services/cluster/delete_service.rb