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

Fix error handling in package release cli #1553

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

goshkis
Copy link

@goshkis goshkis commented Apr 27, 2024

What this PR does / why we need it:

kctrl package release ... --repo-output ... command is silently ignoring errors from releaseResources function.
Say, if incompatible ytt version is installed, this command will not yield any errors but no content will be written to the destination.

The bug seems to be in a simple mistake unconditionally returning nil in case of any errors

Which issue(s) this PR fixes:

Fixes #1552

Does this PR introduce a user-facing change?

NONE

Additional Notes for your reviewer:

Review Checklist:
  • Follows the developer guidelines
  • Relevant tests are added or updated
  • Relevant docs in this repo added or updated
  • Relevant carvel.dev docs added or updated in a separate PR and there's
    a link to that PR
  • Code is at least as readable and maintainable as it was before this
    change

Additional documentation e.g., Proposal, usage docs, etc.:


Copy link
Member

@praveenrewar praveenrewar left a comment

Choose a reason for hiding this comment

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

Thank you so much for the fix @goshkis!
Do you think you would be able to add a test for this?

Comment on lines 135 to 138
err = o.releaseResources(appSpec, *pkgBuild, &pkgConfigs.Pkgs[0], &pkgConfigs.PkgMetadatas[0])
if err != nil {
return nil
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: We can just do a return directly

return o.releaseResources(appSpec, *pkgBuild, &pkgConfigs.Pkgs[0], &pkgConfigs.PkgMetadatas[0])

Copy link
Author

Choose a reason for hiding this comment

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

It's not the last call in the Run(), so proposed change will skip o.printNextSteps() below.

Signed-off-by: Egor Pak <goshkis@gmail.com>
@goshkis
Copy link
Author

goshkis commented May 3, 2024

Thank you so much for the fix @goshkis! Do you think you would be able to add a test for this?

I looked at the tests in the repo, and think this will take some time for me to understand how to add the new test properly.
Unfortunately, I don't have time for this now.

@rohitagg2020
Copy link
Contributor

rohitagg2020 commented May 25, 2024

Thank you so much for the fix @goshkis! Do you think you would be able to add a test for this?

I looked at the tests in the repo, and think this will take some time for me to understand how to add the new test properly. Unfortunately, I don't have time for this now.

We are ok with skipping the test for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Fix error handling in kctrl package release command
3 participants