uffizzi-cli 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uffizzi/cli/preview.rb +15 -14
- data/lib/uffizzi/shell.rb +24 -15
- data/lib/uffizzi/version.rb +1 -1
- data/man/uffizzi-preview-list +3 -3
- data/man/uffizzi-preview-list.ronn +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aec0603c01f8385a1793a1017e7bc9c7624a1941389b04410aab4072ca9ba01e
|
4
|
+
data.tar.gz: d3376a7c58bf38d1cb3a6b2947855f1c787f739c2384484ef150d3be0a45acbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa475005282e38146f1f699b6721ec0f9695fb6351f1dff84b4b226da16446b15ef8a4b30b7098828e48f56d5b2182bbc2c4a3ea4f1483fe5255acbb8083a3a9
|
7
|
+
data.tar.gz: 53a8cdb71069aa0d42cb41246ffe6fb9e01681a4a541a0f421ff6fe8111b233e4067e9365110eecc09705aa5ae4c75ca2f828e88df16c8a425092de0e878ed9c
|
data/lib/uffizzi/cli/preview.rb
CHANGED
@@ -15,7 +15,7 @@ module Uffizzi
|
|
15
15
|
|
16
16
|
desc 'list', 'List all previews'
|
17
17
|
method_option :filter, required: false, type: :string, aliases: '-f'
|
18
|
-
method_option :output, required: false, type: :string, aliases: '-o', enum: ['json']
|
18
|
+
method_option :output, required: false, type: :string, aliases: '-o', enum: ['json', 'pretty-json']
|
19
19
|
def list
|
20
20
|
run('list')
|
21
21
|
end
|
@@ -87,6 +87,7 @@ module Uffizzi
|
|
87
87
|
|
88
88
|
def handle_create_command(file_path, project_slug, labels)
|
89
89
|
Uffizzi.ui.disable_stdout unless options[:output].nil?
|
90
|
+
|
90
91
|
params = prepare_params(file_path, labels)
|
91
92
|
|
92
93
|
response = create_deployment(ConfigFile.read_option(:server), project_slug, params)
|
@@ -96,7 +97,7 @@ module Uffizzi
|
|
96
97
|
end
|
97
98
|
|
98
99
|
deployment = response[:body][:deployment]
|
99
|
-
Uffizzi.ui.say("Preview
|
100
|
+
Uffizzi.ui.say("Preview with ID deployment-#{deployment[:id]} was created.")
|
100
101
|
|
101
102
|
success = PreviewService.run_containers_deploy(project_slug, deployment)
|
102
103
|
|
@@ -120,7 +121,7 @@ module Uffizzi
|
|
120
121
|
end
|
121
122
|
|
122
123
|
deployment = response[:body][:deployment]
|
123
|
-
Uffizzi.ui.say("Preview with ID deployment-#{deployment_id} was
|
124
|
+
Uffizzi.ui.say("Preview with ID deployment-#{deployment_id} was updated.")
|
124
125
|
|
125
126
|
success = PreviewService.run_containers_deploy(project_slug, deployment)
|
126
127
|
|
@@ -145,7 +146,8 @@ module Uffizzi
|
|
145
146
|
end
|
146
147
|
|
147
148
|
def handle_succeed_events_response(response)
|
148
|
-
Uffizzi.ui.
|
149
|
+
Uffizzi.ui.output_format = Uffizzi::UI::Shell::PRETTY_JSON
|
150
|
+
Uffizzi.ui.say(response[:body][:events])
|
149
151
|
end
|
150
152
|
|
151
153
|
def handle_delete_command(deployment_name, project_slug)
|
@@ -180,13 +182,12 @@ module Uffizzi
|
|
180
182
|
deployments = response[:body][:deployments] || []
|
181
183
|
raise Uffizzi::Error.new('The project has no active deployments') if deployments.empty?
|
182
184
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
Uffizzi.ui.pretty_say(deployment)
|
188
|
-
end
|
185
|
+
if Uffizzi.ui.output_format.nil?
|
186
|
+
deployments = deployments.reduce('') do |acc, deployment|
|
187
|
+
"#{acc}deployment-#{deployment[:id]}\n"
|
188
|
+
end.strip
|
189
189
|
end
|
190
|
+
Uffizzi.ui.say(deployments)
|
190
191
|
end
|
191
192
|
|
192
193
|
def handle_succeed_delete_response(deployment_id)
|
@@ -202,9 +203,8 @@ module Uffizzi
|
|
202
203
|
|
203
204
|
container
|
204
205
|
end
|
205
|
-
deployment.
|
206
|
-
|
207
|
-
end
|
206
|
+
deployment_data = deployment.reduce('') { |acc, (key, value)| "#{acc}#{key}: #{value}\n" }.strip
|
207
|
+
Uffizzi.ui.say(deployment_data)
|
208
208
|
end
|
209
209
|
|
210
210
|
def hide_secrets(secret_variables)
|
@@ -240,7 +240,8 @@ module Uffizzi
|
|
240
240
|
Uffizzi.ui.say(preview_url) if success
|
241
241
|
else
|
242
242
|
deployment_data = build_deployment_data(deployment)
|
243
|
-
Uffizzi.ui.
|
243
|
+
Uffizzi.ui.enable_stdout
|
244
|
+
Uffizzi.ui.say(deployment_data)
|
244
245
|
end
|
245
246
|
end
|
246
247
|
|
data/lib/uffizzi/shell.rb
CHANGED
@@ -7,12 +7,26 @@ module Uffizzi
|
|
7
7
|
class Shell
|
8
8
|
attr_accessor :output_format
|
9
9
|
|
10
|
+
PRETTY_JSON = 'pretty-json'
|
11
|
+
REGULAR_JSON = 'json'
|
12
|
+
GITHUB_ACTION = 'github-action'
|
13
|
+
|
10
14
|
def initialize
|
11
15
|
@shell = Thor::Shell::Basic.new
|
12
16
|
end
|
13
17
|
|
14
18
|
def say(message)
|
15
|
-
|
19
|
+
formatted_message = case output_format
|
20
|
+
when PRETTY_JSON
|
21
|
+
format_to_pretty_json(message)
|
22
|
+
when REGULAR_JSON
|
23
|
+
format_to_json(message)
|
24
|
+
when GITHUB_ACTION
|
25
|
+
format_to_github_action(message)
|
26
|
+
else
|
27
|
+
message
|
28
|
+
end
|
29
|
+
@shell.say(formatted_message)
|
16
30
|
end
|
17
31
|
|
18
32
|
def print_in_columns(messages)
|
@@ -34,33 +48,28 @@ module Uffizzi
|
|
34
48
|
@shell.send(:stdout).string.strip
|
35
49
|
end
|
36
50
|
|
37
|
-
def pretty_say(collection, index = true)
|
38
|
-
ap(collection, { index: index })
|
39
|
-
end
|
40
|
-
|
41
51
|
def disable_stdout
|
42
52
|
$stdout = StringIO.new
|
43
53
|
end
|
44
54
|
|
45
|
-
def
|
55
|
+
def enable_stdout
|
46
56
|
$stdout = IO.new(1, 'w')
|
47
|
-
json_format? ? output_in_json(data) : output_in_github_format(data)
|
48
57
|
end
|
49
58
|
|
50
59
|
private
|
51
60
|
|
52
|
-
def
|
53
|
-
|
61
|
+
def format_to_json(data)
|
62
|
+
data.to_json
|
54
63
|
end
|
55
64
|
|
56
|
-
def
|
57
|
-
|
65
|
+
def format_to_pretty_json(data)
|
66
|
+
JSON.pretty_generate(data)
|
58
67
|
end
|
59
68
|
|
60
|
-
def
|
61
|
-
data.
|
62
|
-
|
63
|
-
|
69
|
+
def format_to_github_action(data)
|
70
|
+
return '' unless data.is_a?(Hash)
|
71
|
+
|
72
|
+
data.reduce('') { |acc, (key, value)| "#{acc}::set-output name=#{key}::#{value}\n" }
|
64
73
|
end
|
65
74
|
end
|
66
75
|
end
|
data/lib/uffizzi/version.rb
CHANGED
data/man/uffizzi-preview-list
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
.\" generated with Ronn-NG/v0.9.1
|
2
2
|
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
3
|
-
.TH "UFFIZZI\-PREVIEW\-LIST" "" "
|
3
|
+
.TH "UFFIZZI\-PREVIEW\-LIST" "" "September 2022" ""
|
4
4
|
.SH "NAME"
|
5
5
|
\fBuffizzi\-preview\-list\fR \- list previews in a project
|
6
6
|
.SH "SYNOPSIS"
|
@@ -20,7 +20,7 @@ https://github\.com/UffizziCloud/uffizzi_cli
|
|
20
20
|
\-\-filter=METADATA
|
21
21
|
Metadata to filtering list of deployments\.
|
22
22
|
|
23
|
-
\-\-output=json
|
23
|
+
\-\-output=pretty\-json
|
24
24
|
Use this option for a more detailed description of listed
|
25
25
|
deployments\.
|
26
26
|
.fi
|
@@ -41,7 +41,7 @@ To list all previews in a project with name my_project, run:
|
|
41
41
|
|
42
42
|
To list all previews in json format, run:
|
43
43
|
|
44
|
-
$ uffizzi preview list \-\-output="json"
|
44
|
+
$ uffizzi preview list \-\-output="pretty\-json"
|
45
45
|
|
46
46
|
To list all previews filtered by metadata using single
|
47
47
|
label, run:
|
@@ -15,7 +15,7 @@ uffizzi-preview-list - list previews in a project
|
|
15
15
|
--filter=METADATA
|
16
16
|
Metadata to filtering list of deployments.
|
17
17
|
|
18
|
-
--output=json
|
18
|
+
--output=pretty-json
|
19
19
|
Use this option for a more detailed description of listed
|
20
20
|
deployments.
|
21
21
|
|
@@ -34,7 +34,7 @@ uffizzi-preview-list - list previews in a project
|
|
34
34
|
|
35
35
|
To list all previews in json format, run:
|
36
36
|
|
37
|
-
$ uffizzi preview list --output="json"
|
37
|
+
$ uffizzi preview list --output="pretty-json"
|
38
38
|
|
39
39
|
To list all previews filtered by metadata using single
|
40
40
|
label, run:
|
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: 1.0.
|
4
|
+
version: 1.0.2
|
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-
|
12
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: awesome_print
|