hammer_cli_katello 0.23.0 → 0.23.1
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: 39b7d013b69ccff473c384efe07fbc1c1574033c074e685be65723f5e3d79156
|
4
|
+
data.tar.gz: 9ba014e8f0a515eddfbb66d507483fa8f81b8873c5e670eca78755989bc1f40d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32c3e1f7dc2aa8fa32ceba935d7229c7b628bdf9429f6ed1fa036e818d3cca44bfa47d5d2319e7b8b16354688302f6743168fca59aa62c4a956f9ba4206fe74c
|
7
|
+
data.tar.gz: d270942a73c21fa9e996f1e0457d82b8e4abc866ddeed5d201d017febfbf9272640144aeacc260387550e8e8e22b36fac80b33b2e7b3d93fad87ff98ee465886
|
@@ -249,6 +249,13 @@ module HammerCLIKatello
|
|
249
249
|
if option(:option_product_name).exist?
|
250
250
|
any(*organization_options).required
|
251
251
|
end
|
252
|
+
|
253
|
+
if option(:option_docker_tag).exist? != option(:option_docker_digest).exist?
|
254
|
+
option(:option_docker_tag).rejected(
|
255
|
+
:msg => _('--docker-digest required with --docker-tag'))
|
256
|
+
option(:option_docker_digest).rejected(
|
257
|
+
:msg => _('--docker-tag required with --docker-digest'))
|
258
|
+
end
|
252
259
|
end
|
253
260
|
|
254
261
|
build_options(:without => [:unprotected]) do |o|
|
@@ -257,12 +264,63 @@ module HammerCLIKatello
|
|
257
264
|
option "--publish-via-http", "ENABLE", _("Publish Via HTTP"),
|
258
265
|
:attribute_name => :option_unprotected,
|
259
266
|
:format => HammerCLI::Options::Normalizers::Bool.new
|
267
|
+
option "--docker-tag", "TAG", _("Container Image tag")
|
268
|
+
option "--docker-digest", "DIGEST", _("Container Image manifest digest")
|
260
269
|
|
261
270
|
def execute
|
262
271
|
@failure = false
|
263
|
-
|
272
|
+
|
273
|
+
if option_docker_tag
|
274
|
+
upload_tag(option_docker_tag, option_docker_digest)
|
275
|
+
else
|
276
|
+
super
|
277
|
+
end
|
278
|
+
|
264
279
|
@failure ? HammerCLI::EX_DATAERR : HammerCLI::EX_OK
|
265
280
|
end
|
281
|
+
|
282
|
+
def content_upload_resource
|
283
|
+
::HammerCLIForeman.foreman_resource(:content_uploads)
|
284
|
+
end
|
285
|
+
|
286
|
+
def upload_tag(tag, digest)
|
287
|
+
upload_id = create_content_upload
|
288
|
+
import_uploads([
|
289
|
+
{
|
290
|
+
id: upload_id,
|
291
|
+
name: tag,
|
292
|
+
digest: digest
|
293
|
+
}
|
294
|
+
], last_file: true)
|
295
|
+
print_message _("Repository updated")
|
296
|
+
rescue => e
|
297
|
+
@failure = true
|
298
|
+
logger.error e
|
299
|
+
output.print_error _("Failed to upload tag '%s' to repository.") % tag
|
300
|
+
ensure
|
301
|
+
content_upload_resource.call(:destroy, :repository_id => get_identifier, :id => upload_id)
|
302
|
+
end
|
303
|
+
|
304
|
+
def create_content_upload
|
305
|
+
response = content_upload_resource.call(:create,
|
306
|
+
:repository_id => get_identifier,
|
307
|
+
:size => 0
|
308
|
+
)
|
309
|
+
|
310
|
+
response["upload_id"]
|
311
|
+
end
|
312
|
+
|
313
|
+
def import_uploads(uploads, opts = {})
|
314
|
+
publish_repository = opts.fetch(:last_file, false)
|
315
|
+
sync_capsule = opts.fetch(:last_file, false)
|
316
|
+
params = {:id => get_identifier,
|
317
|
+
:uploads => uploads,
|
318
|
+
publish_repository: publish_repository,
|
319
|
+
sync_capsule: sync_capsule,
|
320
|
+
content_type: "docker_tag"
|
321
|
+
}
|
322
|
+
resource.call(:import_uploads, params)
|
323
|
+
end
|
266
324
|
end
|
267
325
|
|
268
326
|
class DeleteCommand < HammerCLIKatello::DeleteCommand
|
@@ -2,7 +2,7 @@ require_relative '../test_helper'
|
|
2
2
|
require_relative '../organization/organization_helpers'
|
3
3
|
require 'hammer_cli_katello/repository'
|
4
4
|
|
5
|
-
module HammerCLIKatello
|
5
|
+
module HammerCLIKatello # rubocop:disable Metrics/ModuleLength
|
6
6
|
describe Repository::UpdateCommand do
|
7
7
|
include OrganizationHelpers
|
8
8
|
|
@@ -14,6 +14,46 @@ module HammerCLIKatello
|
|
14
14
|
run_cmd(%w(repository update --id 1 --new-name rep1))
|
15
15
|
end
|
16
16
|
|
17
|
+
describe 'tags docker images' do
|
18
|
+
let(:repo_id) { 3 }
|
19
|
+
let(:tag_name) { "latest" }
|
20
|
+
let(:digest) { "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }
|
21
|
+
let(:upload_id) { "1234" }
|
22
|
+
let(:_href) { "/pulp/api/v2/content/uploads/#{upload_id}" }
|
23
|
+
let(:upload_response) do
|
24
|
+
{
|
25
|
+
"upload_id" => upload_id,
|
26
|
+
"_href" => _href
|
27
|
+
}
|
28
|
+
end
|
29
|
+
it "adds a tag to an image" do
|
30
|
+
ex = api_expects(:content_uploads, :create)
|
31
|
+
.with_params('repository_id' => repo_id, :size => 0)
|
32
|
+
|
33
|
+
ex.returns(upload_response)
|
34
|
+
ex2 = api_expects(:repositories, :import_uploads, 'Take in an upload')
|
35
|
+
.with_params(:id => repo_id, :sync_capsule => true, :publish_repository => true,
|
36
|
+
:uploads => [{
|
37
|
+
:id => '1234',
|
38
|
+
:name => tag_name,
|
39
|
+
:digest => digest
|
40
|
+
}],
|
41
|
+
:content_type => "docker_tag"
|
42
|
+
)
|
43
|
+
|
44
|
+
ex2.returns("")
|
45
|
+
|
46
|
+
ex3 = api_expects(:content_uploads, :destroy, "Delete the upload")
|
47
|
+
.with_params('id' => upload_id, 'repository_id' => repo_id)
|
48
|
+
|
49
|
+
ex3.returns("")
|
50
|
+
# rubocop:disable LineLength
|
51
|
+
result = run_cmd(%W(repository update --id #{repo_id} --docker-tag #{tag_name} --docker-digest #{digest}))
|
52
|
+
# rubocop:enable LineLength
|
53
|
+
assert_equal(result.exit_code, 0)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
17
57
|
describe 'resolves repository ID' do
|
18
58
|
it 'by requiring product' do
|
19
59
|
api_expects_no_call
|
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: 0.23.
|
4
|
+
version: 0.23.1
|
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: 2020-09-
|
38
|
+
date: 2020-09-21 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: hammer_cli_foreman
|
@@ -518,7 +518,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
518
518
|
- !ruby/object:Gem::Version
|
519
519
|
version: '0'
|
520
520
|
requirements: []
|
521
|
-
rubygems_version: 3.
|
521
|
+
rubygems_version: 3.1.2
|
522
522
|
signing_key:
|
523
523
|
specification_version: 4
|
524
524
|
summary: Katello commands for Hammer
|