Skip to content

Fixes #38410 - Add mechanism for deprecating displayed fields#395

Merged
ofedoren merged 1 commit intotheforeman:masterfrom
qcjames53:38410
May 14, 2025
Merged

Fixes #38410 - Add mechanism for deprecating displayed fields#395
ofedoren merged 1 commit intotheforeman:masterfrom
qcjames53:38410

Conversation

@qcjames53
Copy link
Contributor

@qcjames53 qcjames53 commented May 7, 2025

Currently, hammer has no way to deprecate old fields our developers wish to remove. This PR adds an option for deprecating a field with :deprecated => true. When a deprecated field is displayed, a stderr warning message is shown indicating it will be removed in the future. Updated doc/creating_commands.md to show how to deprecate a field.

How to test:

  1. Find a field in hammer-cli-foreman or hammer-cli-katello and modify it to have the deprecated flag:
field :example, _("Example field"), Fields::Field, :deprecated => true
  1. When displaying this field, verify that a warning is printed to stderr:
WARNING: Field 'Example field' is deprecated and may be removed in future versions.
  1. Remove this field from the default set and confirm that the error message does not display when the field is not rendered:
field :example, _("Example field"), Fields::Field, :sets => ['ALL'], :deprecated => true
  1. Confirm that the error message does display for a variety of field output edge cases (--fields, etc). Ensure output is always sent to stderr.
  2. Add the :replaced_by flag and repeat the previous testing steps:
field :example, _("Example field"), Fields::Field, :replaced_by => "Example/Path"

Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @qcjames53 ! This is really a great addition :)

Some nitpicks though:

@qcjames53
Copy link
Contributor Author

@ofedoren Thank you for the review! I have added your requested changes and fixed the commit name.

@qcjames53 qcjames53 changed the title Refs #38410 - Add mechanism for deprecating displayed fields Fixes #38410 - Add mechanism for deprecating displayed fields May 13, 2025
Copy link
Member

@ofedoren ofedoren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @qcjames53 ! We could probably generalize warning message/options instead of hardcoding 2 messages, but that can be dealt with in the future. As of now it seems and works quite nicely.

@ofedoren ofedoren merged commit 69199dd into theforeman:master May 14, 2025
8 checks passed
@qcjames53 qcjames53 deleted the 38410 branch May 14, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants