hammer_cli_katello 1.3.1 → 1.4.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a00c7f5dd067ab0cc8203da1989be46411dc15ed1079442b38bf27e4c1c5eef
|
4
|
+
data.tar.gz: 4088650b9e19e79031e912cfc1f3c49ec11ef448e41c5c97cb41820fe5474bcc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b638de29d5f9ebf39fa1962ec41d316f23579c64f9b0bd387bc3bd0323d447368fb9dacf283ea8e10d898e1d2bd4e6956c99f435080f38c835092c154e85f03
|
7
|
+
data.tar.gz: 8c59ab30460634b1098d74933284052ee98492897a04d17358166597fb2d53e2412e521228486b5df37c8d8cb2f254565eb79ccb3cc29e5dfd8cfc9b42b4e399
|
@@ -84,16 +84,16 @@ module HammerCLIKatello
|
|
84
84
|
include OrganizationOptions
|
85
85
|
include CompositeContentViewNameResolvable
|
86
86
|
output do
|
87
|
-
field :
|
87
|
+
field :content_view_id, _("Content View Id")
|
88
88
|
field :content_view_name, _("Name")
|
89
89
|
field :version, _("Version")
|
90
|
+
field :id, _("Component Id")
|
90
91
|
field :current_version, _("Current Version")
|
91
92
|
field :version_id, _("Version Id")
|
92
93
|
end
|
93
94
|
|
94
95
|
def extend_data(mod)
|
95
96
|
if mod['latest']
|
96
|
-
mod['content_view_name'] = mod["content_view"]["name"]
|
97
97
|
mod['version'] = _("Latest")
|
98
98
|
if mod['content_view_version']
|
99
99
|
mod['current_version'] = mod['content_view_version']['version']
|
@@ -102,10 +102,11 @@ module HammerCLIKatello
|
|
102
102
|
mod['current_version'] = _("No Published Version")
|
103
103
|
end
|
104
104
|
else
|
105
|
-
mod['content_view_name'] = mod["content_view"]["name"]
|
106
105
|
mod['version'] = mod['content_view_version']['version']
|
107
106
|
mod['version_id'] = mod['content_view_version']['id']
|
108
107
|
end
|
108
|
+
mod['content_view_name'] = mod["content_view"]["name"]
|
109
|
+
mod['content_view_id'] = mod["content_view"]["id"]
|
109
110
|
mod
|
110
111
|
end
|
111
112
|
|
@@ -389,6 +389,8 @@ module HammerCLIKatello
|
|
389
389
|
o.expand.including(:products, :organizations)
|
390
390
|
end
|
391
391
|
|
392
|
+
option "--async", :flag, _("Do not wait for the task.")
|
393
|
+
|
392
394
|
option "--ostree-repository-name", "OSTREE REPOSITORY NAME",
|
393
395
|
_("Name of OSTree repository in archive."),
|
394
396
|
:attribute_name => :option_ostree_repository_name,
|
@@ -415,6 +417,7 @@ module HammerCLIKatello
|
|
415
417
|
update_content_upload(upload_id, repo_id, file)
|
416
418
|
end
|
417
419
|
opts[:ostree_repository_name] = options["option_ostree_repository_name"]
|
420
|
+
opts[:filename] = filename
|
418
421
|
results = import_uploads([
|
419
422
|
{
|
420
423
|
id: upload_id,
|
@@ -423,7 +426,7 @@ module HammerCLIKatello
|
|
423
426
|
size: file.size,
|
424
427
|
checksum: checksum
|
425
428
|
}], opts)
|
426
|
-
print_results(filename, results)
|
429
|
+
print_results(filename, results, options["option_async"])
|
427
430
|
ensure
|
428
431
|
if upload_id
|
429
432
|
content_upload_resource.call(:destroy, :repository_id => get_identifier, :id => upload_id)
|
@@ -468,35 +471,54 @@ module HammerCLIKatello
|
|
468
471
|
params = {:id => get_identifier,
|
469
472
|
:uploads => uploads,
|
470
473
|
publish_repository: publish_repository,
|
471
|
-
sync_capsule: sync_capsule
|
474
|
+
sync_capsule: sync_capsule,
|
475
|
+
async: true
|
472
476
|
}
|
473
477
|
params[:content_type] = options["option_content_type"] if options["option_content_type"]
|
474
478
|
if options["option_ostree_repository_name"]
|
475
479
|
params[:ostree_repository_name] = options["option_ostree_repository_name"]
|
476
480
|
end
|
477
|
-
|
481
|
+
results = if options["option_async"]
|
482
|
+
resource.call(:import_uploads, params)
|
483
|
+
else
|
484
|
+
task_progress(resource.call(:import_uploads, params))
|
485
|
+
end
|
486
|
+
results
|
478
487
|
end
|
479
488
|
|
480
|
-
def
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
489
|
+
def task_progress(task_or_id)
|
490
|
+
super
|
491
|
+
task_id = task_or_id.is_a?(Hash) ? task_or_id['id'] : task_or_id
|
492
|
+
load_task(task_id)
|
493
|
+
end
|
494
|
+
|
495
|
+
# rubocop:disable CyclomaticComplexity
|
496
|
+
# rubocop:disable PerceivedComplexity
|
497
|
+
def print_results(name, results, async)
|
498
|
+
if !%w(error warning).include?(results) && !async # task successful && no async flag used
|
486
499
|
upload_results = results.dig('output', 'upload_results') || []
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
500
|
+
|
501
|
+
if upload_results.empty?
|
502
|
+
print_message _("Successfully uploaded file %s" % name)
|
503
|
+
else
|
504
|
+
upload_results.each do |result|
|
505
|
+
if result['type'] == 'docker_manifest'
|
506
|
+
print_message(
|
507
|
+
_("Successfully uploaded manifest file '%{name}' with digest '%{digest}'") % {
|
508
|
+
:name => name, :digest => result['digest'] })
|
509
|
+
else
|
510
|
+
print_message _("Successfully uploaded file %s" % name)
|
511
|
+
end
|
496
512
|
end
|
497
513
|
end
|
514
|
+
elsif results&.dig('id') && async # async flag used
|
515
|
+
print_message _("Content is being uploaded in task #{results['id']}.")
|
516
|
+
else
|
517
|
+
print_message _("Could not upload the content.")
|
498
518
|
end
|
499
519
|
end
|
520
|
+
# rubocop:enable CyclomaticComplexity
|
521
|
+
# rubocop:enable PerceivedComplexity
|
500
522
|
|
501
523
|
def silence_warnings
|
502
524
|
original_verbose = $VERBOSE
|
@@ -17,10 +17,16 @@ describe 'upload repository' do
|
|
17
17
|
let(:path) { "./test.rpm" }
|
18
18
|
let(:upload_id) { "1234" }
|
19
19
|
let(:_href) { "/pulp/api/v2/content/uploads/#{upload_id}" }
|
20
|
+
let(:task_id) { "2ea4f" }
|
20
21
|
let(:upload_response) do
|
21
22
|
{
|
22
23
|
"upload_id" => upload_id,
|
23
|
-
"
|
24
|
+
"href" => _href
|
25
|
+
}
|
26
|
+
end
|
27
|
+
let(:import_uploads_response) do
|
28
|
+
{
|
29
|
+
"id" => task_id
|
24
30
|
}
|
25
31
|
end
|
26
32
|
|
@@ -36,7 +42,7 @@ describe 'upload repository' do
|
|
36
42
|
|
37
43
|
# rubocop:disable LineLength
|
38
44
|
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
39
|
-
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
45
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
40
46
|
:uploads => [{
|
41
47
|
:id => '1234',
|
42
48
|
:name => 'test.rpm',
|
@@ -47,14 +53,16 @@ describe 'upload repository' do
|
|
47
53
|
)
|
48
54
|
# rubocop:enable LineLength
|
49
55
|
|
50
|
-
ex2.returns(
|
56
|
+
ex2.returns(import_uploads_response)
|
57
|
+
expect_foreman_task(task_id)
|
58
|
+
expect_foreman_task(task_id)
|
51
59
|
|
52
60
|
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
53
61
|
.with_params('id' => upload_id, 'repository_id' => repo_id)
|
54
62
|
|
55
63
|
ex3.returns("")
|
56
|
-
|
57
64
|
result = run_cmd(@cmd + params)
|
65
|
+
|
58
66
|
assert_equal(result.exit_code, 0)
|
59
67
|
File.delete("test.rpm")
|
60
68
|
end
|
@@ -70,7 +78,7 @@ describe 'upload repository' do
|
|
70
78
|
|
71
79
|
# rubocop:disable LineLength
|
72
80
|
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
73
|
-
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :content_type => 'srpm',
|
81
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :content_type => 'srpm', :async => true,
|
74
82
|
:uploads => [{
|
75
83
|
:id => '1234',
|
76
84
|
:name => 'test.src.rpm',
|
@@ -79,9 +87,11 @@ describe 'upload repository' do
|
|
79
87
|
:checksum => 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
|
80
88
|
}]
|
81
89
|
)
|
82
|
-
|
83
90
|
# rubocop:enable LineLength
|
84
|
-
|
91
|
+
|
92
|
+
ex2.returns(import_uploads_response)
|
93
|
+
expect_foreman_task(task_id)
|
94
|
+
expect_foreman_task(task_id)
|
85
95
|
|
86
96
|
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
87
97
|
.with_params(:id => upload_id, :repository_id => repo_id)
|
@@ -105,7 +115,7 @@ describe 'upload repository' do
|
|
105
115
|
|
106
116
|
# rubocop:disable LineLength
|
107
117
|
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
108
|
-
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
118
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
109
119
|
:uploads => [{
|
110
120
|
:id => '1234',
|
111
121
|
:name => 'test.src.rpm',
|
@@ -140,7 +150,7 @@ describe 'upload repository' do
|
|
140
150
|
|
141
151
|
# rubocop:disable LineLength
|
142
152
|
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
143
|
-
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
153
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
144
154
|
:uploads => [{
|
145
155
|
:id => '1234',
|
146
156
|
:name => 'test.rpm',
|
@@ -150,13 +160,20 @@ describe 'upload repository' do
|
|
150
160
|
}]
|
151
161
|
)
|
152
162
|
# rubocop:enable LineLength
|
153
|
-
ex2.returns('output' => {'upload_results' => [{'type' => 'docker_manifest',
|
154
|
-
'digest' => 'sha256:1234'}]})
|
155
163
|
|
156
|
-
|
164
|
+
ex2.returns(import_uploads_response)
|
165
|
+
expect_foreman_task(task_id)
|
166
|
+
|
167
|
+
ex3 = api_expects(:foreman_tasks, :show, 'Show task')
|
168
|
+
ex3.returns('id' => task_id, 'state' => 'stopped', 'progress' => 1,
|
169
|
+
'humanized' => {'output' => {'upload_results' => [{'type' => 'docker_manifest',
|
170
|
+
'digest' => 'sha256:1234'}]},
|
171
|
+
'errors' => ''})
|
172
|
+
|
173
|
+
ex4 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
157
174
|
.with_params(:id => upload_id, :repository_id => repo_id)
|
158
175
|
|
159
|
-
|
176
|
+
ex4.returns("")
|
160
177
|
|
161
178
|
result = run_cmd(@cmd + params)
|
162
179
|
assert_equal(result.exit_code, 0)
|
@@ -180,7 +197,7 @@ describe 'upload repository' do
|
|
180
197
|
|
181
198
|
# rubocop:disable LineLength
|
182
199
|
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
183
|
-
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
200
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
184
201
|
:uploads => [{
|
185
202
|
:id => '1234',
|
186
203
|
:name => 'test.rpm',
|
@@ -191,7 +208,9 @@ describe 'upload repository' do
|
|
191
208
|
)
|
192
209
|
# rubocop:enable LineLength
|
193
210
|
|
194
|
-
ex2.returns(
|
211
|
+
ex2.returns(import_uploads_response)
|
212
|
+
expect_foreman_task(task_id)
|
213
|
+
expect_foreman_task(task_id)
|
195
214
|
|
196
215
|
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
197
216
|
.with_params(:id => upload_id, :repository_id => repo_id)
|
@@ -212,10 +231,9 @@ describe 'upload repository' do
|
|
212
231
|
.with_params(:repository_id => repo_id, :size => file.size)
|
213
232
|
|
214
233
|
ex.returns(upload_response)
|
215
|
-
|
216
234
|
# rubocop:disable LineLength
|
217
235
|
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
218
|
-
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
236
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
219
237
|
:uploads => [{
|
220
238
|
:id => '1234',
|
221
239
|
:name => 'test.rpm',
|
@@ -225,8 +243,9 @@ describe 'upload repository' do
|
|
225
243
|
}]
|
226
244
|
)
|
227
245
|
# rubocop:enable LineLength
|
228
|
-
|
229
|
-
|
246
|
+
ex2.returns(import_uploads_response)
|
247
|
+
expect_foreman_task(task_id)
|
248
|
+
expect_foreman_task(task_id)
|
230
249
|
|
231
250
|
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
232
251
|
.with_params(:id => upload_id, :repository_id => repo_id)
|
@@ -253,7 +272,7 @@ describe 'upload repository' do
|
|
253
272
|
|
254
273
|
# rubocop:disable LineLength
|
255
274
|
ex = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
256
|
-
.with_params(:id => repo_id, :sync_capsule => false, :publish_repository => false,
|
275
|
+
.with_params(:id => repo_id, :sync_capsule => false, :publish_repository => false, :async => true,
|
257
276
|
:uploads => [{
|
258
277
|
:id => '1234',
|
259
278
|
:name => 'test1.rpm',
|
@@ -264,7 +283,9 @@ describe 'upload repository' do
|
|
264
283
|
)
|
265
284
|
# rubocop:enable LineLength
|
266
285
|
|
267
|
-
ex.returns(
|
286
|
+
ex.returns(import_uploads_response)
|
287
|
+
expect_foreman_task(task_id)
|
288
|
+
expect_foreman_task(task_id)
|
268
289
|
|
269
290
|
ex = api_expects(:content_uploads, :destroy, "Delete the upload")
|
270
291
|
.with_params(:id => upload_id, :repository_id => repo_id)
|
@@ -280,7 +301,7 @@ describe 'upload repository' do
|
|
280
301
|
|
281
302
|
# rubocop:disable LineLength
|
282
303
|
ex = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
283
|
-
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
304
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true, :async => true,
|
284
305
|
:uploads => [{
|
285
306
|
:id => '1234',
|
286
307
|
:name => 'test2.rpm',
|
@@ -291,7 +312,9 @@ describe 'upload repository' do
|
|
291
312
|
)
|
292
313
|
# rubocop:enable LineLength
|
293
314
|
|
294
|
-
ex.returns(
|
315
|
+
ex.returns(import_uploads_response)
|
316
|
+
expect_foreman_task(task_id)
|
317
|
+
expect_foreman_task(task_id)
|
295
318
|
|
296
319
|
ex = api_expects(:content_uploads, :destroy, "Delete the upload")
|
297
320
|
.with_params(:id => upload_id, :repository_id => repo_id)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hammer_cli_katello
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Price
|
@@ -35,7 +35,7 @@ authors:
|
|
35
35
|
autorequire:
|
36
36
|
bindir: bin
|
37
37
|
cert_chain: []
|
38
|
-
date:
|
38
|
+
date: 2022-02-13 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: hammer_cli_foreman
|