Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHELC-1507] Port environment variables to config file #1272

Merged
merged 8 commits into from
Sep 19, 2024

Conversation

r0x0d
Copy link
Member

@r0x0d r0x0d commented Jun 19, 2024

This patch introduces the initial work to port the environment variables
to be read by a configuration file, parsed, and put into the ToolOpts
class.

With that, we are aiming to remove the environments variables completely
in the next release, managing all the configurations/inhibitors/settings
through that config file.

Jira Issues:

Checklist

  • PR has been tested manually in a VM (either author or reviewer)
  • Jira issue has been made public if possible
  • [RHELC-] or [HMS-] is part of the PR title
  • GitHub label has been added to help with Release notes
  • PR title explains the change from the user's point of view
  • Code and tests are documented properly
  • The commits are squashed to as few commits as possible (without losing data)
  • When merged: Jira issue has been updated to Release Pending if relevant

@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from edd1500 to 66e7744 Compare June 19, 2024 17:04
Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 97.10983% with 10 lines in your changes missing coverage. Please review.

Project coverage is 96.52%. Comparing base (27f2ffc) to head (b4e7e61).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
convert2rhel/toolopts/config.py 96.45% 2 Missing and 3 partials ⚠️
convert2rhel/cli.py 95.18% 2 Missing and 2 partials ⚠️
convert2rhel/toolopts/__init__.py 98.27% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1272      +/-   ##
==========================================
+ Coverage   96.34%   96.52%   +0.17%     
==========================================
  Files          66       70       +4     
  Lines        4983     5065      +82     
  Branches      877      881       +4     
==========================================
+ Hits         4801     4889      +88     
+ Misses        102       98       -4     
+ Partials       80       78       -2     
Flag Coverage Δ
centos-linux-7 92.01% <97.09%> (+0.25%) ⬆️
centos-linux-8 92.88% <97.09%> (+0.23%) ⬆️
centos-linux-9 92.92% <97.10%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

convert2rhel/toolopts.py Fixed Show fixed Hide fixed
convert2rhel/toolopts.py Outdated Show resolved Hide resolved
convert2rhel/toolopts.py Outdated Show resolved Hide resolved
convert2rhel/toolopts.py Outdated Show resolved Hide resolved
convert2rhel/toolopts.py Outdated Show resolved Hide resolved
convert2rhel/toolopts.py Outdated Show resolved Hide resolved
@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from 8ffaf85 to f596240 Compare August 6, 2024 13:53
@r0x0d r0x0d requested a review from a team as a code owner August 6, 2024 13:53
@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from f596240 to 1330775 Compare August 6, 2024 13:54
convert2rhel/toolopts.py Outdated Show resolved Hide resolved
@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from 22f587c to 9639951 Compare August 6, 2024 16:35
@r0x0d r0x0d added kind/feature New feature or request tests/tier0 PR ready to run the essential test suit. Equivalent to `/packit test --labels tier0`. labels Aug 6, 2024
@has-bot
Copy link
Member

has-bot commented Aug 6, 2024

/packit test --labels tier0


Comment generated by an automation.

@r0x0d
Copy link
Member Author

r0x0d commented Aug 6, 2024

/packit build

@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from 9639951 to edb3a8d Compare August 7, 2024 18:32
jochapma
jochapma previously approved these changes Aug 7, 2024
Copy link
Contributor

@jochapma jochapma left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@r0x0d
Copy link
Member Author

r0x0d commented Aug 8, 2024

/packit test --labels tier0

@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from edb3a8d to c742c76 Compare August 8, 2024 13:22
@r0x0d
Copy link
Member Author

r0x0d commented Aug 8, 2024

/packit test --labels tier0

convert2rhel/toolopts.py Outdated Show resolved Hide resolved
@r0x0d r0x0d requested a review from hosekadam August 9, 2024 15:02
@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch 2 times, most recently from 312f34d to e217b35 Compare August 12, 2024 13:09
@r0x0d
Copy link
Member Author

r0x0d commented Aug 12, 2024

/packit build

@r0x0d
Copy link
Member Author

r0x0d commented Aug 12, 2024

/packit test --labels tier0

@r0x0d
Copy link
Member Author

r0x0d commented Sep 16, 2024

/packit test --labels tier0

@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from 5ad7c8c to 2478c25 Compare September 17, 2024 12:54
@r0x0d
Copy link
Member Author

r0x0d commented Sep 17, 2024

/packit test --labels tier0

@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from 2478c25 to 24e1b7f Compare September 17, 2024 13:58
@r0x0d
Copy link
Member Author

r0x0d commented Sep 17, 2024

/packit test --labels tier0

@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from 24e1b7f to 2560fba Compare September 17, 2024 15:02
@r0x0d
Copy link
Member Author

r0x0d commented Sep 17, 2024

/packit test --labels tier0

1 similar comment
@r0x0d
Copy link
Member Author

r0x0d commented Sep 17, 2024

/packit test --labels tier0

@r0x0d r0x0d requested review from Venefilyn, kokesak and jochapma and removed request for jochapma September 17, 2024 19:20
Copy link
Member

@kokesak kokesak left a comment

Choose a reason for hiding this comment

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

Tests are passing. But I think we can extend our test suite. In integration tests that are verifying a certain inhibitor and ability to override it, we could also introduce a variant that puts the override value to the config file instead of the environment. I wouldn't block this PR on this - we can add this in the integration test ticket - https://issues.redhat.com/browse/RHELC-1535

config/convert2rhel.ini Outdated Show resolved Hide resolved
config/convert2rhel.ini Outdated Show resolved Hide resolved
Copy link
Member

@Venefilyn Venefilyn left a comment

Choose a reason for hiding this comment

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

Overall looks great!

In the past, we used to have this portion of code all together inside
the toolopts module, making it very difficult to understand and improve
as the separation was not intuitive enough.

With this patch, we are splitting the cli related functions and classes
to its own module, making it an entrypoint for everything related to CLI
usage.

Toolopts also got its own module to further separate the logic between
cli stuff and options stuff. Historically we call all options from our
source code as "toolopts", so to preserve the naming convention and
minimize as much as possible the changes throughout the codebase, the
same name was preserved.

A new addition was also made which is the config module. This module is
responsible to gather all the configuration options we could ever define
for the tool. Currently, it only has CLIConfig and FileConfig, which are
the two supported options.

Toolopts, at this point, is our final class who will hold all the
options that are composed from the cli and config file (being able to be
extended in the future to other options).
A couple of functions and constants were moved to their related utils
modules to get them out of the way from circle dependency and make the
codebase a bit more clear
This patch introduces the updated references to both toolopts and cli
throughout the codebase as some of the things we had before could be
changed to the new format, especially because no code get executed
before the CLI class parse all the options necessary.

We are not safe to call tool_opts even if nothing is populated inside
the class. Beware that it will still fail if we try to access any
attributes before they get created, but that should be a implementation
problem, not really a workflow one, since we expect that the CLI get
executed very early in the process.
Add a couple of missing variables to the vulture whitelist script so the
hook can stop warning about unused variable.
Parsing the values for inhibitor_overrides now convert it to a boolean
value by default.
@r0x0d r0x0d force-pushed the port-env-vars-to-config-file branch from 2d4a4cf to b4e7e61 Compare September 18, 2024 13:09
@kokesak
Copy link
Member

kokesak commented Sep 18, 2024

/packit test --labels tier0

@Venefilyn Venefilyn enabled auto-merge (squash) September 19, 2024 11:12
@Venefilyn Venefilyn merged commit 0f8750e into oamg:main Sep 19, 2024
40 checks passed
@r0x0d r0x0d deleted the port-env-vars-to-config-file branch September 19, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New feature or request tests/tier0 PR ready to run the essential test suit. Equivalent to `/packit test --labels tier0`.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants