hammer_cli_katello 0.19.0 → 0.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cba613b687a09867f991db7067887e8b4081c21bf2f4ef91dec62a526232052
4
- data.tar.gz: 1314bb33f0f3f715a3b629b54b7d8c4f3a625eb63b020f9e715182b5076d5ec1
3
+ metadata.gz: fba6e1084b82989bca341b0de60b13f08ecdf223fa2a7c44be4df296ae9d88e3
4
+ data.tar.gz: ff4554e7abe415a95ef8a69e8d6a141045d80a7f9eb93bab68ca33594f87416f
5
5
  SHA512:
6
- metadata.gz: ab9572e1855282d5a7a7b7321ed5b059c98ead6f147adc7be663bb6b0f26ca8af7c0ef03287854ea0b947f66dc04b4a20a45b855736cdc1e1055b49f3929c8bd
7
- data.tar.gz: 93226ed6593f9c493ed1e83d46207c58eefe8423421ea61f455a661be3347e01e5e9f5f86bca3627f493404f0647e53a57ece0f159c805bdb066b9e2d71ca63b
6
+ metadata.gz: 4467809af59038ebd1749c8e0a0ea09051e2ac05c5ae4675b42928031bc20f8c9c33d4f55b696c2f6e0cbd665c2cb916455f37b844ad4367e4a45688b7be4624
7
+ data.tar.gz: 65f5924fdf39fa51ee0142721ef0d23fb32134684e478d43f55418a64e31c541ae25ce4b4c3856832a5ae2e682b4ac1a0a4f2c0b72ecb6d0c906df3c373a3a5b
@@ -111,20 +111,8 @@ module HammerCLIKatello
111
111
  end
112
112
  end
113
113
 
114
- validate_options :before, 'IdResolution' do
115
- product_options = [:option_product_id, :option_product_name]
116
- if option(:option_repository_ids).exist?
117
- any(*product_options).rejected
118
- option(:option_repository_names).rejected
119
- end
120
-
121
- if option(:option_repository_names).exist?
122
- any(*product_options).required
123
- end
124
- end
125
-
126
114
  build_options do |o|
127
- o.expand.including(:products)
115
+ o.expand.except(:repositories)
128
116
  end
129
117
  end
130
118
 
@@ -174,20 +162,10 @@ module HammerCLIKatello
174
162
  if option(:option_name).exist? || option(:option_product_name).exist?
175
163
  any(*organization_options).required
176
164
  end
177
-
178
- product_options = [:option_product_id, :option_product_name]
179
- if option(:option_repository_ids).exist?
180
- any(*product_options).rejected
181
- option(:option_repository_names).rejected
182
- end
183
-
184
- if option(:option_repository_names).exist?
185
- any(*product_options).required
186
- end
187
165
  end
188
166
 
189
167
  build_options do |o|
190
- o.expand.including(:products)
168
+ o.expand.except(:repositories)
191
169
  end
192
170
  end
193
171
 
@@ -13,6 +13,7 @@ module HammerCLIKatello
13
13
  field :id, _("ID")
14
14
  field :name, _("Name")
15
15
  field :version, _("Version")
16
+ field :description, _("Description")
16
17
  field :environments, _("Lifecycle Environments"), Fields::List
17
18
  end
18
19
 
@@ -159,6 +160,20 @@ module HammerCLIKatello
159
160
  extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
160
161
  end
161
162
 
163
+ class UpdateCommand < HammerCLIKatello::UpdateCommand
164
+ action :update
165
+ command_name "update"
166
+
167
+ success_message _("Content view version updated.")
168
+ failure_message _("Could not update the content view version")
169
+
170
+ build_options do |o|
171
+ o.expand(:all).including(:environments, :content_views, :organizations)
172
+ end
173
+
174
+ extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
175
+ end
176
+
162
177
  class IncrementalUpdate < HammerCLIKatello::Command
163
178
  include HammerCLIForemanTasks::Async
164
179
 
@@ -3,6 +3,9 @@ module HammerCLIKatello
3
3
  resource :packages
4
4
 
5
5
  class ListCommand < HammerCLIKatello::ListCommand
6
+ extend_with(HammerCLIKatello::CommandExtensions::LifecycleEnvironment.new)
7
+ include LifecycleEnvironmentNameMapping
8
+
6
9
  output do
7
10
  field :id, _("ID")
8
11
  field :filename, _("Filename")
@@ -34,7 +37,6 @@ module HammerCLIKatello
34
37
  :option_environment_name).required
35
38
  end
36
39
  end
37
-
38
40
  build_options do |o|
39
41
  o.expand.including(:products, :content_views)
40
42
  end
@@ -443,9 +443,9 @@ module HammerCLIKatello
443
443
  params = {:id => get_identifier,
444
444
  :uploads => uploads,
445
445
  publish_repository: publish_repository,
446
- sync_capsule: sync_capsule,
447
- content_type: option_content_type
446
+ sync_capsule: sync_capsule
448
447
  }
448
+ params[:content_type] = options["option_content_type"] if options["option_content_type"]
449
449
  resource.call(:import_uploads, params)
450
450
  end
451
451
 
@@ -0,0 +1,61 @@
1
+ module HammerCLIKatello
2
+ class SrpmCommand < HammerCLIKatello::Command
3
+ resource :srpms
4
+
5
+ class ListCommand < HammerCLIKatello::ListCommand
6
+ include LifecycleEnvironmentNameMapping
7
+ output do
8
+ field :id, _("ID")
9
+ field :name, _("Name")
10
+ field :filename, _("Filename")
11
+ end
12
+
13
+ validate_options :before, 'IdResolution' do
14
+ organization_options = [:option_organization_id, :option_organization_name, \
15
+ :option_organization_label]
16
+ product_options = [:option_product_id, :option_product_name]
17
+ content_view_options = [:option_content_view_id, :option_content_view_name]
18
+
19
+ if option(:option_product_name).exist? || option(:option_content_view_name).exist?
20
+ any(*organization_options).required
21
+ end
22
+
23
+ if option(:option_repository_name).exist?
24
+ any(*product_options).required
25
+ end
26
+
27
+ if option(:option_content_view_version_version).exist?
28
+ any(*content_view_options).required
29
+ end
30
+
31
+ if any(*content_view_options).exist?
32
+ any(:option_content_view_version_id,
33
+ :option_content_view_version_version,
34
+ :option_environment_id,
35
+ :option_environment_name).required
36
+ end
37
+ end
38
+
39
+ build_options do |o|
40
+ o.expand.including(:products, :content_views)
41
+ end
42
+ end
43
+
44
+ class InfoCommand < HammerCLIKatello::InfoCommand
45
+ output do
46
+ field :id, _("ID")
47
+ field :name, _("Name")
48
+ field :version, _("Version")
49
+ field :arch, _("Architecture")
50
+ field :epoch, _("Epoch")
51
+ field :release, _("Release")
52
+ field :filename, _("Filename")
53
+ field :summary, _("Description")
54
+ end
55
+
56
+ build_options
57
+ end
58
+
59
+ autoload_subcommands
60
+ end
61
+ end
@@ -1,5 +1,5 @@
1
1
  module HammerCLIKatello
2
2
  def self.version
3
- @version ||= Gem::Version.new('0.19.0')
3
+ @version ||= Gem::Version.new('0.19.1')
4
4
  end
5
5
  end
@@ -136,6 +136,11 @@ module HammerCLIKatello
136
136
  'hammer_cli_katello/module_stream'
137
137
  )
138
138
 
139
+ HammerCLI::MainCommand.lazy_subcommand("srpm", _("Manipulate source RPMs"),
140
+ 'HammerCLIKatello::SrpmCommand',
141
+ 'hammer_cli_katello/srpm'
142
+ )
143
+
139
144
  # subcommands to hammer_cli_foreman commands
140
145
  require 'hammer_cli_katello/host'
141
146
  require 'hammer_cli_katello/hostgroup'
@@ -8,14 +8,11 @@ describe 'content-view create' do
8
8
  let(:error_heading) { "Could not create the content view" }
9
9
  let(:name) { 'test-cv' }
10
10
  let(:org_id) { 1 }
11
- let(:product) do
12
- { 'name' => 'product-1', 'id' => 1 }
13
- end
14
11
  let(:repositories) do
15
12
  [
16
- {'name' => 'repo-1', 'id' => '1'},
17
- {'name' => 'repo-2', 'id' => '2'},
18
- {'name' => 'repo-3', 'id' => '3'}
13
+ {'id' => '1'},
14
+ {'id' => '2'},
15
+ {'id' => '3'}
19
16
  ]
20
17
  end
21
18
 
@@ -34,87 +31,4 @@ describe 'content-view create' do
34
31
  result = run_cmd(@cmd + @base_params + params)
35
32
  assert_cmd(expected_result, result)
36
33
  end
37
-
38
- it 'create the content view with repositories specified by product id and names' do
39
- wanted = repositories.take(2)
40
- ids = wanted.map { |repo| repo['id'] }
41
- names = wanted.map { |repo| repo['name'] }
42
- params = %W(--product-id=#{product['id']} --repositories=#{names.join(',')})
43
-
44
- api_repositories = api_expects(:repositories, :index,
45
- 'Find repositories belonging to product') do |par|
46
- par['product_id'] == product['id'] &&
47
- par['names'] == names &&
48
- !par.key?('name')
49
- end
50
- api_repositories.returns(repositories)
51
-
52
- api_expects(:content_views, :create, 'Create content view') do |par|
53
- par['organization_id'] == org_id &&
54
- par['name'] == name &&
55
- par['repository_ids'] == ids
56
- end
57
-
58
- expected_result = success_result("Content view created.\n")
59
- result = run_cmd(@cmd + @base_params + params)
60
- assert_cmd(expected_result, result)
61
- end
62
-
63
- it 'create the content view with repositories specified by product name and names' do
64
- wanted = repositories.take(2)
65
- ids = wanted.map { |repo| repo['id'] }
66
- names = wanted.map { |repo| repo['name'] }
67
- params = %W(--product=#{product['name']} --repositories=#{names.join(',')})
68
-
69
- api_products = api_expects(:products, :index, 'Find ID of product') do |par|
70
- par['organization_id'] == org_id && par['name'] == product['name']
71
- end
72
- api_products.returns(product)
73
-
74
- api_repositories = api_expects(:repositories, :index,
75
- 'Find repositories belonging to product') do |par|
76
- par['product_id'] == product['id'] &&
77
- par['names'] == names &&
78
- !par.key?('name')
79
- end
80
- api_repositories.returns(repositories)
81
-
82
- api_expects(:content_views, :create, 'Create content view') do |par|
83
- par['organization_id'] == org_id &&
84
- par['name'] == name &&
85
- par['repository_ids'] == ids
86
- end
87
-
88
- expected_result = success_result("Content view created.\n")
89
- result = run_cmd(@cmd + @base_params + params)
90
- assert_cmd(expected_result, result)
91
- end
92
-
93
- it 'fails on providing repository names without product' do
94
- params = %w(--repositories=repo-1,repo-2)
95
-
96
- expected_result = usage_error_result(
97
- @cmd,
98
- 'At least one of options --product-id, --product is required.',
99
- error_heading
100
- )
101
-
102
- api_expects_no_call
103
- result = run_cmd(@cmd + @base_params + params)
104
- assert_cmd(expected_result, result)
105
- end
106
-
107
- it 'fails on providing product and repository ids' do
108
- params = %w(--product=testproduct --repository-ids=1,2,3,4,5)
109
-
110
- expected_result = usage_error_result(
111
- @cmd,
112
- "You can't set any of options --product-id, --product.",
113
- error_heading
114
- )
115
-
116
- api_expects_no_call
117
- result = run_cmd(@cmd + params)
118
- assert_cmd(expected_result, result)
119
- end
120
34
  end
@@ -48,32 +48,6 @@ module HammerCLIKatello
48
48
  end
49
49
  run_cmd(%w(content-view update --name cv2 --organization-label org1))
50
50
  end
51
-
52
- it 'requires organization if product name is supplied along with repository' do
53
- id = 122
54
- repo_id = 100
55
- product_name = "foo"
56
- api_expects_no_call
57
- cmd = %W(content-view update --id=#{id}\
58
- --repository-ids=#{repo_id} --product=#{product_name})
59
- result = run_cmd(cmd)
60
- expected_error = "--organization-id, --organization, --organization-label is required"
61
- assert(result.err.include?(expected_error),
62
- "Invalid Error Message")
63
- end
64
-
65
- it 'requires product if repository names are provided' do
66
- id = 122
67
- repo_id = 100
68
- organization_id = 5
69
- api_expects_no_call
70
- cmd = %W(content-view update --id=#{id}\
71
- --repositories=#{repo_id} --organization-id=#{organization_id})
72
- result = run_cmd(cmd)
73
- expected_error = "--product-id, --product is required"
74
- assert(result.err.include?(expected_error),
75
- "Invalid Error Message")
76
- end
77
51
  end
78
52
  end
79
53
  end
@@ -0,0 +1,48 @@
1
+ require_relative '../../test_helper'
2
+ require 'hammer_cli_katello/content_view_version'
3
+
4
+ module HammerCLIKatello
5
+ describe ContentViewVersion::UpdateCommand do
6
+ include OrganizationHelpers
7
+ it 'allows minimal options' do
8
+ ex = api_expects(:content_view_versions, :update).with_params('description' => 'pizza')
9
+ ex.returns('id' => '2', 'description' => 'pizza')
10
+
11
+ result = run_cmd(%w(content-view version update --id 2 --description pizza))
12
+ assert_equal(result.exit_code, 0)
13
+ end
14
+ end
15
+
16
+ describe 'content view options' do
17
+ it 'allows content view id with one version' do
18
+ ex = api_expects(:content_view_versions, :index)
19
+ ex.returns('id' => '1', 'content_view' => [{'id' => '2'}])
20
+
21
+ ex = api_expects(:content_view_versions, :update).with_params('description' => 'pizza')
22
+ ex.returns('id' => '1', 'description' => 'pizza', 'content_view' => [{'id' => '2'}])
23
+
24
+ result = run_cmd(%w(content-view version update --description pizza --content-view-id 2))
25
+ assert_equal(result.exit_code, 0)
26
+ end
27
+
28
+ it 'allows content view id with multiple versions' do
29
+ ex = api_expects(:content_view_versions, :index)
30
+ ex.returns('id' => '2', 'content_view' => [{'id' => '3'}])
31
+
32
+ ex = api_expects(:content_view_versions, :update).with_params('description' => 'pizza')
33
+ ex.returns('id' => '2', 'description' => 'pizza', 'content_view' => [{'id' => '3'}])
34
+
35
+ result = run_cmd(%w(content-view version update --description pizza
36
+ --content-view-id 3 --version 2))
37
+ assert_equal(result.exit_code, 0)
38
+ end
39
+
40
+ it 'blocks update without description' do
41
+ ex = api_expects(:content_view_versions, :index)
42
+ ex.returns('id' => '1', 'content_view' => [{'id' => '2'}])
43
+
44
+ result = run_cmd(%w(content-view version update --content-view-id 2))
45
+ assert_equal(result.exit_code, 64)
46
+ end
47
+ end
48
+ end
@@ -2,11 +2,14 @@ require_relative '../test_helper'
2
2
  require_relative '../repository/repository_helpers'
3
3
  require_relative '../product/product_helpers'
4
4
  require_relative '../organization/organization_helpers'
5
+ require_relative '../lifecycle_environment/lifecycle_environment_helpers'
5
6
  require 'hammer_cli_katello/package'
6
7
 
8
+ # rubocop:disable ModuleLength
7
9
  module HammerCLIKatello
8
10
  describe PackageCommand::ListCommand do
9
11
  include OrganizationHelpers
12
+ include LifecycleEnvironmentHelpers
10
13
  include RepositoryHelpers
11
14
  include ProductHelpers
12
15
 
@@ -66,6 +69,28 @@ module HammerCLIKatello
66
69
  end
67
70
  end
68
71
 
72
+ describe 'environment options' do
73
+ it 'may be specified environment name' do
74
+ org_id = 2
75
+ env_name = "dev"
76
+ expected_id = 6
77
+ expect_lifecycle_environment_search(org_id, env_name, expected_id)
78
+
79
+ api_expects(:packages, :index).with_params("organization_id" => org_id,
80
+ "environment_id" => expected_id,
81
+ "page" => 1, "per_page" => 1000)
82
+
83
+ run_cmd(%W(package list --environment=#{env_name} --organization-id=#{org_id}))
84
+ end
85
+
86
+ it 'may be specified environment name no org fails' do
87
+ api_expects_no_call
88
+ r = run_cmd(%w(package list --environment Library))
89
+ expected_error = "--organization, --organization-label, --organization-id"
90
+ assert(r.err.include?(expected_error), "Invalid error message")
91
+ end
92
+ end
93
+
69
94
  describe 'product options' do
70
95
  it 'may be specified by ID' do
71
96
  api_expects(:repositories, :index)
@@ -0,0 +1,91 @@
1
+ require_relative '../test_helper'
2
+ require_relative '../repository/repository_helpers'
3
+ require_relative '../product/product_helpers'
4
+ require_relative '../organization/organization_helpers'
5
+ require 'hammer_cli_katello/srpm'
6
+
7
+ module HammerCLIKatello
8
+ describe PackageCommand::ListCommand do
9
+ include OrganizationHelpers
10
+ include RepositoryHelpers
11
+ include ProductHelpers
12
+
13
+ it 'allows minimal options' do
14
+ api_expects(:srpms, :index)
15
+
16
+ run_cmd(%w(srpm list))
17
+ end
18
+
19
+ describe 'repository options' do
20
+ it 'may be specified by ID' do
21
+ api_expects(:srpms, :index).with_params('repository_id' => 1)
22
+
23
+ run_cmd(%w(srpm list --repository-id 1))
24
+ end
25
+
26
+ it 'require product ID when given repository name' do
27
+ api_expects_no_call
28
+
29
+ r = run_cmd(%w(srpm list --repository repo1))
30
+ assert(r.err.include?("--product-id, --product is required"), "Invalid error message")
31
+ end
32
+
33
+ it 'may be specified by name and product ID' do
34
+ expect_repository_search(2, 'repo1', 1)
35
+
36
+ api_expects(:srpms, :index).with_params('repository_id' => 1)
37
+
38
+ run_cmd(%w(srpm list --repository repo1 --product-id 2))
39
+ end
40
+ end
41
+
42
+ describe 'organization options' do
43
+ it 'may be specified by ID' do
44
+ api_expects(:srpms, :index).with_params('organization_id' => 1)
45
+
46
+ run_cmd(%w(srpm list --organization-id 1))
47
+ end
48
+
49
+ it 'may be specified by name' do
50
+ expect_organization_search('org3', 1)
51
+ api_expects(:srpms, :index).with_params('organization_id' => 1)
52
+
53
+ run_cmd(%w(srpm list --organization org3))
54
+ end
55
+
56
+ it 'may be specified by label' do
57
+ expect_organization_search('org3', 1, field: 'label')
58
+ api_expects(:srpms, :index).with_params('organization_id' => 1)
59
+
60
+ run_cmd(%w(srpm list --organization-label org3))
61
+ end
62
+ end
63
+
64
+ describe 'content-view options' do
65
+ it 'may be specified by ID' do
66
+ api_expects(:content_view_versions, :index)
67
+ .with_params('content_view_id' => 1, 'version' => '2.1')
68
+ .returns(index_response([{'id' => 5}]))
69
+ api_expects(:srpms, :index).with_params('content_view_version_id' => 5)
70
+
71
+ run_cmd(%w(srpm list --content-view-id 1 --content-view-version 2.1))
72
+ end
73
+
74
+ it 'requires organization ID when given content view name' do
75
+ api_expects_no_call
76
+
77
+ r = run_cmd(%w(srpm list --content-view cv1 --content-view-version 2.1))
78
+ expected_error = "--organization-id, --organization, --organization-label is required"
79
+ assert(r.err.include?(expected_error), "Invalid error message")
80
+ end
81
+
82
+ it 'requires content view ID when given content view version number' do
83
+ api_expects_no_call
84
+
85
+ r = run_cmd(%w(srpm list --content-view-version cvv1))
86
+ assert(r.err.include?("--content-view-id, --content-view is required"),
87
+ "Invalid error message")
88
+ end
89
+ end
90
+ end
91
+ 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.19.0
4
+ version: 0.19.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: 2019-08-07 00:00:00.000000000 Z
38
+ date: 2019-08-29 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: hammer_cli_foreman
@@ -293,6 +293,7 @@ files:
293
293
  - lib/hammer_cli_katello/repository_scoped_to_product.rb
294
294
  - lib/hammer_cli_katello/repository_set.rb
295
295
  - lib/hammer_cli_katello/search_options_creators.rb
296
+ - lib/hammer_cli_katello/srpm.rb
296
297
  - lib/hammer_cli_katello/subscription.rb
297
298
  - lib/hammer_cli_katello/sync_plan.rb
298
299
  - lib/hammer_cli_katello/version.rb
@@ -380,6 +381,7 @@ files:
380
381
  - test/functional/content_view/version/list_test.rb
381
382
  - test/functional/content_view/version/promote_test.rb
382
383
  - test/functional/content_view/version/republish_repositories_test.rb
384
+ - test/functional/content_view/version/update_test.rb
383
385
  - test/functional/erratum/erratum_helpers.rb
384
386
  - test/functional/erratum/info_test.rb
385
387
  - test/functional/erratum/list_test.rb
@@ -461,6 +463,7 @@ files:
461
463
  - test/functional/repository_set/list_test.rb
462
464
  - test/functional/repository_set/repository_set_helpers.rb
463
465
  - test/functional/search_helpers.rb
466
+ - test/functional/srpm/list_test.rb
464
467
  - test/functional/subscription/list_test.rb
465
468
  - test/functional/sync_plan/create_test.rb
466
469
  - test/functional/sync_plan/delete_test.rb
@@ -494,8 +497,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
494
497
  - !ruby/object:Gem::Version
495
498
  version: '0'
496
499
  requirements: []
497
- rubyforge_project:
498
- rubygems_version: 2.7.6.2
500
+ rubygems_version: 3.0.3
499
501
  signing_key:
500
502
  specification_version: 4
501
503
  summary: Katello commands for Hammer
@@ -568,6 +570,7 @@ test_files:
568
570
  - test/functional/content_view/version/list_test.rb
569
571
  - test/functional/content_view/version/promote_test.rb
570
572
  - test/functional/content_view/version/republish_repositories_test.rb
573
+ - test/functional/content_view/version/update_test.rb
571
574
  - test/functional/erratum/erratum_helpers.rb
572
575
  - test/functional/erratum/info_test.rb
573
576
  - test/functional/erratum/list_test.rb
@@ -649,6 +652,7 @@ test_files:
649
652
  - test/functional/repository_set/list_test.rb
650
653
  - test/functional/repository_set/repository_set_helpers.rb
651
654
  - test/functional/search_helpers.rb
655
+ - test/functional/srpm/list_test.rb
652
656
  - test/functional/subscription/list_test.rb
653
657
  - test/functional/sync_plan/create_test.rb
654
658
  - test/functional/sync_plan/delete_test.rb