hammer_cli_foreman 2.5.0 → 2.5.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: c1ce3b2c0a42afcc7d60fac9440b1363e089277c6682f8a1adf43b2954b67a02
4
- data.tar.gz: 02a3da3459817db5e6dd1e87e75daba6ef121f3ac3aceb3beed8c7e9a7a32049
3
+ metadata.gz: 9a7510aa3b7250c6c467a18d128bc575f5a79f40c3a07283bb65def698e9c4cc
4
+ data.tar.gz: e5b1cbbd810d718b84f6a0102883bd4825880efe10250bbd8af1688966f209f1
5
5
  SHA512:
6
- metadata.gz: 9a915023e0332a5bfd827fa75158d00bce3a71bd2cd69564296cddea4657e90e4582d7eaf8144dfa419c1b5a3b4edf79efe63135cf91dd4c60b5ec87650f865a
7
- data.tar.gz: f17200f55885f6508c155f412d14d9d0630c814803255f6e496389efca1494891226aa15ec86b5f24f805b1e459a83f8dc2a352654b26464b5a78459690a0539
6
+ metadata.gz: e4112d9f91de37bfac6af33daf9d6e31d58d880889d421a873147dd75ac151c981849b641a90eb3322ca27add6b9dc8596f5a7fd8f6f95e830e1ffb3b8d3c5a5
7
+ data.tar.gz: 137ee8f5c12f70577b438132a4b5c2a68bb12c0f54f06fbdf6ad4d6db4b514bdea654c6daf3f1150132061a4e519f43c3d75828df4b2ac1fd96e767be9f45894
data/doc/release_notes.md CHANGED
@@ -1,5 +1,8 @@
1
1
  Release notes
2
2
  =============
3
+ ### 2.5.1 (2021-06-08)
4
+ * Show new msg for empty update commands, [#32454](http://projects.theforeman.org/issues/32454)
5
+
3
6
  ### 2.5.0 (2021-05-04)
4
7
  * Update test data to latest foreman
5
8
  * change to resource_type_label, [#11454](http://projects.theforeman.org/issues/11454)
@@ -1,3 +1,4 @@
1
+ require 'hammer_cli_foreman/command_extensions/update_common'
1
2
  require 'hammer_cli_foreman/command_extensions/fields'
2
3
  require 'hammer_cli_foreman/command_extensions/puppet_environment'
3
4
  require 'hammer_cli_foreman/command_extensions/puppet_environments'
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module HammerCLIForeman
4
+ module CommandExtensions
5
+ class UpdateCommon < HammerCLI::CommandExtensions
6
+ inheritable true
7
+
8
+ request_params do |params, command_object|
9
+ update_params = params[command_object.resource.singular_name]
10
+ command_object.context[:action_message] = :nothing_to_do if update_params && update_params.empty?
11
+ end
12
+ end
13
+ end
14
+ end
@@ -548,6 +548,19 @@ module HammerCLIForeman
548
548
  builder
549
549
  end
550
550
 
551
+ def self.inherited(child)
552
+ child.success_message_for(:nothing_to_do, _('Nothing to update.'))
553
+ end
554
+
555
+ def clean_up_context
556
+ super
557
+ context.delete(:action_message)
558
+ end
559
+
560
+ def success_message
561
+ success_message_for(context[:action_message] || :default)
562
+ end
563
+
551
564
  def method_options_for_params(params, options)
552
565
  opts = super
553
566
  # overwrite searchables with correct values
@@ -560,6 +573,7 @@ module HammerCLIForeman
560
573
  opts
561
574
  end
562
575
 
576
+ extend_with(HammerCLIForeman::CommandExtensions::UpdateCommon.new)
563
577
  end
564
578
 
565
579
 
@@ -1,5 +1,5 @@
1
1
  module HammerCLIForeman
2
2
  def self.version
3
- @version ||= Gem::Version.new "2.5.0"
3
+ @version ||= Gem::Version.new "2.5.1"
4
4
  end
5
5
  end
@@ -45,5 +45,35 @@ describe 'architecture' do
45
45
  _(result.exit_code).must_equal HammerCLI::EX_OK
46
46
  end
47
47
  end
48
- end
49
48
 
49
+ describe 'update' do
50
+ before do
51
+ @cmd = %w[architecture update]
52
+ @architecture = {
53
+ id: 1,
54
+ name: 'x86_64',
55
+ }
56
+ end
57
+
58
+ it 'should update an architecture with id' do
59
+ params = %w[--id=1 --new-name=x86_64]
60
+ api_expects(:architectures, :update, 'Update architecture').returns(@architecture)
61
+
62
+ expected_result = success_result("Architecture updated.\n")
63
+
64
+ result = run_cmd(@cmd + params)
65
+ assert_cmd(expected_result, result)
66
+ end
67
+
68
+ it 'updates nothing without architecture related parameters' do
69
+ params = %w[--id=1]
70
+ api_expects(:architectures, :update, 'Update architecture with no params').returns({})
71
+
72
+ expected_result = success_result("Nothing to update.\n")
73
+
74
+ result = run_cmd(@cmd + params)
75
+ assert_cmd(expected_result, result)
76
+ end
77
+
78
+ end
79
+ end
@@ -158,7 +158,8 @@ describe 'bookmark' do
158
158
  api_expects(:bookmarks, :update) do |par|
159
159
  par['id'] == '1'
160
160
  end
161
- run_cmd(%w[bookmark update --id 1])
161
+ result = run_cmd(%w[bookmark update --id 1])
162
+ assert_cmd(success_result("Nothing to update.\n"), result)
162
163
  end
163
164
 
164
165
  it 'update bookmark' do
@@ -40,6 +40,17 @@ describe "parameters" do
40
40
  result = run_cmd(@cmd + params)
41
41
  assert_cmd(success_result("Compute profile updated.\n"), result)
42
42
  end
43
+
44
+ it 'updates nothing without profile related parameters' do
45
+ params = %w[--id=1]
46
+ api_expects(:compute_profiles, :update, 'Update profile with no params').returns({})
47
+
48
+ expected_result = success_result("Nothing to update.\n")
49
+
50
+ result = run_cmd(@cmd + params)
51
+ assert_cmd(expected_result, result)
52
+ end
53
+
43
54
  end
44
55
 
45
56
  describe "delete compute profile" do
@@ -404,7 +404,7 @@ describe 'host update' do
404
404
  it 'updates nothing without host related parameters' do
405
405
  api_expects(:hosts, :update, 'Update host with no host params').returns({})
406
406
 
407
- expected_result = success_result("Host updated.\n")
407
+ expected_result = success_result("Nothing to update.\n")
408
408
 
409
409
  result = run_cmd(cmd + minimal_params)
410
410
  assert_cmd(expected_result, result)
@@ -61,9 +61,21 @@ describe 'httpproxy' do
61
61
  end
62
62
 
63
63
  it 'deletes an http proxy' do
64
+ api_expects(:http_proxies, :destroy, 'Delete proxy').returns(http_proxy)
65
+
64
66
  expected_result = success_result("Http proxy deleted.\n")
65
67
 
66
68
  result = run_cmd(%w(http-proxy delete --id 1))
67
69
  assert_cmd(expected_result, result)
68
70
  end
71
+
72
+ it 'updates nothing without related parameters' do
73
+ api_expects(:http_proxies, :update, 'Update proxy with no params').returns({})
74
+
75
+ expected_result = success_result("Nothing to update.\n")
76
+
77
+ result = run_cmd(%w(http-proxy update --id 1))
78
+ assert_cmd(expected_result, result)
79
+ end
80
+
69
81
  end
@@ -272,4 +272,17 @@ describe 'update' do
272
272
  result = run_cmd(@cmd + params)
273
273
  assert_cmd(success_result("Location updated.\n"), result)
274
274
  end
275
+
276
+ it 'updates nothing without related parameters' do
277
+ params = %w[--id=1]
278
+
279
+ api_expects(:locations, :index)
280
+ api_expects(:locations, :update, 'Update location with no params').returns({})
281
+
282
+ expected_result = success_result("Nothing to update.\n")
283
+
284
+ result = run_cmd(@cmd + params)
285
+ assert_cmd(expected_result, result)
286
+ end
287
+
275
288
  end
@@ -126,5 +126,16 @@ describe 'medium' do
126
126
  result = run_cmd(@cmd + params)
127
127
  assert_cmd(success_result("Installation medium updated.\n"), result)
128
128
  end
129
+
130
+ it 'updates nothing without medium related parameters' do
131
+ params = %w[--id=1]
132
+
133
+ api_expects(:media, :update, 'Update medium with no params').returns({})
134
+
135
+ expected_result = success_result("Nothing to update.\n")
136
+
137
+ result = run_cmd(@cmd + params)
138
+ assert_cmd(expected_result, result)
139
+ end
129
140
  end
130
141
  end
@@ -99,5 +99,16 @@ describe 'realm' do
99
99
  result = run_cmd(@cmd + params)
100
100
  assert_cmd(success_result("Realm [%{name}] updated.\n"), result)
101
101
  end
102
+
103
+ it 'updates nothing without realm related parameters' do
104
+ params = %w[--id=1]
105
+
106
+ api_expects(:realms, :update, 'Update realm with no params').returns({})
107
+
108
+ expected_result = success_result("Nothing to update.\n")
109
+
110
+ result = run_cmd(@cmd + params)
111
+ assert_cmd(expected_result, result)
112
+ end
102
113
  end
103
114
  end
@@ -195,6 +195,17 @@ describe 'report-template' do
195
195
  result = run_cmd(cmd + params)
196
196
  assert_cmd(success_result("Report template updated.\n"), result)
197
197
  end
198
+
199
+ it 'updates nothing without template related parameters' do
200
+ params = %w[--id=1]
201
+
202
+ api_expects(:report_templates, :update, 'Update template with no params').returns({})
203
+
204
+ expected_result = success_result("Nothing to update.\n")
205
+
206
+ result = run_cmd(cmd + params)
207
+ assert_cmd(expected_result, result)
208
+ end
198
209
  end
199
210
 
200
211
  describe 'dump' do
@@ -95,6 +95,18 @@ describe 'template' do
95
95
 
96
96
  assert_cmd(success_result("Provisioning template updated.\n"), result)
97
97
  end
98
+
99
+ it 'updates nothing without template related parameters' do
100
+ params = %w[--id=1 --organization-id=1 --location-id=1]
101
+
102
+ api_expects(:template_kinds, :index, 'Get list of template kinds').returns(index_response([]))
103
+ api_expects(:provisioning_templates, :update, 'Update template with no params').returns({})
104
+
105
+ expected_result = success_result("Nothing to update.\n")
106
+
107
+ result = run_cmd(@cmd + params)
108
+ assert_cmd(expected_result, result)
109
+ end
98
110
  end
99
111
 
100
112
  describe 'create' do
@@ -82,6 +82,17 @@ describe "user" do
82
82
  assert_cmd(expected_result, result)
83
83
  end
84
84
 
85
+ it 'updates nothing without user related parameters' do
86
+ params = %w[--id=1]
87
+
88
+ api_expects(:users, :update, 'Update user with no params').returns({})
89
+
90
+ expected_result = success_result("Nothing to update.\n")
91
+
92
+ result = run_cmd(cmd + params)
93
+ assert_cmd(expected_result, result)
94
+ end
95
+
85
96
  describe "update password" do
86
97
  def replace_foreman_connection(connection)
87
98
  HammerCLI.context[:api_connection].drop('foreman')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammer_cli_foreman
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomáš Strachota
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-05-04 00:00:00.000000000 Z
12
+ date: 2021-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hammer_cli
@@ -86,8 +86,8 @@ extra_rdoc_files:
86
86
  - doc/name_id_resolution.md
87
87
  - doc/option_builder.md
88
88
  - doc/plugin.md
89
- - doc/using_hammer_cli_foreman_command.md
90
89
  - doc/testing.md
90
+ - doc/using_hammer_cli_foreman_command.md
91
91
  - doc/release_notes.md
92
92
  - README.md
93
93
  files:
@@ -134,6 +134,7 @@ files:
134
134
  - lib/hammer_cli_foreman/command_extensions/puppet_environments.rb
135
135
  - lib/hammer_cli_foreman/command_extensions/status.rb
136
136
  - lib/hammer_cli_foreman/command_extensions/subnet.rb
137
+ - lib/hammer_cli_foreman/command_extensions/update_common.rb
137
138
  - lib/hammer_cli_foreman/command_extensions/user.rb
138
139
  - lib/hammer_cli_foreman/commands.rb
139
140
  - lib/hammer_cli_foreman/common_parameter.rb
@@ -369,7 +370,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
369
370
  - !ruby/object:Gem::Version
370
371
  version: '0'
371
372
  requirements: []
372
- rubygems_version: 3.0.8
373
+ rubygems_version: 3.1.2
373
374
  signing_key:
374
375
  specification_version: 4
375
376
  summary: Foreman commands for Hammer
@@ -388,107 +389,107 @@ test_files:
388
389
  - test/data/1.24/foreman_api.json
389
390
  - test/data/2.0/foreman_api.json
390
391
  - test/data/2.1/foreman_api.json
391
- - test/data/README.md
392
392
  - test/data/2.4/foreman_api.json
393
393
  - test/data/2.5/foreman_api.json
394
+ - test/data/README.md
394
395
  - test/functional/associating_commands_test.rb
396
+ - test/functional/audit_test.rb
395
397
  - test/functional/auth_source_test.rb
396
398
  - test/functional/commands/list_test.rb
397
399
  - test/functional/compute_attribute_test.rb
400
+ - test/functional/compute_resource_test.rb
401
+ - test/functional/config_group_test.rb
402
+ - test/functional/filter_test.rb
398
403
  - test/functional/hostgroup/create_test.rb
399
404
  - test/functional/hostgroup/update_test.rb
400
- - test/functional/http_proxy_test.rb
405
+ - test/functional/mail_notification_test.rb
406
+ - test/functional/model_test.rb
407
+ - test/functional/operating_system_test.rb
408
+ - test/functional/organization_test.rb
401
409
  - test/functional/personal_access_token_test.rb
410
+ - test/functional/ping_test.rb
402
411
  - test/functional/proxy_test.rb
403
- - test/functional/report_template_test.rb
412
+ - test/functional/registration_test.rb
413
+ - test/functional/role_test.rb
414
+ - test/functional/settings_test.rb
404
415
  - test/functional/smart_class_parameter_test.rb
405
416
  - test/functional/ssh_keys_test.rb
417
+ - test/functional/status_test.rb
406
418
  - test/functional/subnet/create_test.rb
407
419
  - test/functional/subnet/update_test.rb
408
- - test/functional/template_test.rb
409
420
  - test/functional/test_helper.rb
410
421
  - test/functional/user_mail_notification_test.rb
422
+ - test/functional/usergroup_test.rb
411
423
  - test/functional/virtual_machine_test.rb
424
+ - test/functional/architecture_test.rb
425
+ - test/functional/bookmark_test.rb
426
+ - test/functional/compute_profile_test.rb
427
+ - test/functional/host_test.rb
428
+ - test/functional/http_proxy_test.rb
412
429
  - test/functional/location_test.rb
413
430
  - test/functional/media_test.rb
414
431
  - test/functional/realm_test.rb
415
- - test/functional/role_test.rb
416
- - test/functional/bookmark_test.rb
417
- - test/functional/compute_profile_test.rb
418
- - test/functional/compute_resource_test.rb
419
- - test/functional/config_group_test.rb
420
- - test/functional/mail_notification_test.rb
421
- - test/functional/ping_test.rb
422
- - test/functional/registration_test.rb
423
- - test/functional/status_test.rb
424
- - test/functional/filter_test.rb
425
- - test/functional/model_test.rb
426
- - test/functional/settings_test.rb
427
- - test/functional/audit_test.rb
428
- - test/functional/organization_test.rb
432
+ - test/functional/report_template_test.rb
429
433
  - test/functional/user_test.rb
430
- - test/functional/architecture_test.rb
431
- - test/functional/host_test.rb
432
- - test/functional/operating_system_test.rb
433
- - test/functional/usergroup_test.rb
434
+ - test/functional/template_test.rb
435
+ - test/test_helper.rb
436
+ - test/unit/api/interactive_basic_auth_test.rb
434
437
  - test/unit/api/oauth/oauth_authentication_code_grant_test.rb
435
438
  - test/unit/api/oauth/oauth_password_grant_test.rb
436
439
  - test/unit/api/session_authenticator_wrapper_test.rb
437
440
  - test/unit/api/void_auth_test.rb
438
- - test/unit/api/interactive_basic_auth_test.rb
441
+ - test/unit/api_test.rb
442
+ - test/unit/apipie_resource_mock.rb
443
+ - test/unit/architecture_test.rb
439
444
  - test/unit/audit_test.rb
440
445
  - test/unit/auth_source_external.rb
441
446
  - test/unit/auth_source_ldap_test.rb
447
+ - test/unit/bookmark_test.rb
448
+ - test/unit/commands_test.rb
449
+ - test/unit/common_parameter_test.rb
450
+ - test/unit/compute_profile_test.rb
442
451
  - test/unit/compute_resource_test.rb
452
+ - test/unit/config_group_test.rb
453
+ - test/unit/config_report_test.rb
443
454
  - test/unit/data/test_api.json
444
455
  - test/unit/defaults_test.rb
456
+ - test/unit/dependency_resolver_test.rb
445
457
  - test/unit/domain_test.rb
458
+ - test/unit/exception_handler_test.rb
446
459
  - test/unit/external_usergroup_test.rb
447
460
  - test/unit/fact_test.rb
448
461
  - test/unit/filter_test.rb
449
- - test/unit/helpers/fake_searchables.rb
450
462
  - test/unit/helpers/command.rb
463
+ - test/unit/helpers/fake_searchables.rb
451
464
  - test/unit/helpers/resource_disabled.rb
452
- - test/unit/hostgroup_test.rb
465
+ - test/unit/id_resolver_test.rb
453
466
  - test/unit/image_test.rb
454
467
  - test/unit/location_test.rb
468
+ - test/unit/mail_notification_test.rb
469
+ - test/unit/media_test.rb
455
470
  - test/unit/messages_test.rb
471
+ - test/unit/model_test.rb
472
+ - test/unit/operating_system_test.rb
473
+ - test/unit/option_builders_test.rb
456
474
  - test/unit/option_sources/id_params_test.rb
457
475
  - test/unit/option_sources/ids_params_test.rb
458
476
  - test/unit/organization_test.rb
459
477
  - test/unit/output/formatters_test.rb
478
+ - test/unit/param_filters_test.rb
479
+ - test/unit/partition_table_test.rb
460
480
  - test/unit/puppet_class_test.rb
461
- - test/unit/puppet_environment_test.rb
462
481
  - test/unit/realm_test.rb
463
- - test/unit/smart_class_parameter_test.rb
464
- - test/unit/smart_proxy_test.rb
482
+ - test/unit/role_test.rb
483
+ - test/unit/sessions_test.rb
484
+ - test/unit/settings_test.rb
465
485
  - test/unit/subnet_test.rb
486
+ - test/unit/template_test.rb
466
487
  - test/unit/test_helper.rb
467
488
  - test/unit/test_output_adapter.rb
468
489
  - test/unit/user_test.rb
469
- - test/unit/api_test.rb
470
- - test/unit/commands_test.rb
471
- - test/unit/common_parameter_test.rb
472
- - test/unit/dependency_resolver_test.rb
473
- - test/unit/exception_handler_test.rb
474
- - test/unit/host_test.rb
475
- - test/unit/id_resolver_test.rb
476
- - test/unit/media_test.rb
477
- - test/unit/option_builders_test.rb
478
- - test/unit/param_filters_test.rb
479
- - test/unit/partition_table_test.rb
480
- - test/unit/role_test.rb
481
- - test/unit/sessions_test.rb
482
- - test/unit/template_test.rb
483
490
  - test/unit/usergroup_test.rb
484
- - test/unit/architecture_test.rb
485
- - test/unit/compute_profile_test.rb
486
- - test/unit/config_group_test.rb
487
- - test/unit/mail_notification_test.rb
488
- - test/unit/model_test.rb
489
- - test/unit/settings_test.rb
490
- - test/unit/apipie_resource_mock.rb
491
- - test/unit/bookmark_test.rb
492
- - test/unit/config_report_test.rb
493
- - test/unit/operating_system_test.rb
494
- - test/test_helper.rb
491
+ - test/unit/host_test.rb
492
+ - test/unit/hostgroup_test.rb
493
+ - test/unit/puppet_environment_test.rb
494
+ - test/unit/smart_class_parameter_test.rb
495
+ - test/unit/smart_proxy_test.rb