autotailor: Add --local-path option for layered product compatibility#2337
autotailor: Add --local-path option for layered product compatibility#2337ggbecker wants to merge 1 commit intoOpenSCAP:mainfrom
Conversation
|
To which openscap versions do we want to include this change? |
utils/autotailor
Outdated
| help="Where to save the tailoring file. If not supplied, write to " | ||
| "standard output.") | ||
| parser.add_argument( | ||
| "--relative-path", action="store_true", |
There was a problem hiding this comment.
Please document the new option in the man page.
utils/autotailor
Outdated
| benchmark = ET.SubElement(root, "{%s}benchmark" % NS) | ||
| datastream_uri = pathlib.Path( | ||
| self.original_ds_filename).absolute().as_uri() | ||
| if self.use_relative_path: |
There was a problem hiding this comment.
The to_xml method starts getting long. I suggest extracting the code that determines the URI to a separate method eg. _get_datastream_uri()
utils/autotailor
Outdated
| "standard output.") | ||
| parser.add_argument( | ||
| "--relative-path", action="store_true", | ||
| help="Use relative path (basename only) for the benchmark href instead of " |
There was a problem hiding this comment.
Please add a test that covers this feature.
Good question. The answer isn't clear. The RHEL ticket is reported against RHEL 10. That'd mean we shall merge it only to the main branch and it will be a part of OpenSCAP version 1.4.5. However, in the RHEL ticket description, they say they use it for RHEL 9 content, which would suggest that they will need the fix also in RHEL 9, which contains OpenSCAP 1.3.xx and therefore we would need it merge it also to the maint-1.3 branch so that it would become part of OpenSCAP 1.3.15. In general, we try to do the backporting only for bugfixes, in this case it's difficult to say whether this is a bugfix or a new feature, but I feel this would be more of a bugfix. If you agree, then please after this PR is merged create another PR with the same contents but to the maint-1.3 branch. |
| # Preserve relative paths as-is, convert absolute paths to basename | ||
| ds_path = pathlib.Path(self.original_ds_filename) | ||
| if ds_path.is_absolute(): | ||
| # Convert absolute path to basename for compatibility with layered products |
There was a problem hiding this comment.
The option name is -relative-path but if this branch is executed there will be a basename which doesn't have to be a relative path. Consider some better name for the command line option.
85dd6b3 to
1331f26
Compare
e27ed41 to
e6d21f9
Compare
|
@ggbecker This CI error looks legit: |
e6d21f9 to
fa208c2
Compare
Add a new --local-path flag that generates benchmark references using local paths instead of absolute file:// URIs. This enables compatibility with Red Hat Satellite and other layered products that cannot resolve local filesystem paths. When --local-path is specified: - Absolute paths are converted to basename only - Relative paths are preserved as provided by the user The default behavior remains unchanged for backward compatibility. Changes based on code review feedback: - Renamed option from --relative-path to --local-path for clarity (the name better reflects that absolute paths become basenames) - Extracted URI determination logic to _get_datastream_uri() method to improve code organization and readability - Added comprehensive documentation to autotailor.8 man page - Added unit tests for _get_datastream_uri() method - Added integration tests for --local-path functionality Resolves: RHEL-143568
fa208c2 to
0b6baf0
Compare
|



Add a new --relative-path flag that generates benchmark references using relative paths instead of absolute file:// URIs. This enables compatibility with Red Hat Satellite and other layered products that cannot resolve local filesystem paths.
When --relative-path is specified:
The default behavior remains unchanged for backward compatibility.
Resolves: https://redhat.atlassian.net/browse/RHEL-143616