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

Refactor DownloadManifests in deploy for clarity and modularity #1436

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

ugiordan
Copy link
Contributor

@ugiordan ugiordan commented Dec 9, 2024

Description

This PR refactors the DownloadManifests function in the deploy package to improve its structure, readability, and maintainability.

The PR introduces the following key changes:

  • Refactored loop to skip failed or irrelevant paths using specific errors: errPathResolutionFailed, and errPathIrrelevant.
  • Extracted TAR unpacking logic into unpackTarFromReader.
  • Centralized path resolution into resolveTargetPath.
  • Moved header processing into processTarHeader and writeFileFromTar for better organization.
  • Unified directory creation with a reusable createDirectory function.
  • Enabled gocritic linter diagnostic defer checkers.

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

- Added helper functions for directory creation and tar file processing.
- Enhanced readability by isolating core operations into smaller, focused functions.
- Simplified error handling and ensured consistent error messages.

Update pkg/deploy/deploy.go

Co-authored-by: Gerard Ryan <[email protected]>

renamed processTarHeader to extractFileOrDirectory
@openshift-ci openshift-ci bot requested review from grdryn and jackdelahunt December 9, 2024 12:14
@ugiordan
Copy link
Contributor Author

ugiordan commented Dec 10, 2024

/retest

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@f9a2b9b). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1436   +/-   ##
=======================================
  Coverage        ?   25.57%           
=======================================
  Files           ?       67           
  Lines           ?     5526           
  Branches        ?        0           
=======================================
  Hits            ?     1413           
  Misses          ?     3940           
  Partials        ?      173           

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

Copy link
Member

@grdryn grdryn left a comment

Choose a reason for hiding this comment

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

/lgtm

Copy link

openshift-ci bot commented Dec 12, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grdryn

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 47007f2 into opendatahub-io:main Dec 12, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants