hammer_cli_katello 0.24.1 → 0.24.2
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_helper.rb +22 -13
- data/lib/hammer_cli_katello/version.rb +1 -1
- data/test/functional/content_export/complete/version_test.rb +35 -3
- data/test/functional/content_export/content_export_helpers.rb +19 -14
- data/test/functional/content_export/incremental/version_test.rb +35 -3
- data/test/functional/content_view/content_view_helpers.rb +3 -1
- data/test/functional/lifecycle_environment/lifecycle_environment_helpers.rb +1 -1
- data/test/functional/search_helpers.rb +11 -0
- 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: 4f913438c207c69774eadb286a20e8cb249c77eef5c64fec2b431d3d5bdfe11d
|
4
|
+
data.tar.gz: b00a4f7143e13ca251ee5ba533277c786c887f9211ed1273e35124f6006d83a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d555ffa3fe7daf61efc108c218646aa42e8923686b3e28a23fbf137354c2a7645de12ca0ab44ccaab524ae00690a143a783f0668fa8b998be8e12b17714f0400
|
7
|
+
data.tar.gz: ef7a75b53d2e1ed73f64156b77935e634042394b15edad9e4d28ed23350496d089359d4dc1b2a037a7aef42e48ca58cbada276e8e7fc03fd2391f68361f5677e
|
@@ -134,6 +134,25 @@ module HammerCLIKatello
|
|
134
134
|
|
135
135
|
def self.setup_version(base)
|
136
136
|
base.action(:version)
|
137
|
+
setup_version_options(base)
|
138
|
+
base.success_message _("Content view version is being exported in task %{id}.")
|
139
|
+
base.failure_message _("Could not export the content view version")
|
140
|
+
|
141
|
+
base.extend_with(
|
142
|
+
HammerCLIKatello::CommandExtensions::LifecycleEnvironments.new(only: :option_sources)
|
143
|
+
)
|
144
|
+
base.include(LifecycleEnvironmentNameMapping)
|
145
|
+
|
146
|
+
base.class_eval do
|
147
|
+
def request_params
|
148
|
+
super.tap do |opts|
|
149
|
+
opts["id"] = resolver.content_view_version_id(options)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def self.setup_version_options(base)
|
137
156
|
base.option "--fail-on-missing-content", :flag,
|
138
157
|
_("Fails if any of the repositories belonging"\
|
139
158
|
" to this version are unexportable.")
|
@@ -143,30 +162,20 @@ module HammerCLIKatello
|
|
143
162
|
:required => false
|
144
163
|
|
145
164
|
base.build_options do |o|
|
146
|
-
o.expand(:all).including(:content_views, :organizations)
|
165
|
+
o.expand(:all).including(:content_views, :organizations, :environments)
|
166
|
+
o.without(:environment_ids, :environment_id)
|
147
167
|
end
|
148
168
|
|
149
169
|
base.validate_options do
|
150
170
|
unless option(:option_id).exist?
|
151
171
|
any(:option_id, :option_content_view_name, :option_content_view_id).required
|
152
|
-
|
172
|
+
any(:option_version, :option_environment_id, :option_environment_name).required
|
153
173
|
unless option(:option_content_view_id).exist?
|
154
174
|
any(:option_organization_id, :option_organization_name, \
|
155
175
|
:option_organization_label).required
|
156
176
|
end
|
157
177
|
end
|
158
178
|
end
|
159
|
-
|
160
|
-
base.success_message _("Content view version is being exported in task %{id}.")
|
161
|
-
base.failure_message _("Could not export the content view version")
|
162
|
-
|
163
|
-
base.class_eval do
|
164
|
-
def request_params
|
165
|
-
super.tap do |opts|
|
166
|
-
opts["id"] = resolver.content_view_version_id(options)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
179
|
end
|
171
180
|
end
|
172
181
|
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '../../../test_helper')
|
2
|
-
require_relative '../content_export_helpers'
|
3
2
|
require 'hammer_cli_katello/content_export_complete'
|
3
|
+
require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
|
4
|
+
require_relative '../../content_view/content_view_helpers'
|
5
|
+
require_relative '../content_export_helpers'
|
4
6
|
|
5
7
|
describe 'content-export complete version' do
|
6
8
|
include ForemanTaskHelpers
|
7
9
|
include ContentExportHelpers
|
10
|
+
include ContentViewHelpers
|
11
|
+
include LifecycleEnvironmentHelpers
|
8
12
|
|
9
13
|
before do
|
10
14
|
@cmd = %w(content-export complete version)
|
@@ -30,7 +34,7 @@ describe 'content-export complete version' do
|
|
30
34
|
end
|
31
35
|
|
32
36
|
let(:content_view_id) { '77' }
|
33
|
-
let(:content_view_version_id) { '
|
37
|
+
let(:content_view_version_id) { '1001' }
|
34
38
|
|
35
39
|
let(:version) { '10.0' }
|
36
40
|
let(:destination_server) { "dream.example.com" }
|
@@ -99,7 +103,7 @@ describe 'content-export complete version' do
|
|
99
103
|
it 'fails on missing content-view version' do
|
100
104
|
params = ["--content-view-id=2"]
|
101
105
|
result = run_cmd(@cmd + params)
|
102
|
-
expected_error = "
|
106
|
+
expected_error = "--version, --lifecycle-environment-id, --lifecycle-environment is required."
|
103
107
|
|
104
108
|
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
105
109
|
assert_match(/#{expected_error}/, result.err)
|
@@ -182,4 +186,32 @@ describe 'content-export complete version' do
|
|
182
186
|
assert_match(/Unable to fully export this version because/, result.out)
|
183
187
|
assert_match(/200/, result.out)
|
184
188
|
end
|
189
|
+
|
190
|
+
it 'should accept content view and lifecycle environment and get the right version' do
|
191
|
+
env = "foo"
|
192
|
+
org_id = '100'
|
193
|
+
env_id = '223'
|
194
|
+
params = ["--content-view-id=#{content_view_id}",
|
195
|
+
"--lifecycle-environment=#{env}",
|
196
|
+
"--organization-id=#{org_id}"]
|
197
|
+
expect_lifecycle_environment_search(org_id, env, env_id)
|
198
|
+
expect_content_view_version_search({'environment_id' => env_id,
|
199
|
+
'content_view_id' => content_view_id},
|
200
|
+
'id' => content_view_version_id).at_least_once
|
201
|
+
|
202
|
+
expects_repositories_in_version(content_view_version_id)
|
203
|
+
ex = api_expects(:content_exports, :version)
|
204
|
+
ex.returns(response)
|
205
|
+
|
206
|
+
expect_foreman_task(task_id).at_least_once
|
207
|
+
|
208
|
+
HammerCLIKatello::ContentExportComplete::VersionCommand.
|
209
|
+
any_instance.
|
210
|
+
expects(:fetch_export_history).
|
211
|
+
returns(export_history)
|
212
|
+
|
213
|
+
result = run_cmd(@cmd + params)
|
214
|
+
assert_match(/Generated .*metadata.*json/, result.out)
|
215
|
+
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
216
|
+
end
|
185
217
|
end
|
@@ -1,21 +1,26 @@
|
|
1
|
+
require_relative '../search_helpers'
|
2
|
+
|
1
3
|
module ContentExportHelpers
|
4
|
+
include SearchHelpers
|
2
5
|
def expects_repositories_in_library(organization_id, returns = [])
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
expect_lenient_search(:repositories,
|
7
|
+
params: {
|
8
|
+
organization_id: organization_id,
|
9
|
+
library: true,
|
10
|
+
search: "download_policy != immediate",
|
11
|
+
content_type: 'yum'
|
12
|
+
},
|
13
|
+
returns: returns)
|
10
14
|
end
|
11
15
|
|
12
16
|
def expects_repositories_in_version(version_id, returns = [])
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
expect_lenient_search(:repositories,
|
18
|
+
params: {
|
19
|
+
content_view_version_id: version_id,
|
20
|
+
library: true,
|
21
|
+
search: "download_policy != immediate",
|
22
|
+
content_type: 'yum'
|
23
|
+
},
|
24
|
+
returns: returns)
|
20
25
|
end
|
21
26
|
end
|
@@ -1,10 +1,14 @@
|
|
1
|
-
|
2
|
-
require_relative '../content_export_helpers'
|
1
|
+
require_relative '../../test_helper'
|
3
2
|
require 'hammer_cli_katello/content_export'
|
3
|
+
require_relative '../../lifecycle_environment/lifecycle_environment_helpers'
|
4
|
+
require_relative '../../content_view/content_view_helpers'
|
5
|
+
require_relative '../content_export_helpers'
|
4
6
|
|
5
7
|
describe 'content-export incremental version' do
|
6
8
|
include ForemanTaskHelpers
|
7
9
|
include ContentExportHelpers
|
10
|
+
include ContentViewHelpers
|
11
|
+
include LifecycleEnvironmentHelpers
|
8
12
|
|
9
13
|
before do
|
10
14
|
@cmd = %w(content-export incremental version)
|
@@ -151,8 +155,8 @@ describe 'content-export incremental version' do
|
|
151
155
|
it 'fails on missing content-view version' do
|
152
156
|
params = ["--content-view-id=2"]
|
153
157
|
result = run_cmd(@cmd + params)
|
154
|
-
expected_error = "Option --version is required"
|
155
158
|
|
159
|
+
expected_error = "--version, --lifecycle-environment-id, --lifecycle-environment is required."
|
156
160
|
assert_equal(result.exit_code, HammerCLI::EX_USAGE)
|
157
161
|
assert_match(/#{expected_error}/, result.err)
|
158
162
|
end
|
@@ -233,4 +237,32 @@ describe 'content-export incremental version' do
|
|
233
237
|
assert_match(/Unable to fully export this version because/, result.out)
|
234
238
|
assert_match(/200/, result.out)
|
235
239
|
end
|
240
|
+
|
241
|
+
it 'should accept content view and lifecycle environment and get the right version' do
|
242
|
+
env = "foo"
|
243
|
+
org_id = '100'
|
244
|
+
env_id = '223'
|
245
|
+
params = ["--content-view-id=#{content_view_id}",
|
246
|
+
"--lifecycle-environment=#{env}",
|
247
|
+
"--organization-id=#{org_id}"]
|
248
|
+
expect_lifecycle_environment_search(org_id, env, env_id)
|
249
|
+
expect_content_view_version_search({'environment_id' => env_id,
|
250
|
+
'content_view_id' => content_view_id},
|
251
|
+
'id' => content_view_version_id).at_least_once
|
252
|
+
|
253
|
+
expects_repositories_in_version(content_view_version_id)
|
254
|
+
ex = api_expects(:content_export_incrementals, :version)
|
255
|
+
ex.returns(response)
|
256
|
+
|
257
|
+
expect_foreman_task(task_id).at_least_once
|
258
|
+
|
259
|
+
HammerCLIKatello::ContentExportIncremental::VersionCommand.
|
260
|
+
any_instance.
|
261
|
+
expects(:fetch_export_history).
|
262
|
+
returns(export_history)
|
263
|
+
|
264
|
+
result = run_cmd(@cmd + params)
|
265
|
+
assert_match(/Generated .*metadata.*json/, result.out)
|
266
|
+
assert_equal(HammerCLI::EX_OK, result.exit_code)
|
267
|
+
end
|
236
268
|
end
|
@@ -13,6 +13,8 @@ module ContentViewHelpers
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def expect_content_view_version_search(params, returns)
|
16
|
-
|
16
|
+
expect_lenient_search(:content_view_versions,
|
17
|
+
params: params,
|
18
|
+
returns: returns)
|
17
19
|
end
|
18
20
|
end
|
@@ -4,7 +4,7 @@ module LifecycleEnvironmentHelpers
|
|
4
4
|
include SearchHelpers
|
5
5
|
|
6
6
|
def expect_lifecycle_environment_search(org_id, name, id)
|
7
|
-
|
7
|
+
expect_lenient_search(:lifecycle_environments,
|
8
8
|
params: {'name' => name, 'organization_id' => org_id},
|
9
9
|
returns: {'id' => id})
|
10
10
|
end
|
@@ -3,4 +3,15 @@ module SearchHelpers
|
|
3
3
|
ex = api_expects(resource, :index, "Find the #{resource}").with_params(args[:params])
|
4
4
|
ex.returns(index_response([args[:returns]]))
|
5
5
|
end
|
6
|
+
|
7
|
+
def expect_lenient_search(resource, params:, returns:)
|
8
|
+
ex = api_expects(resource, :index, "Find the #{resource}") do |p|
|
9
|
+
params.each do |key, expected|
|
10
|
+
actual = p[key] || p[key.to_sym] || p[key.to_s]
|
11
|
+
assert_equal expected.to_s, actual.to_s, "key: '#{key}', resource: #{resource}"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
returns = [returns] unless returns.is_a? Array
|
15
|
+
ex.returns(index_response(returns))
|
16
|
+
end
|
6
17
|
end
|
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.24.
|
4
|
+
version: 0.24.2
|
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: 2021-01-05 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: hammer_cli_foreman
|