fix(go): update NewCfg to return error for better error handling#312
Merged
fix(go): update NewCfg to return error for better error handling#312
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR improves error handling in the Helm package by updating the NewCfg function to return an error instead of using panic-based error handling. This change makes errors more explicit and easier to handle gracefully.
Key Changes:
- Modified
NewCfgto return(*action.Configuration, error)instead of just*action.Configuration - Replaced panic calls with proper error returns using
fmt.Errorfwith error wrapping - Updated all call sites across 9 files to handle the returned error
- Added comprehensive test coverage for error scenarios
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| native/internal/helm/helm.go | Updated NewCfg function signature to return error; replaced panics with proper error returns |
| native/internal/helm/upgrade.go | Added error handling for NewCfg call |
| native/internal/helm/uninstall.go | Added error handling for NewCfg call |
| native/internal/helm/test.go | Added error handling for NewCfg call |
| native/internal/helm/show.go | Added error handling for NewCfg call |
| native/internal/helm/registry.go | Added error handling for NewCfg calls in both login and logout functions |
| native/internal/helm/push.go | Added error handling for NewCfg call |
| native/internal/helm/list.go | Added error handling for NewCfg call |
| native/internal/helm/install.go | Added error handling for NewCfg call |
| native/internal/helm/plugins_test.go | Updated 5 test cases to handle NewCfg error return |
| native/internal/helm/helm_test.go | Updated existing test and added new tests for invalid kubeconfig scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.