uffizzi-cli 2.1.0 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uffizzi/auth_helper.rb +16 -4
- data/lib/uffizzi/cli/account.rb +1 -1
- data/lib/uffizzi/cli/cluster.rb +17 -16
- data/lib/uffizzi/cli/dev.rb +48 -28
- data/lib/uffizzi/cli/preview/service.rb +2 -5
- data/lib/uffizzi/cli/preview.rb +1 -3
- data/lib/uffizzi/cli/project/compose.rb +1 -3
- data/lib/uffizzi/cli/project.rb +1 -1
- data/lib/uffizzi/config_file.rb +1 -0
- data/lib/uffizzi/services/cluster_service.rb +1 -0
- data/lib/uffizzi/services/dev_service.rb +108 -0
- data/lib/uffizzi/services/kubeconfig_service.rb +3 -1
- data/lib/uffizzi/version.rb +1 -1
- data/lib/uffizzi.rb +4 -0
- data/man/uffizzi-cluster-create.ronn +10 -1
- data/man/uffizzi-dev-start +79 -9
- data/man/uffizzi-dev-start.ronn +77 -8
- data/man/uffizzi-dev-stop +41 -0
- data/man/uffizzi-dev-stop.ronn +33 -0
- metadata +5 -3
- data/lib/uffizzi/services/command_service.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a2c29a4de6f7d90584e2e49dfdfce35d6a787d126617a90af2725153a4d97e1
|
4
|
+
data.tar.gz: e318f3abd73127d71c42eb96a74adf02bd200d81b3d8beeaae4e96028f01a1fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf7d7627bb4d280719662cf21187cd532bf7434e11bfd5a52e43b31b008203061bcc3b31e1964001f15af5e2a98ee351481318326d4c4c729f63797c70dd6802
|
7
|
+
data.tar.gz: e5c50211551e420d3e114fd9a70987a7c481f9cf82517d3b5cf5f5baeddaa8f43244c9afcf0d0c5d947ef1e1cbb0be771376c8394f9a4028e661821eead389ed
|
data/lib/uffizzi/auth_helper.rb
CHANGED
@@ -4,7 +4,7 @@ module Uffizzi
|
|
4
4
|
module AuthHelper
|
5
5
|
class << self
|
6
6
|
def signed_in?
|
7
|
-
config_data_exists?
|
7
|
+
config_data_exists? && authorized?
|
8
8
|
end
|
9
9
|
|
10
10
|
def sign_out
|
@@ -16,13 +16,25 @@ module Uffizzi
|
|
16
16
|
Uffizzi::Token.delete if Uffizzi::Token.exists?
|
17
17
|
end
|
18
18
|
|
19
|
+
def check_login(project_option)
|
20
|
+
raise Uffizzi::Error.new('You are not logged in. Run `uffizzi login`.') unless signed_in?
|
21
|
+
raise Uffizzi::Error.new('This command needs project to be set in config file') unless project_set?(project_option)
|
22
|
+
end
|
23
|
+
|
19
24
|
private
|
20
25
|
|
21
26
|
def config_data_exists?
|
22
27
|
ConfigFile.exists? &&
|
23
|
-
ConfigFile.option_has_value?(:
|
24
|
-
ConfigFile.option_has_value?(:
|
25
|
-
|
28
|
+
ConfigFile.option_has_value?(:server) &&
|
29
|
+
ConfigFile.option_has_value?(:account)
|
30
|
+
end
|
31
|
+
|
32
|
+
def authorized?
|
33
|
+
ConfigFile.option_has_value?(:cookie) || Uffizzi::Token.exists?
|
34
|
+
end
|
35
|
+
|
36
|
+
def project_set?(project_option)
|
37
|
+
!project_option.nil? || (Uffizzi::ConfigFile.exists? && Uffizzi::ConfigFile.option_has_value?(:project))
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
data/lib/uffizzi/cli/account.rb
CHANGED
data/lib/uffizzi/cli/cluster.rb
CHANGED
@@ -6,13 +6,10 @@ require 'uffizzi'
|
|
6
6
|
require 'uffizzi/auth_helper'
|
7
7
|
require 'uffizzi/helpers/config_helper'
|
8
8
|
require 'uffizzi/services/preview_service'
|
9
|
-
require 'uffizzi/services/command_service'
|
10
9
|
require 'uffizzi/services/cluster_service'
|
11
10
|
require 'uffizzi/services/kubeconfig_service'
|
12
11
|
require 'uffizzi/services/cluster/disconnect_service'
|
13
12
|
|
14
|
-
MANUAL = 'manual'
|
15
|
-
|
16
13
|
module Uffizzi
|
17
14
|
class Cli::Cluster < Thor
|
18
15
|
class Error < StandardError; end
|
@@ -32,6 +29,7 @@ module Uffizzi
|
|
32
29
|
method_option :'update-current-context', type: :boolean, required: false, default: true
|
33
30
|
method_option :output, required: false, type: :string, aliases: '-o', enum: ['json', 'pretty-json']
|
34
31
|
method_option :'creation-source', required: false, type: :string
|
32
|
+
method_option :'k8s-version', required: false, type: :string
|
35
33
|
def create(name = nil)
|
36
34
|
run('create', { name: name })
|
37
35
|
end
|
@@ -67,9 +65,7 @@ module Uffizzi
|
|
67
65
|
|
68
66
|
def run(command, command_args = {})
|
69
67
|
Uffizzi.ui.output_format = options[:output]
|
70
|
-
|
71
|
-
raise Uffizzi::Error.new('This command needs project to be set in config file') unless CommandService.project_set?(options)
|
72
|
-
|
68
|
+
Uffizzi::AuthHelper.check_login(options[:project])
|
73
69
|
project_slug = options[:project].nil? ? ConfigFile.read_option(:project) : options[:project]
|
74
70
|
|
75
71
|
case command
|
@@ -115,14 +111,16 @@ module Uffizzi
|
|
115
111
|
end
|
116
112
|
|
117
113
|
cluster_name = command_args[:name] || options[:name] || ClusterService.generate_name
|
118
|
-
creation_source = options[:"creation-source"] ||
|
119
|
-
|
120
|
-
unless ClusterService.valid_name?(cluster_name)
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
114
|
+
creation_source = options[:"creation-source"] || ClusterService::MANUAL_CREATION_SOURCE
|
115
|
+
k8s_version = options[:"k8s-version"]
|
116
|
+
Uffizzi.ui.say_error_and_exit("Cluster name: #{cluster_name} is not valid.") unless ClusterService.valid_name?(cluster_name)
|
117
|
+
|
118
|
+
params = cluster_creation_params(
|
119
|
+
name: cluster_name,
|
120
|
+
creation_source: creation_source,
|
121
|
+
manifest_file_path: options[:manifest],
|
122
|
+
k8s_version: k8s_version,
|
123
|
+
)
|
126
124
|
response = create_cluster(ConfigFile.read_option(:server), project_slug, params)
|
127
125
|
|
128
126
|
return ResponseHelper.handle_failed_response(response) unless ResponseHelper.created?(response)
|
@@ -241,7 +239,7 @@ module Uffizzi
|
|
241
239
|
end
|
242
240
|
end
|
243
241
|
|
244
|
-
def cluster_creation_params(name
|
242
|
+
def cluster_creation_params(name:, creation_source:, manifest_file_path:, k8s_version:)
|
245
243
|
manifest_content = load_manifest_file(manifest_file_path)
|
246
244
|
oidc_token = Uffizzi::ConfigFile.read_option(:oidc_token)
|
247
245
|
|
@@ -250,6 +248,7 @@ module Uffizzi
|
|
250
248
|
name: name,
|
251
249
|
manifest: manifest_content,
|
252
250
|
creation_source: creation_source,
|
251
|
+
k8s_version: k8s_version,
|
253
252
|
},
|
254
253
|
token: oidc_token,
|
255
254
|
}
|
@@ -305,6 +304,7 @@ module Uffizzi
|
|
305
304
|
status: cluster_data[:state],
|
306
305
|
created: Time.strptime(cluster_data[:created_at], '%Y-%m-%dT%H:%M:%S.%N').strftime('%a %b %d %H:%M:%S %Y'),
|
307
306
|
url: cluster_data[:host],
|
307
|
+
k8s_version: cluster_data[:k8s_version],
|
308
308
|
}
|
309
309
|
|
310
310
|
rendered_cluster_data = if Uffizzi.ui.output_format.nil?
|
@@ -337,7 +337,6 @@ module Uffizzi
|
|
337
337
|
end
|
338
338
|
|
339
339
|
def save_kubeconfig(kubeconfig, kubeconfig_path)
|
340
|
-
kubeconfig_path = kubeconfig_path.nil? ? KubeconfigService.default_path : kubeconfig_path
|
341
340
|
is_update_current_context = options[:'update-current-context']
|
342
341
|
|
343
342
|
KubeconfigService.save_to_filepath(kubeconfig_path, kubeconfig) do |kubeconfig_by_path|
|
@@ -356,6 +355,8 @@ module Uffizzi
|
|
356
355
|
merged_kubeconfig
|
357
356
|
end
|
358
357
|
end
|
358
|
+
|
359
|
+
Uffizzi.ui.say("Kubeconfig was updated by the path: #{kubeconfig_path}") if is_update_current_context
|
359
360
|
end
|
360
361
|
|
361
362
|
def update_clusters_config(id, params)
|
data/lib/uffizzi/cli/dev.rb
CHANGED
@@ -1,20 +1,32 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'uffizzi/services/command_service'
|
4
3
|
require 'uffizzi/services/cluster_service'
|
4
|
+
require 'uffizzi/services/dev_service'
|
5
5
|
require 'uffizzi/services/kubeconfig_service'
|
6
|
+
require 'uffizzi/auth_helper'
|
6
7
|
|
7
8
|
module Uffizzi
|
8
9
|
class Cli::Dev < Thor
|
9
10
|
include ApiClient
|
10
11
|
|
11
12
|
desc 'start [CONFIG]', 'Start dev environment'
|
13
|
+
method_option :quiet, type: :boolean, aliases: :q
|
14
|
+
method_option :'default-repo', type: :string
|
15
|
+
method_option :kubeconfig, type: :string
|
16
|
+
method_option :'k8s-version', required: false, type: :string
|
12
17
|
def start(config_path = 'skaffold.yaml')
|
13
|
-
|
14
|
-
|
18
|
+
Uffizzi::AuthHelper.check_login(options[:project])
|
19
|
+
DevService.check_skaffold_existence
|
20
|
+
DevService.check_running_daemon if options[:quiet]
|
21
|
+
DevService.check_skaffold_config_existence(config_path)
|
15
22
|
cluster_id, cluster_name = start_create_cluster
|
16
23
|
kubeconfig = wait_cluster_creation(cluster_name)
|
17
|
-
|
24
|
+
|
25
|
+
if options[:quiet]
|
26
|
+
launch_demonise_skaffold(config_path)
|
27
|
+
else
|
28
|
+
DevService.start_basic_skaffold(config_path, options)
|
29
|
+
end
|
18
30
|
ensure
|
19
31
|
if defined?(cluster_name).present? && defined?(cluster_id).present?
|
20
32
|
kubeconfig = defined?(kubeconfig).present? ? kubeconfig : nil
|
@@ -22,17 +34,28 @@ module Uffizzi
|
|
22
34
|
end
|
23
35
|
end
|
24
36
|
|
25
|
-
|
37
|
+
desc 'stop', 'Stop dev environment'
|
38
|
+
def stop
|
39
|
+
return Uffizzi.ui.say('Uffizzi dev is not running') unless File.exist?(DevService.pid_path)
|
40
|
+
|
41
|
+
pid = File.read(DevService.pid_path).to_i
|
42
|
+
File.delete(DevService.pid_path)
|
26
43
|
|
27
|
-
|
28
|
-
|
29
|
-
|
44
|
+
Uffizzi.process.kill('QUIT', pid)
|
45
|
+
Uffizzi.ui.say('Uffizzi dev was stopped')
|
46
|
+
rescue Errno::ESRCH
|
47
|
+
Uffizzi.ui.say('Uffizzi dev is not running')
|
48
|
+
File.delete(DevService.pid_path)
|
30
49
|
end
|
31
50
|
|
51
|
+
private
|
52
|
+
|
32
53
|
def start_create_cluster
|
33
|
-
|
34
|
-
|
35
|
-
|
54
|
+
params = cluster_creation_params(
|
55
|
+
name: ClusterService.generate_name,
|
56
|
+
creation_source: ClusterService::MANUAL_CREATION_SOURCE,
|
57
|
+
k8s_version: options[:"k8s-version"],
|
58
|
+
)
|
36
59
|
Uffizzi.ui.say('Start creating a cluster')
|
37
60
|
response = create_cluster(ConfigFile.read_option(:server), project_slug, params)
|
38
61
|
return ResponseHelper.handle_failed_response(response) unless ResponseHelper.created?(response)
|
@@ -56,7 +79,7 @@ module Uffizzi
|
|
56
79
|
end
|
57
80
|
|
58
81
|
def handle_succeed_cluster_creation(cluster_data)
|
59
|
-
kubeconfig_path = KubeconfigService.default_path
|
82
|
+
kubeconfig_path = options[:kubeconfig] || KubeconfigService.default_path
|
60
83
|
parsed_kubeconfig = parse_kubeconfig(cluster_data[:kubeconfig])
|
61
84
|
|
62
85
|
Uffizzi.ui.say("Cluster with name: #{cluster_data[:name]} was created.")
|
@@ -85,7 +108,7 @@ module Uffizzi
|
|
85
108
|
ConfigFile.write_option(:clusters, clusters_config)
|
86
109
|
end
|
87
110
|
|
88
|
-
def cluster_creation_params(name
|
111
|
+
def cluster_creation_params(name:, creation_source:, k8s_version:)
|
89
112
|
oidc_token = Uffizzi::ConfigFile.read_option(:oidc_token)
|
90
113
|
|
91
114
|
{
|
@@ -93,12 +116,15 @@ module Uffizzi
|
|
93
116
|
name: name,
|
94
117
|
manifest: nil,
|
95
118
|
creation_source: creation_source,
|
119
|
+
k8s_version: k8s_version,
|
96
120
|
},
|
97
121
|
token: oidc_token,
|
98
122
|
}
|
99
123
|
end
|
100
124
|
|
101
125
|
def handle_delete_cluster(cluster_id, cluster_name, kubeconfig)
|
126
|
+
return if cluster_id.nil? || cluster_name.nil?
|
127
|
+
|
102
128
|
exclude_kubeconfig(cluster_id, kubeconfig) if kubeconfig.present?
|
103
129
|
|
104
130
|
params = {
|
@@ -149,25 +175,19 @@ module Uffizzi
|
|
149
175
|
Psych.safe_load(Base64.decode64(kubeconfig))
|
150
176
|
end
|
151
177
|
|
152
|
-
def
|
153
|
-
Uffizzi.
|
154
|
-
cmd = "skaffold dev --filename='#{config_path}'"
|
178
|
+
def launch_demonise_skaffold(config_path)
|
179
|
+
Uffizzi.process.daemon(true)
|
155
180
|
|
156
|
-
|
157
|
-
|
158
|
-
wait_thr.value
|
181
|
+
at_exit do
|
182
|
+
File.delete(DevService.pid_path) if File.exist?(DevService.pid_path)
|
159
183
|
end
|
160
|
-
end
|
161
|
-
|
162
|
-
def check_skaffold_existence
|
163
|
-
cmd = 'skaffold version'
|
164
|
-
stdout_str, stderr_str = Uffizzi.ui.capture3(cmd)
|
165
|
-
|
166
|
-
return if stdout_str.present? && stderr_str.blank?
|
167
184
|
|
168
|
-
|
185
|
+
File.delete(DevService.logs_path) if File.exist?(DevService.logs_path)
|
186
|
+
File.write(DevService.pid_path, Uffizzi.process.pid)
|
187
|
+
DevService.start_check_pid_file_existence
|
188
|
+
DevService.start_demonised_skaffold(config_path, options)
|
169
189
|
rescue StandardError => e
|
170
|
-
|
190
|
+
File.open(DevService.logs_path, 'a') { |f| f.puts(e.message) }
|
171
191
|
end
|
172
192
|
|
173
193
|
def project_slug
|
@@ -4,7 +4,6 @@ require 'uffizzi'
|
|
4
4
|
require 'uffizzi/auth_helper'
|
5
5
|
require 'uffizzi/response_helper'
|
6
6
|
require 'uffizzi/services/preview_service'
|
7
|
-
require 'uffizzi/services/command_service'
|
8
7
|
|
9
8
|
module Uffizzi
|
10
9
|
class Cli::Preview::Service < Thor
|
@@ -12,8 +11,7 @@ module Uffizzi
|
|
12
11
|
|
13
12
|
desc 'logs [LOGS_TYPE] [DEPLOYMENT_ID] [CONTAINER_NAME]', 'Show the logs for a container service of a preview'
|
14
13
|
def logs(logs_type, deployment_name, container_name = args)
|
15
|
-
|
16
|
-
return Uffizzi.ui.say('This command needs project to be set in config file') unless CommandService.project_set?(options)
|
14
|
+
Uffizzi::AuthHelper.check_login(options[:project])
|
17
15
|
|
18
16
|
deployment_id = PreviewService.read_deployment_id(deployment_name)
|
19
17
|
response = service_logs_response(logs_type, deployment_id, container_name)
|
@@ -28,8 +26,7 @@ module Uffizzi
|
|
28
26
|
|
29
27
|
desc 'list [DEPLOYMENT_ID]', 'List the container services of a given compose environment (preview)'
|
30
28
|
def list(deployment_name)
|
31
|
-
|
32
|
-
return Uffizzi.ui.say('This command needs project to be set in config file') unless CommandService.project_set?(options)
|
29
|
+
Uffizzi::AuthHelper.check_login(options[:project])
|
33
30
|
|
34
31
|
project_slug = options[:project].nil? ? ConfigFile.read_option(:project) : options[:project]
|
35
32
|
server = ConfigFile.read_option(:server)
|
data/lib/uffizzi/cli/preview.rb
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
require 'uffizzi'
|
4
4
|
require 'uffizzi/auth_helper'
|
5
5
|
require 'uffizzi/services/preview_service'
|
6
|
-
require 'uffizzi/services/command_service'
|
7
6
|
require 'uffizzi/services/github_service'
|
8
7
|
|
9
8
|
module Uffizzi
|
@@ -55,8 +54,7 @@ module Uffizzi
|
|
55
54
|
|
56
55
|
def run(command, file_path: nil, deployment_name: nil)
|
57
56
|
Uffizzi.ui.output_format = options[:output]
|
58
|
-
|
59
|
-
raise Uffizzi::Error.new('This command needs project to be set in config file') unless CommandService.project_set?(options)
|
57
|
+
Uffizzi::AuthHelper.check_login(options[:project])
|
60
58
|
|
61
59
|
project_slug = options[:project].nil? ? ConfigFile.read_option(:project) : options[:project]
|
62
60
|
|
@@ -5,7 +5,6 @@ require 'uffizzi/auth_helper'
|
|
5
5
|
require 'uffizzi/response_helper'
|
6
6
|
require 'uffizzi/services/compose_file_service'
|
7
7
|
require 'uffizzi/services/env_variables_service'
|
8
|
-
require 'uffizzi/services/command_service'
|
9
8
|
|
10
9
|
module Uffizzi
|
11
10
|
class Cli::Project::Compose < Thor
|
@@ -29,8 +28,7 @@ module Uffizzi
|
|
29
28
|
private
|
30
29
|
|
31
30
|
def run(command)
|
32
|
-
|
33
|
-
return Uffizzi.ui.say('This command needs project to be set in config file') unless CommandService.project_set?(options)
|
31
|
+
Uffizzi::AuthHelper.check_login(options[:project])
|
34
32
|
|
35
33
|
project_slug = options[:project].nil? ? ConfigFile.read_option(:project) : options[:project]
|
36
34
|
file_path = options[:file]
|
data/lib/uffizzi/cli/project.rb
CHANGED
data/lib/uffizzi/config_file.rb
CHANGED
@@ -0,0 +1,108 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uffizzi/clients/api/api_client'
|
4
|
+
|
5
|
+
class DevService
|
6
|
+
class << self
|
7
|
+
include ApiClient
|
8
|
+
|
9
|
+
DEFAULT_REGISTRY_REPO = 'registry.uffizzi.com'
|
10
|
+
|
11
|
+
def check_running_daemon
|
12
|
+
return unless File.exist?(pid_path)
|
13
|
+
|
14
|
+
pid = File.read(pid_path)
|
15
|
+
File.delete(pid_path) if pid.blank?
|
16
|
+
Uffizzi.process.kill(0, pid.to_i)
|
17
|
+
|
18
|
+
Uffizzi.ui.say_error_and_exit("You have already started uffizzi dev as daemon. To stop the process do 'uffizzi dev stop'")
|
19
|
+
rescue Errno::ESRCH
|
20
|
+
File.delete(pid_path)
|
21
|
+
end
|
22
|
+
|
23
|
+
def start_check_pid_file_existence
|
24
|
+
Thread.new do
|
25
|
+
loop do
|
26
|
+
Uffizzi.process.kill('QUIT', Uffizzi.process.pid) unless File.exist?(pid_path)
|
27
|
+
sleep(1)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def start_basic_skaffold(config_path, options)
|
33
|
+
Uffizzi.ui.say('Start skaffold')
|
34
|
+
cmd = build_skaffold_dev_command(config_path, options)
|
35
|
+
|
36
|
+
Uffizzi.ui.popen2e(cmd) do |_stdin, stdout_and_stderr, wait_thr|
|
37
|
+
stdout_and_stderr.each { |l| Uffizzi.ui.say(l) }
|
38
|
+
wait_thr.value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def start_demonised_skaffold(config_path, options)
|
43
|
+
File.write(logs_path, "Start skaffold\n")
|
44
|
+
cmd = build_skaffold_dev_command(config_path, options)
|
45
|
+
|
46
|
+
Uffizzi.ui.popen2e(cmd) do |_stdin, stdout_and_stderr, wait_thr|
|
47
|
+
File.open(logs_path, 'a') do |f|
|
48
|
+
stdout_and_stderr.each do |line|
|
49
|
+
f.puts(line)
|
50
|
+
f.flush
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
wait_thr.value
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_skaffold_existence
|
59
|
+
cmd = 'skaffold version'
|
60
|
+
stdout_str, stderr_str = Uffizzi.ui.capture3(cmd)
|
61
|
+
|
62
|
+
return if stdout_str.present? && stderr_str.blank?
|
63
|
+
|
64
|
+
Uffizzi.ui.say_error_and_exit(stderr_str)
|
65
|
+
rescue StandardError => e
|
66
|
+
Uffizzi.ui.say_error_and_exit(e.message)
|
67
|
+
end
|
68
|
+
|
69
|
+
def check_skaffold_config_existence(config_path)
|
70
|
+
msg = 'A valid dev environment configuration is required. Please provide a valid config,'\
|
71
|
+
"\r\n"\
|
72
|
+
'or run `skaffold init` to generate a skaffold.yaml configuration.'\
|
73
|
+
"\r\n"\
|
74
|
+
'See the `uffizzi dev start --help` page for supported configs and usage details.'
|
75
|
+
|
76
|
+
Uffizzi.ui.say_error_and_exit(msg) unless File.exist?(config_path)
|
77
|
+
end
|
78
|
+
|
79
|
+
def pid_path
|
80
|
+
File.join(Uffizzi::ConfigFile::CONFIG_DIR, 'uffizzi_dev.pid')
|
81
|
+
end
|
82
|
+
|
83
|
+
def logs_path
|
84
|
+
File.join(Uffizzi::ConfigFile::CONFIG_DIR, 'uffizzi_dev.log')
|
85
|
+
end
|
86
|
+
|
87
|
+
def build_skaffold_dev_command(config_path, options)
|
88
|
+
cmd = [
|
89
|
+
'skaffold dev',
|
90
|
+
"--filename='#{config_path}'",
|
91
|
+
"--default-repo='#{default_registry_repo(options[:'default-repo'])}'",
|
92
|
+
"--kubeconfig='#{default_kubeconfig_path(options[:kubeconfig])}'",
|
93
|
+
]
|
94
|
+
|
95
|
+
cmd.join(' ')
|
96
|
+
end
|
97
|
+
|
98
|
+
def default_registry_repo(repo)
|
99
|
+
repo || DEFAULT_REGISTRY_REPO
|
100
|
+
end
|
101
|
+
|
102
|
+
def default_kubeconfig_path(kubeconfig_path)
|
103
|
+
path = kubeconfig_path || KubeconfigService.default_path
|
104
|
+
|
105
|
+
File.expand_path(path)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -81,7 +81,9 @@ class KubeconfigService
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def default_path
|
84
|
-
kubeconfig_env_path || Uffizzi.configuration.default_kubeconfig_path
|
84
|
+
path = kubeconfig_env_path || Uffizzi.configuration.default_kubeconfig_path
|
85
|
+
|
86
|
+
File.expand_path(path)
|
85
87
|
end
|
86
88
|
|
87
89
|
def read_kubeconfig(filepath)
|
data/lib/uffizzi/version.rb
CHANGED
data/lib/uffizzi.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
uffizzi cluster create -h
|
1
2
|
uffizzi-cluster-create - create a cluster
|
2
3
|
================================================================
|
3
4
|
|
@@ -12,9 +13,17 @@ uffizzi-cluster-create - create a cluster
|
|
12
13
|
https://docs.uffizzi.com/references/cli/
|
13
14
|
|
14
15
|
## FLAGS
|
16
|
+
|
15
17
|
--name
|
16
18
|
Option is deprecated and will be removed in the newer versions.
|
17
|
-
Please use a positional argument instead: uffizzi cluster create
|
19
|
+
Please use a positional argument instead: uffizzi cluster create
|
20
|
+
my-awesome-name.
|
21
|
+
|
22
|
+
--k8s-version=<api-version>
|
23
|
+
Specify which version of the Kubernetes API to use when creating
|
24
|
+
the cluster, formatted as [MAJOR].[MINOR]. Defaults to 1.27.
|
25
|
+
Minor versions point to the latest release of the corresponding k3s
|
26
|
+
minor version. See https://github.com/k3s-io/k3s/releases
|
18
27
|
|
19
28
|
--kubeconfig="/path/to/your/kubeconfig"
|
20
29
|
Path to kubeconfig file
|
data/man/uffizzi-dev-start
CHANGED
@@ -1,29 +1,99 @@
|
|
1
1
|
.\" generated with Ronn-NG/v0.9.1
|
2
2
|
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
3
|
-
.TH "UFFIZZI\-DEV\-START" "" "
|
3
|
+
.TH "UFFIZZI\-DEV\-START" "" "October 2023" ""
|
4
4
|
.SH "NAME"
|
5
|
-
\fBuffizzi\-dev\-start\fR \- start development environment
|
5
|
+
\fBuffizzi\-dev\-start\fR \- start a development environment
|
6
6
|
.SH "SYNOPSIS"
|
7
7
|
.nf
|
8
|
-
uffizzi dev start [
|
8
|
+
uffizzi dev start [CONFIG_FILE] [FLAGS]
|
9
9
|
.fi
|
10
10
|
.SH "DESCRIPTION"
|
11
11
|
.nf
|
12
|
-
Creates a
|
13
|
-
|
14
|
-
|
12
|
+
Creates a Uffizzi cluster preconfigured for development
|
13
|
+
workflows, including building, pushing, and deploying
|
14
|
+
your changes every time project files are saved\.
|
15
|
+
current\-context is updated in kubeconfig file\.
|
16
|
+
|
17
|
+
This command watches for file changes in a given local
|
18
|
+
project directory, as specified in your configuration file\.
|
19
|
+
It then serializes those changes and redeploys them onto
|
20
|
+
a Uffizzi cluster\.
|
21
|
+
|
22
|
+
The command looks for a configuration at the specified
|
23
|
+
path CONFIG_FILE\. Skaffold configurations are currently
|
24
|
+
supported\. For help creating a skaffold\.yaml file, see:
|
25
|
+
https://skaffold\.dev/docs/init/
|
26
|
+
|
27
|
+
If a kubeconfig exists
|
15
28
|
|
16
29
|
For more information on Uffizzi clusters, see:
|
17
30
|
https://docs\.uffizzi\.com/references/cli/
|
18
31
|
.fi
|
32
|
+
.SH "POSITIONAL ARGUMENTS"
|
33
|
+
.nf
|
34
|
+
[CONFIG_FILE]
|
35
|
+
Path to the development environment configuration file\.
|
36
|
+
Currently supports skaffold\.yaml files\.
|
37
|
+
.fi
|
38
|
+
.SH "FLAGS"
|
39
|
+
.nf
|
40
|
+
\-\-build="<local\-or\-remote>"
|
41
|
+
This option specifies whether to build images on the
|
42
|
+
local environment or on the remote Uffizzi cluster\.
|
43
|
+
Possible values are "local" or "remote"\.
|
44
|
+
|
45
|
+
\-\-default\-repo="<container\-registry\-domain>"
|
46
|
+
A public or private repo used to push/pull build
|
47
|
+
artifacts\. Overrides the global default image registry:
|
48
|
+
"registry\.uffizzi\.com"\. See `uffizzi connect \-h` for
|
49
|
+
adding private registry credentials\.
|
50
|
+
|
51
|
+
\-\-quiet, \-q
|
52
|
+
Run the development process in detached mode (i\.e\., in
|
53
|
+
the background)\. Without this option, logs are streamed
|
54
|
+
to the terminal in the foreground\. Run \'uffizzi dev stop`
|
55
|
+
to stop the detached process\.
|
56
|
+
|
57
|
+
\-\-help, \-h
|
58
|
+
Show this message and exit\.
|
59
|
+
|
60
|
+
\-\-kubeconfig="/path/to/your/kubeconfig"
|
61
|
+
Path to kubeconfig file\. If this option is not specified,
|
62
|
+
this command looks for the file at ~/\.kube/config\.
|
63
|
+
.fi
|
19
64
|
.SH "EXAMPLES"
|
20
65
|
.nf
|
21
|
-
|
66
|
+
If your configuration file is in the current working
|
67
|
+
directory and you want to use an auto\-generated name,
|
68
|
+
run:
|
22
69
|
|
23
70
|
$ uffizzi dev start
|
24
71
|
|
25
|
-
To start
|
72
|
+
To start a dev environment using a skaffold\.yaml config
|
73
|
+
file in directory \'~/foo\', run:
|
74
|
+
|
75
|
+
$ uffizzi dev start ~/foo/skaffold\.yaml
|
76
|
+
|
77
|
+
To start a dev environment in quiet mode,
|
78
|
+
run:
|
79
|
+
|
80
|
+
$ uffizzi dev start \-\-quiet
|
81
|
+
|
82
|
+
To push your build artifacts to a private Docker Hub repo
|
83
|
+
called \'acme/foo\', first add your Docker Hub credentials:
|
84
|
+
|
85
|
+
$ uffizzi connect docker\-hub
|
86
|
+
(See `uffizzi connect \-h` for other registry options)
|
87
|
+
|
88
|
+
\|\.\|\.\|\.then override the default repo:
|
89
|
+
|
90
|
+
$ uffizzi dev start \e
|
91
|
+
\-\-default\-repo="hub\.docker\.com/acme/foo"
|
92
|
+
|
93
|
+
To start a dev environment using an alternate kubeconfig file,
|
94
|
+
run:
|
26
95
|
|
27
|
-
$ uffizzi
|
96
|
+
$ uffizzi dev start \e
|
97
|
+
\-\-kubeconfig="/path/to/alternate/kubeconfig"
|
28
98
|
.fi
|
29
99
|
|
data/man/uffizzi-dev-start.ronn
CHANGED
@@ -1,22 +1,91 @@
|
|
1
|
-
uffizzi-dev-start - start development environment
|
1
|
+
uffizzi-dev-start - start a development environment
|
2
2
|
================================================================
|
3
3
|
|
4
4
|
## SYNOPSIS
|
5
|
-
uffizzi dev start [
|
5
|
+
uffizzi dev start [CONFIG_FILE] [FLAGS]
|
6
6
|
|
7
7
|
## DESCRIPTION
|
8
|
-
Creates a
|
9
|
-
|
10
|
-
|
8
|
+
Creates a Uffizzi cluster preconfigured for development
|
9
|
+
workflows, including building, pushing, and deploying
|
10
|
+
your changes every time project files are saved.
|
11
|
+
current-context is updated in kubeconfig file.
|
12
|
+
|
13
|
+
This command watches for file changes in a given local
|
14
|
+
project directory, as specified in your configuration file.
|
15
|
+
It then serializes those changes and redeploys them onto
|
16
|
+
a Uffizzi cluster.
|
17
|
+
|
18
|
+
The command looks for a configuration at the specified
|
19
|
+
path CONFIG_FILE. Skaffold configurations are currently
|
20
|
+
supported. For help creating a skaffold.yaml file, see:
|
21
|
+
https://skaffold.dev/docs/init/
|
22
|
+
|
23
|
+
If a kubeconfig exists
|
11
24
|
|
12
25
|
For more information on Uffizzi clusters, see:
|
13
26
|
https://docs.uffizzi.com/references/cli/
|
14
27
|
|
28
|
+
## POSITIONAL ARGUMENTS
|
29
|
+
[CONFIG_FILE]
|
30
|
+
Path to the development environment configuration file.
|
31
|
+
Currently supports skaffold.yaml files.
|
32
|
+
|
33
|
+
## FLAGS
|
34
|
+
--k8s-version=<api-version>
|
35
|
+
Specify which version of the Kubernetes API to use when creating
|
36
|
+
the cluster, formatted as [MAJOR].[MINOR]. Defaults to 1.27.
|
37
|
+
Minor versions point to the latest release of the corresponding k3s
|
38
|
+
minor version. See https://github.com/k3s-io/k3s/releases
|
39
|
+
|
40
|
+
--default-repo="<container-registry-domain>"
|
41
|
+
A public or private repo used to push/pull build
|
42
|
+
artifacts. Overrides the global default image registry:
|
43
|
+
"registry.uffizzi.com". See `uffizzi connect -h` for
|
44
|
+
adding private registry credentials.
|
45
|
+
|
46
|
+
--quiet, -q
|
47
|
+
Run the development process in detached mode (i.e., in
|
48
|
+
the background). Without this option, logs are streamed
|
49
|
+
to the terminal in the foreground. Run 'uffizzi dev stop`
|
50
|
+
to stop the detached process.
|
51
|
+
|
52
|
+
--help, -h
|
53
|
+
Show this message and exit.
|
54
|
+
|
55
|
+
--kubeconfig="/path/to/your/kubeconfig"
|
56
|
+
Path to kubeconfig file. If this option is not specified,
|
57
|
+
this command looks for the file at ~/.kube/config.
|
58
|
+
|
15
59
|
## EXAMPLES
|
16
|
-
|
60
|
+
If your configuration file is in the current working
|
61
|
+
directory and you want to use an auto-generated name,
|
62
|
+
run:
|
17
63
|
|
18
64
|
$ uffizzi dev start
|
19
65
|
|
20
|
-
To start
|
66
|
+
To start a dev environment using a skaffold.yaml config
|
67
|
+
file in directory '~/foo', run:
|
68
|
+
|
69
|
+
$ uffizzi dev start ~/foo/skaffold.yaml
|
70
|
+
|
71
|
+
To start a dev environment in quiet mode,
|
72
|
+
run:
|
73
|
+
|
74
|
+
$ uffizzi dev start --quiet
|
75
|
+
|
76
|
+
To push your build artifacts to a private Docker Hub repo
|
77
|
+
called 'acme/foo', first add your Docker Hub credentials:
|
78
|
+
|
79
|
+
$ uffizzi connect docker-hub
|
80
|
+
(See `uffizzi connect -h` for other registry options)
|
81
|
+
|
82
|
+
...then override the default repo:
|
83
|
+
|
84
|
+
$ uffizzi dev start \
|
85
|
+
--default-repo="hub.docker.com/acme/foo"
|
86
|
+
|
87
|
+
To start a dev environment using an alternate kubeconfig file,
|
88
|
+
run:
|
21
89
|
|
22
|
-
$ uffizzi
|
90
|
+
$ uffizzi dev start \
|
91
|
+
--kubeconfig="/path/to/alternate/kubeconfig"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
.\" generated with Ronn-NG/v0.9.1
|
2
|
+
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
3
|
+
.TH "UFFIZZI\-DEV\-STOP" "" "October 2023" ""
|
4
|
+
.SH "NAME"
|
5
|
+
\fBuffizzi\-dev\-stop\fR \- stop a development environment
|
6
|
+
.SH "SYNOPSIS"
|
7
|
+
.nf
|
8
|
+
uffizzi dev stop
|
9
|
+
.fi
|
10
|
+
.SH "DESCRIPTION"
|
11
|
+
.nf
|
12
|
+
Stops a dev environment and deletes the backing
|
13
|
+
Uffizzi cluster resources, including any persistent
|
14
|
+
volumes, and the namespace itself\. The Uffizzi
|
15
|
+
cluster config is deleted from the kubeconfig file\.
|
16
|
+
|
17
|
+
This command watches for file changes in a given local
|
18
|
+
project directory, as specified in your configuration file\.
|
19
|
+
It then serializes those changes and redeploys them onto
|
20
|
+
a Uffizzi cluster\.
|
21
|
+
|
22
|
+
The command looks for a configuration at the specified
|
23
|
+
path CONFIG_FILE\. Skaffold configurations are currently
|
24
|
+
supported\. For help creating a skaffold\.yaml file, see:
|
25
|
+
https://skaffold\.dev/docs/init/
|
26
|
+
|
27
|
+
For more information on Uffizzi clusters, see:
|
28
|
+
https://docs\.uffizzi\.com/references/cli/
|
29
|
+
.fi
|
30
|
+
.SH "FLAGS"
|
31
|
+
.nf
|
32
|
+
\-\-help, \-h
|
33
|
+
Show this message and exit\.
|
34
|
+
.fi
|
35
|
+
.SH "EXAMPLES"
|
36
|
+
.nf
|
37
|
+
To stop a dev environment, run:
|
38
|
+
|
39
|
+
$ uffizzi dev stop
|
40
|
+
.fi
|
41
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
uffizzi-dev-stop - stop a development environment
|
2
|
+
================================================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
uffizzi dev stop
|
6
|
+
|
7
|
+
## DESCRIPTION
|
8
|
+
Stops a dev environment and deletes the backing
|
9
|
+
Uffizzi cluster resources, including any persistent
|
10
|
+
volumes, and the namespace itself. The Uffizzi
|
11
|
+
cluster config is deleted from the kubeconfig file.
|
12
|
+
|
13
|
+
This command watches for file changes in a given local
|
14
|
+
project directory, as specified in your configuration file.
|
15
|
+
It then serializes those changes and redeploys them onto
|
16
|
+
a Uffizzi cluster.
|
17
|
+
|
18
|
+
The command looks for a configuration at the specified
|
19
|
+
path CONFIG_FILE. Skaffold configurations are currently
|
20
|
+
supported. For help creating a skaffold.yaml file, see:
|
21
|
+
https://skaffold.dev/docs/init/
|
22
|
+
|
23
|
+
For more information on Uffizzi clusters, see:
|
24
|
+
https://docs.uffizzi.com/references/cli/
|
25
|
+
|
26
|
+
## FLAGS
|
27
|
+
--help, -h
|
28
|
+
Show this message and exit.
|
29
|
+
|
30
|
+
## EXAMPLES
|
31
|
+
To stop a dev environment, run:
|
32
|
+
|
33
|
+
$ uffizzi dev stop
|
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.1.
|
4
|
+
version: 2.1.3
|
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
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -448,8 +448,8 @@ files:
|
|
448
448
|
- lib/uffizzi/response_helper.rb
|
449
449
|
- lib/uffizzi/services/cluster/disconnect_service.rb
|
450
450
|
- lib/uffizzi/services/cluster_service.rb
|
451
|
-
- lib/uffizzi/services/command_service.rb
|
452
451
|
- lib/uffizzi/services/compose_file_service.rb
|
452
|
+
- lib/uffizzi/services/dev_service.rb
|
453
453
|
- lib/uffizzi/services/env_variables_service.rb
|
454
454
|
- lib/uffizzi/services/github_service.rb
|
455
455
|
- lib/uffizzi/services/kubeconfig_service.rb
|
@@ -521,6 +521,8 @@ files:
|
|
521
521
|
- man/uffizzi-connect.ronn
|
522
522
|
- man/uffizzi-dev-start
|
523
523
|
- man/uffizzi-dev-start.ronn
|
524
|
+
- man/uffizzi-dev-stop
|
525
|
+
- man/uffizzi-dev-stop.ronn
|
524
526
|
- man/uffizzi-disconnect
|
525
527
|
- man/uffizzi-disconnect.ronn
|
526
528
|
- man/uffizzi-login
|