uffizzi-cli 2.4.7 → 2.4.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d5ba713ecb457d3cb8f344936b8192c76bed2951fc22036d4416e2267b00fd0
4
- data.tar.gz: d1f0324a8b54de3282c2215ed9b68af1fc9c5d9fc54593647431bc7b57279c87
3
+ metadata.gz: 744480393ee81d335802bcb1008333c1e6c9b6f9870d7710dfff294698a1eb7a
4
+ data.tar.gz: cf43c7519e0621f9be3fbb18d9fd89fd0cf2a6ea0dc56d0b41662428e6d4b46c
5
5
  SHA512:
6
- metadata.gz: 966f0569cd79e933a4d1c62fe2c031b4856a92e36aa8804c62bc2f73d5faee9d0f325783921cda96c2bcf3b67504c39529c5baccfba2549c3762e13f6f517375
7
- data.tar.gz: 616709d553d89ef6ac020360c41173a2756fed3582fa35e4c3eacca29cf919a29aaa68a8ef1ea912d63814a13890f6bbdc74cb7783a9e7e9e40f21979dbb0167
6
+ metadata.gz: ef39ee4ce26c553068d279f3960ba924b7458fbf439a4ffd0abbed363fa359cbf9707df59e8ee439ff06f091894836f67d7bcdb8f2c78879caa7b52120e2dfb2
7
+ data.tar.gz: 6c0471f16b076c5c8dedd2b714416c6514e03f9ee96b6d6aead5d5fca19556ac6f09e73b44a050ef07f7cdcfd3a72d9bb2b14902eda9931b5251830389aacc57
@@ -35,7 +35,6 @@ module Uffizzi
35
35
  method_option :output, required: false, type: :string, aliases: '-o', enum: ['json', 'pretty-json']
36
36
  method_option :'creation-source', required: false, type: :string
37
37
  method_option :'k8s-version', required: false, type: :string
38
- method_option :'node-selector', required: false, type: :string
39
38
  def create(name = nil)
40
39
  run('create', { name: name })
41
40
  end
@@ -262,7 +261,6 @@ module Uffizzi
262
261
  manifest_content = load_manifest_file(options[:manifest])
263
262
  creation_source = options[:"creation-source"] || ClusterService::MANUAL_CREATION_SOURCE
264
263
  k8s_version = options[:"k8s-version"]
265
- node_selector = options[:"node-selector"]
266
264
 
267
265
  {
268
266
  cluster: {
@@ -270,7 +268,6 @@ module Uffizzi
270
268
  manifest: manifest_content,
271
269
  creation_source: creation_source,
272
270
  k8s_version: k8s_version,
273
- node_selector: node_selector,
274
271
  },
275
272
  token: oidc_token,
276
273
  }
@@ -17,6 +17,7 @@ module Uffizzi
17
17
  method_option :context, type: :string
18
18
  method_option :issuer, type: :string, enum: ['letsencrypt', 'zerossl']
19
19
  method_option :'repo-url', type: :string
20
+ method_option :'node-selector-template', required: false, type: :string
20
21
  def controller(hostname)
21
22
  Uffizzi::AuthHelper.check_login
22
23
 
@@ -66,11 +67,12 @@ module Uffizzi
66
67
  controller_password: generate_password,
67
68
  cert_email: options[:email],
68
69
  cluster_issuer: options[:issuer] || InstallService::DEFAULT_CLUSTER_ISSUER,
70
+ node_selector_template: options[:"node-selector-template"],
69
71
  }
70
72
  end
71
73
 
72
74
  def wait_ip
73
- spinner = TTY::Spinner.new('[:spinner] Waiting IP addess...', format: :dots)
75
+ spinner = TTY::Spinner.new('[:spinner] Waiting on IP address...', format: :dots)
74
76
  spinner.auto_spin
75
77
 
76
78
  ip = nil
@@ -80,7 +82,7 @@ module Uffizzi
80
82
  ip = InstallService.get_controller_ip(namespace)
81
83
  break if ip.present?
82
84
 
83
- if try == 30
85
+ if try == 90
84
86
  spinner.error
85
87
 
86
88
  return 'unknown'
@@ -95,29 +97,6 @@ module Uffizzi
95
97
  ip
96
98
  end
97
99
 
98
- def wait_certificate_request_ready(uri)
99
- spinner = TTY::Spinner.new('[:spinner] Waiting create certificate for controller host...', format: :dots)
100
- spinner.auto_spin
101
-
102
- try = 0
103
-
104
- loop do
105
- requests = InstallService.get_certificate_request(namespace, uri)
106
- break if requests.all? { |r| r['status'].downcase == 'true' }
107
-
108
- if try == 60
109
- spinner.error
110
-
111
- return Uffizzi.ui.say('Stop waiting creation certificate')
112
- end
113
-
114
- try += 1
115
- sleep(2)
116
- end
117
-
118
- spinner.success
119
- end
120
-
121
100
  def build_helm_values(params)
122
101
  {
123
102
  global: {
@@ -212,12 +191,12 @@ module Uffizzi
212
191
  managed_dns_zone: uri.host,
213
192
  login: installation_options[:controller_username],
214
193
  password: installation_options[:controller_password],
194
+ node_selector_template: installation_options[:node_selector_template],
215
195
  }
216
196
  end
217
197
 
218
198
  def say_success(uri)
219
199
  ip_address = wait_ip
220
- wait_certificate_request_ready(uri)
221
200
 
222
201
  msg = 'Your Uffizzi controller is ready. To configure DNS,'\
223
202
  " create a record for the hostname '*.#{uri.host}' pointing to '#{ip_address}'"
@@ -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
@@ -98,17 +98,6 @@ class InstallService
98
98
  load_balancers.map { |i| i['ip'] }[0]
99
99
  end
100
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?
107
-
108
- conditions = certificate_request.dig('status', 'conditions') || []
109
- conditions.map { |c| c.slice('type', 'status') }
110
- end
111
-
112
101
  def build_controller_host(host)
113
102
  [DEFAULT_CONTROLLER_DOMAIN_PREFIX, host].join('.')
114
103
  end
@@ -130,6 +119,14 @@ class InstallService
130
119
  File.dirname(Uffizzi::ConfigFile.config_path)
131
120
  end
132
121
 
122
+ def current_namespace
123
+ path = KubeconfigService.default_path
124
+ kubeconfig = KubeconfigService.read_kubeconfig(path)
125
+ return if kubeconfig.nil?
126
+
127
+ KubeconfigService.get_current_namespace(kubeconfig) || DEFAULT_NAMESPACE
128
+ end
129
+
133
130
  private
134
131
 
135
132
  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.7'
4
+ VERSION = '2.4.9'
5
5
  end
data/lib/uffizzi.rb CHANGED
@@ -7,6 +7,7 @@ require 'active_support'
7
7
  require 'active_support/core_ext/hash/indifferent_access'
8
8
  require 'active_support/core_ext/object/blank'
9
9
  require 'launchy'
10
+ require 'base64'
10
11
 
11
12
  require 'thor'
12
13
  require 'uffizzi/error'
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.7
4
+ version: 2.4.9
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-02 00:00:00.000000000 Z
12
+ date: 2024-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport