hammer_cli_katello 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hammer_cli_katello/content_export.rb +1 -1
- data/lib/hammer_cli_katello/content_export_helper.rb +4 -7
- data/lib/hammer_cli_katello/content_import.rb +13 -3
- data/lib/hammer_cli_katello/organization.rb +2 -1
- data/lib/hammer_cli_katello/repository.rb +46 -0
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/data/4.6/foreman_api.json +1 -1
- data/test/data/4.7/foreman_api.json +1 -0
- data/test/functional/content_export/complete/repository_test.rb +3 -1
- data/test/functional/content_export/incremental/repository_test.rb +3 -1
- data/test/functional/organization/cdn_configuration_test.rb +1 -0
- data/test/functional/repository/list_test.rb +38 -0
- data/test/functional/repository/remove_content_test.rb +2 -1
- data/test/functional/repository/types_test.rb +120 -0
- data/test/test_helper.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2708ed7f94bc63930cdbfbf1e6b6910224b9ac947a59beb6fd67325de8d13df5
|
4
|
+
data.tar.gz: 8e1658c27cab54ba5d45d68b9a2e9eea54df34db5be3316f090ef7bce073f7a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e69050801a50bef32379cce5b0f12b71a2308dac7bd6452a512f077e45b6fcd7e492cc75ed9eac8b425552884bd814857f3394c8aebd919553e54c10a9b5bb9b
|
7
|
+
data.tar.gz: cf6ca14b9f61a2f05d310084f2af7207a2a6aba887cd6a69c9a3ff1da1ce3670b450e45645a6d36affdabc9f2532d8a0baeda20e7f722bedfdbbd96fcc9ba086
|
@@ -14,10 +14,9 @@ module HammerCLIKatello
|
|
14
14
|
response
|
15
15
|
else
|
16
16
|
export_history = fetch_export_history_from_task(reload_task(@task))
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
elsif export_history
|
17
|
+
|
18
|
+
if export_history
|
19
|
+
make_listing_files(export_history) if syncable?
|
21
20
|
generate_metadata_json(export_history)
|
22
21
|
HammerCLI::EX_OK
|
23
22
|
else
|
@@ -82,8 +81,6 @@ module HammerCLIKatello
|
|
82
81
|
|
83
82
|
def make_listing_files(export_history)
|
84
83
|
check_export_history_syncable!(export_history)
|
85
|
-
output.print_message _("Generated #{export_history['path']}")
|
86
|
-
|
87
84
|
return unless Dir.exist?("#{export_history['path']}/content")
|
88
85
|
|
89
86
|
begin
|
@@ -138,7 +135,7 @@ module HammerCLIKatello
|
|
138
135
|
def fetch_repositories
|
139
136
|
if repository_command?
|
140
137
|
resp = show(:repositories, id: resolver.repository_id(options))
|
141
|
-
return resp["download_policy"] == "immediate" ? [] : [resp]
|
138
|
+
return resp["content_type"] != "yum" || resp["download_policy"] == "immediate" ? [] : [resp]
|
142
139
|
end
|
143
140
|
|
144
141
|
repo_options = {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'open-uri'
|
1
2
|
module HammerCLIKatello
|
2
3
|
class ContentImport < HammerCLIKatello::Command
|
3
4
|
desc "Import content from a content archive"
|
@@ -18,10 +19,11 @@ module HammerCLIKatello
|
|
18
19
|
|
19
20
|
base.validate_options do
|
20
21
|
option(:option_path).required
|
21
|
-
|
22
22
|
metadata_file = option(:option_metadata_file).value ||
|
23
23
|
File.join(option(:option_path).value, "metadata.json")
|
24
|
-
|
24
|
+
begin
|
25
|
+
URI.open(metadata_file)
|
26
|
+
rescue Errno::ENOENT
|
25
27
|
msg = _("Unable to find '#{metadata_file}'. "\
|
26
28
|
"If the metadata.json file is at a different location "\
|
27
29
|
"provide it to the --metadata-file option ")
|
@@ -32,10 +34,18 @@ module HammerCLIKatello
|
|
32
34
|
base.failure_message _("Could not import the archive.")
|
33
35
|
end
|
34
36
|
|
37
|
+
def fetch_metadata_from_url(metadata_file:, url:)
|
38
|
+
if metadata_file.nil?
|
39
|
+
metadata_file = "/tmp/metadata.json"
|
40
|
+
IO.copy_stream(URI.open(url), metadata_file)
|
41
|
+
end
|
42
|
+
metadata_file
|
43
|
+
end
|
44
|
+
|
35
45
|
def request_params
|
36
46
|
super.tap do |opts|
|
37
47
|
metadata_file = option_metadata_file || File.join(option_path, "metadata.json")
|
38
|
-
opts["metadata"] = JSON.parse(
|
48
|
+
opts["metadata"] = JSON.parse(URI.open(metadata_file).read)
|
39
49
|
end
|
40
50
|
end
|
41
51
|
end
|
@@ -52,7 +52,8 @@ module HammerCLIKatello
|
|
52
52
|
types = {
|
53
53
|
'export_sync' => _("Export Sync"),
|
54
54
|
'network_sync' => _("Network Sync"),
|
55
|
-
'redhat_cdn' => _("Red Hat CDN")
|
55
|
+
'redhat_cdn' => _("Red Hat CDN"),
|
56
|
+
'custom_cdn' => _("Custom CDN")
|
56
57
|
}
|
57
58
|
data["cdn_configuration"].merge!("type_label" => types[data["cdn_configuration"]["type"]])
|
58
59
|
end
|
@@ -34,6 +34,18 @@ module HammerCLIKatello
|
|
34
34
|
field :url, _("Url")
|
35
35
|
end
|
36
36
|
|
37
|
+
content_type_msg = _("Limit the repository type to return." \
|
38
|
+
" View available types with \"hammer repository types\"")
|
39
|
+
option "--content-type", "CONTENT TYPE",
|
40
|
+
content_type_msg,
|
41
|
+
:attribute_name => :option_content_type
|
42
|
+
|
43
|
+
with_content_msg = _("Limit the repository type to return." \
|
44
|
+
" View available types with \"hammer repository types\"")
|
45
|
+
option "--with-content", "WITH CONTENT",
|
46
|
+
with_content_msg,
|
47
|
+
:attribute_name => :option_with_content
|
48
|
+
|
37
49
|
build_options
|
38
50
|
|
39
51
|
extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
|
@@ -214,6 +226,12 @@ module HammerCLIKatello
|
|
214
226
|
:attribute_name => :option_unprotected,
|
215
227
|
:format => HammerCLI::Options::Normalizers::Bool.new
|
216
228
|
|
229
|
+
content_type_msg = _("Type of repository to create." \
|
230
|
+
" View available types with \"hammer repository types\"")
|
231
|
+
option "--content-type", "CONTENT TYPE",
|
232
|
+
content_type_msg,
|
233
|
+
:attribute_name => :option_content_type
|
234
|
+
|
217
235
|
build_options :without => [:unprotected]
|
218
236
|
end
|
219
237
|
|
@@ -321,6 +339,22 @@ module HammerCLIKatello
|
|
321
339
|
end
|
322
340
|
end
|
323
341
|
|
342
|
+
class RepositoryTypesCommand < HammerCLIKatello::InfoCommand
|
343
|
+
resource :repositories, :repository_types
|
344
|
+
command_name "types"
|
345
|
+
|
346
|
+
output do
|
347
|
+
field :name, _("Name")
|
348
|
+
collection :content_types, _('Content types') do
|
349
|
+
field :label, _('Type')
|
350
|
+
field :generic, _('Generic?')
|
351
|
+
field :removable, _('Removable?')
|
352
|
+
field :uploadable, _('Uploadable?')
|
353
|
+
field :indexed, _('Indexed?')
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
324
358
|
# rubocop:disable ClassLength
|
325
359
|
class UploadContentCommand < HammerCLIKatello::InfoCommand
|
326
360
|
extend RepositoryScopedToProduct
|
@@ -331,6 +365,12 @@ module HammerCLIKatello
|
|
331
365
|
command_name "upload-content"
|
332
366
|
CONTENT_CHUNK_SIZE = 2_500_000 # bytes to make sure it's lower than django's default 2621440
|
333
367
|
|
368
|
+
content_type_msg = _("The type of content unit to upload (srpm, file, etc.)." \
|
369
|
+
" View uploadable types with \"hammer repository types\"")
|
370
|
+
option "--content-type", "CONTENT TYPE",
|
371
|
+
content_type_msg,
|
372
|
+
:attribute_name => :option_content_type
|
373
|
+
|
334
374
|
class BinaryPath < HammerCLI::Options::Normalizers::File
|
335
375
|
def format(path)
|
336
376
|
fullpath = ::File.expand_path(path)
|
@@ -562,6 +602,12 @@ module HammerCLIKatello
|
|
562
602
|
end
|
563
603
|
end
|
564
604
|
|
605
|
+
content_type_msg = _("The type of content unit to remove (srpm, docker_manifest, etc.)." \
|
606
|
+
" View removable types with \"hammer repository types\"")
|
607
|
+
option "--content-type", "CONTENT TYPE",
|
608
|
+
content_type_msg,
|
609
|
+
:attribute_name => :option_content_type
|
610
|
+
|
565
611
|
build_options do |o|
|
566
612
|
o.expand.including(:products)
|
567
613
|
end
|