uffizzi-cli 0.3.8 → 0.4.0
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 +4 -4
- data/README.md +10 -0
- data/lib/uffizzi/cli/disconnect.rb +43 -0
- data/lib/uffizzi/cli/preview/service.rb +40 -3
- data/lib/uffizzi/cli.rb +10 -0
- data/lib/uffizzi/clients/api/api_client.rb +14 -0
- data/lib/uffizzi/clients/api/api_routes.rb +8 -0
- data/lib/uffizzi/error.rb +5 -0
- data/lib/uffizzi/version.rb +1 -1
- data/lib/uffizzi.rb +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f517c288807e4cb2a7480303b9c04b2856fe76885c79abc3bfb39f77dee24abc
|
4
|
+
data.tar.gz: be93d597d0a6892854974706d2bd629c5b323cffc6ee682f2623884d61d013ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54df68a43dddc1827a83dfa0f172c57d68b12f6ac52064990b02cd69ccb6a27bced898db4420f146fdd55dcefc017317142b7c587213114af2135dd0a4cc2444
|
7
|
+
data.tar.gz: ff40d04955d46452f0823788c1e62b6de2267fc4623cf4cdd0448e107d78610a1d021051346cd7db55f1b5c1ff18b27da9c81328490fb98c3bb19bf4e0a406aa
|
data/README.md
CHANGED
@@ -176,6 +176,16 @@ $ uffizzi config delete OPTION
|
|
176
176
|
|
177
177
|
Deletes specified option.
|
178
178
|
|
179
|
+
### disconnect ###
|
180
|
+
|
181
|
+
```
|
182
|
+
$ uffizzi disconnect CREDENTIAL_TYPE
|
183
|
+
```
|
184
|
+
|
185
|
+
Deletes credential of specified type
|
186
|
+
|
187
|
+
Supported credential types - `docker-hub`, `acr`, `ecr`, `gcr`
|
188
|
+
|
179
189
|
## Git workflow for the app:
|
180
190
|
|
181
191
|
1. Clone the repository and checkout to `develop` branch
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uffizzi'
|
4
|
+
|
5
|
+
module Uffizzi
|
6
|
+
class CLI::Disconnect
|
7
|
+
include ApiClient
|
8
|
+
|
9
|
+
def run(credential_type)
|
10
|
+
connection_type = case credential_type
|
11
|
+
when 'docker-hub'
|
12
|
+
Uffizzi.configuration.credential_types[:dockerhub]
|
13
|
+
when 'acr'
|
14
|
+
Uffizzi.configuration.credential_types[:azure]
|
15
|
+
when 'ecr'
|
16
|
+
Uffizzi.configuration.credential_types[:amazon]
|
17
|
+
when 'gcr'
|
18
|
+
Uffizzi.configuration.credential_types[:google]
|
19
|
+
else
|
20
|
+
raise Uffizzi::Error.new('Unsupported credential type.')
|
21
|
+
end
|
22
|
+
|
23
|
+
response = delete_credential(ConfigFile.read_option(:hostname), connection_type)
|
24
|
+
|
25
|
+
if ResponseHelper.no_content?(response)
|
26
|
+
Uffizzi.ui.say("Successfully disconnected #{connection_name(credential_type)} connection")
|
27
|
+
else
|
28
|
+
ResponseHelper.handle_failed_response(response)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def connection_name(credential_type)
|
35
|
+
{
|
36
|
+
'docker-hub' => 'DockerHub',
|
37
|
+
'acr' => 'ACR',
|
38
|
+
'ecr' => 'ECR',
|
39
|
+
'gcr' => 'GCR',
|
40
|
+
}[credential_type]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -9,7 +9,23 @@ module Uffizzi
|
|
9
9
|
class CLI::Preview::Service < Thor
|
10
10
|
include ApiClient
|
11
11
|
|
12
|
-
desc '
|
12
|
+
desc 'uffizzi preview service logs [LOGS_TYPE] [DEPLOYMENT_ID] [CONTAINER_NAME]', 'logs'
|
13
|
+
def logs(logs_type, deployment_name, container_name = args)
|
14
|
+
return Uffizzi.ui.say('You are not logged in.') unless Uffizzi::AuthHelper.signed_in?
|
15
|
+
return Uffizzi.ui.say('This command needs project to be set in config file') unless Uffizzi::AuthHelper.project_set?
|
16
|
+
|
17
|
+
deployment_id = PreviewService.read_deployment_id(deployment_name)
|
18
|
+
response = service_logs_response(logs_type, deployment_id, container_name)
|
19
|
+
return Uffizzi.ui.say(response[:errors]) if response[:errors]
|
20
|
+
|
21
|
+
if ResponseHelper.ok?(response)
|
22
|
+
handle_succeed_logs_response(response, container_name)
|
23
|
+
else
|
24
|
+
ResponseHelper.handle_failed_response(response)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'uffizzi preview service logs [DEPLOYMENT_ID]', 'list'
|
13
29
|
def list(deployment_name)
|
14
30
|
return Uffizzi.ui.say('You are not logged in.') unless Uffizzi::AuthHelper.signed_in?
|
15
31
|
return Uffizzi.ui.say('This command needs project to be set in config file') unless Uffizzi::AuthHelper.project_set?
|
@@ -20,7 +36,7 @@ module Uffizzi
|
|
20
36
|
response = fetch_deployment_services(hostname, project_slug, deployment_id)
|
21
37
|
|
22
38
|
if ResponseHelper.ok?(response)
|
23
|
-
|
39
|
+
handle_succeed_list_response(response, deployment_name)
|
24
40
|
else
|
25
41
|
ResponseHelper.handle_failed_response(response)
|
26
42
|
end
|
@@ -28,7 +44,19 @@ module Uffizzi
|
|
28
44
|
|
29
45
|
private
|
30
46
|
|
31
|
-
def
|
47
|
+
def service_logs_response(logs_type, deployment_id, container_name)
|
48
|
+
project_slug = ConfigFile.read_option(:project)
|
49
|
+
hostname = ConfigFile.read_option(:hostname)
|
50
|
+
|
51
|
+
case logs_type
|
52
|
+
when 'container'
|
53
|
+
fetch_deployment_service_logs(hostname, project_slug, deployment_id, container_name)
|
54
|
+
else
|
55
|
+
raise Uffizzi::Error.new('Unknown log type')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def handle_succeed_list_response(response, deployment_name)
|
32
60
|
services = response[:body][:containers] || []
|
33
61
|
return Uffizzi.ui.say("There are no services associated with the preview #{deployment_name}") if services.empty?
|
34
62
|
|
@@ -36,5 +64,14 @@ module Uffizzi
|
|
36
64
|
Uffizzi.ui.say(service)
|
37
65
|
end
|
38
66
|
end
|
67
|
+
|
68
|
+
def handle_succeed_logs_response(response, container_name)
|
69
|
+
logs = response[:body][:logs] || []
|
70
|
+
return Uffizzi.ui.say("The service #{container_name} has no logs") if logs.empty?
|
71
|
+
|
72
|
+
logs.each do |log|
|
73
|
+
Uffizzi.ui.say(log)
|
74
|
+
end
|
75
|
+
end
|
39
76
|
end
|
40
77
|
end
|
data/lib/uffizzi/cli.rb
CHANGED
@@ -8,6 +8,10 @@ module Uffizzi
|
|
8
8
|
require_relative 'cli/common'
|
9
9
|
class_option :help, type: :boolean, aliases: ['-h', 'help']
|
10
10
|
|
11
|
+
def self.exit_on_failure?
|
12
|
+
true
|
13
|
+
end
|
14
|
+
|
11
15
|
desc 'version', 'show version'
|
12
16
|
def version
|
13
17
|
require_relative 'version'
|
@@ -54,5 +58,11 @@ module Uffizzi
|
|
54
58
|
require_relative 'cli/connect'
|
55
59
|
Connect.new.run(credential_type, credential_file_path)
|
56
60
|
end
|
61
|
+
|
62
|
+
desc 'disconect CREDENTIAL_TYPE', 'Disonnect credentials from Uffizzi'
|
63
|
+
def disconnect(credential_type)
|
64
|
+
require_relative 'cli/disconnect'
|
65
|
+
Disconnect.new.run(credential_type)
|
66
|
+
end
|
57
67
|
end
|
58
68
|
end
|
@@ -41,6 +41,20 @@ module ApiClient
|
|
41
41
|
build_response(response)
|
42
42
|
end
|
43
43
|
|
44
|
+
def delete_credential(hostname, credential_type)
|
45
|
+
uri = delete_credential_uri(hostname, credential_type)
|
46
|
+
response = Uffizzi::HttpClient.make_delete_request(uri)
|
47
|
+
|
48
|
+
build_response(response)
|
49
|
+
end
|
50
|
+
|
51
|
+
def fetch_deployment_service_logs(hostname, project_slug, deployment_id, container_name)
|
52
|
+
uri = preview_service_logs_uri(hostname, project_slug, deployment_id, container_name)
|
53
|
+
response = Uffizzi::HttpClient.make_get_request(uri)
|
54
|
+
|
55
|
+
build_response(response)
|
56
|
+
end
|
57
|
+
|
44
58
|
def set_compose_file(hostname, params, project_slug)
|
45
59
|
uri = compose_file_uri(hostname, project_slug)
|
46
60
|
response = Uffizzi::HttpClient.make_post_request(uri, params)
|
@@ -55,4 +55,12 @@ module ApiRoutes
|
|
55
55
|
def preview_services_uri(hostname, project_slug, deployment_id)
|
56
56
|
"#{hostname}/api/cli/v1/projects/#{project_slug}/deployments/#{deployment_id}/containers"
|
57
57
|
end
|
58
|
+
|
59
|
+
def delete_credential_uri(hostname, credential_type)
|
60
|
+
"#{hostname}/api/cli/v1/account/credentials/#{credential_type}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def preview_service_logs_uri(hostname, project_slug, deployment_id, container_name)
|
64
|
+
"#{hostname}/api/cli/v1/projects/#{project_slug}/deployments/#{deployment_id}/containers/#{container_name}/logs"
|
65
|
+
end
|
58
66
|
end
|
data/lib/uffizzi/version.rb
CHANGED
data/lib/uffizzi.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'io/console'
|
4
4
|
require 'tty-spinner'
|
5
5
|
|
6
|
+
require 'thor'
|
7
|
+
require 'uffizzi/error'
|
6
8
|
require 'uffizzi/shell'
|
7
9
|
require 'uffizzi/version'
|
8
10
|
require 'uffizzi/clients/api/api_client'
|
@@ -11,8 +13,6 @@ require 'uffizzi/config_file'
|
|
11
13
|
require_relative '../config/uffizzi'
|
12
14
|
|
13
15
|
module Uffizzi
|
14
|
-
class Error < StandardError; end
|
15
|
-
|
16
16
|
class << self
|
17
17
|
def ui
|
18
18
|
@ui ||= Uffizzi::UI::Shell.new
|
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: 0.
|
4
|
+
version: 0.4.0
|
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: 2022-03-
|
12
|
+
date: 2022-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thor
|
@@ -295,6 +295,7 @@ files:
|
|
295
295
|
- lib/uffizzi/cli/common.rb
|
296
296
|
- lib/uffizzi/cli/config.rb
|
297
297
|
- lib/uffizzi/cli/connect.rb
|
298
|
+
- lib/uffizzi/cli/disconnect.rb
|
298
299
|
- lib/uffizzi/cli/login.rb
|
299
300
|
- lib/uffizzi/cli/logout.rb
|
300
301
|
- lib/uffizzi/cli/preview.rb
|
@@ -306,6 +307,7 @@ files:
|
|
306
307
|
- lib/uffizzi/clients/api/api_routes.rb
|
307
308
|
- lib/uffizzi/clients/api/http_client.rb
|
308
309
|
- lib/uffizzi/config_file.rb
|
310
|
+
- lib/uffizzi/error.rb
|
309
311
|
- lib/uffizzi/response_helper.rb
|
310
312
|
- lib/uffizzi/services/compose_file_service.rb
|
311
313
|
- lib/uffizzi/services/env_variables_service.rb
|