-
Notifications
You must be signed in to change notification settings - Fork 115
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 Helm Chart resource lookup key handling for objects in default namespace #2655
Conversation
Does the PR have any schema changes?Looking good! No breaking changes found. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2655 +/- ##
==========================================
+ Coverage 18.41% 18.62% +0.20%
==========================================
Files 47 47
Lines 9589 9589
==========================================
+ Hits 1766 1786 +20
+ Misses 7724 7699 -25
- Partials 99 104 +5 ☔ View full report in Codecov by Sentry. |
a479487
to
d994349
Compare
d994349
to
4229cf4
Compare
// to searching for the resource by namespace and name. This occurs when the Helm template manifest explicitly | ||
// sets the namespace field on the resource. | ||
if namespace == "default" || namespace == "" { | ||
return resources[fmt.Sprintf("%s::default/%s", gvk, name)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fallback logic to also explicitly specify default
namespace.
kind: Deployment | ||
metadata: | ||
name: {{ include "local-test-chart.fullname" . }}-new | ||
namespace: {{ .Release.Namespace }} # This is what causes the difference when needing to specify a namespace or not during templating. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the helm template format that requires explicit specification of default
in our resource lookup key.
…mespace (#2655) This pull request modifies the `GetResource` Go method for the Helm Chart resource. Previously, when a resource was deployed to the default namespace, the `default` namespace was always omitted from the resource lookup key. However, in cases where the namespace is explicitly defined in the Helm chart template, the `default` namespace was inadvertently excluded from the resource lookup key despite it being needed. This behavior in Helm is documented in the upstream issue: helm/helm#3553. **Changes Made:** - Implemented a fallback mechanism to include the `default` namespace in the resource lookup key when necessary for the `GetResource` method. **Test Added:** - Added a test (`ChartGetResource`) to verify the `GetResource` method for both types of Helm charts—those with the explicitly defined default namespace and those without. **Verification:** - Verified that the modified `GetResource` method successfully handles scenarios where the namespace is explicitly defined in the Helm chart template. - Confirmed that the added test covers both types of Helm charts and fails when the fallback logic is reverted. Fixes: #2638
Proposed changes
This pull request modifies the
GetResource
Go method for the Helm Chart resource. Previously, when a resource was deployed to the default namespace, thedefault
namespace was always omitted from the resource lookup key. However, in cases where the namespace is explicitly defined in the Helm chart template, thedefault
namespace was inadvertently excluded from the resource lookup key despite it being needed. This behavior in Helm is documented in the upstream issue: helm/helm#3553.Changes Made:
default
namespace in the resource lookup key when necessary for theGetResource
method.Test Added:
ChartGetResource
) to verify theGetResource
method for both types of Helm charts—those with the explicitly defined default namespace and those without.Verification:
GetResource
method successfully handles scenarios where the namespace is explicitly defined in the Helm chart template.Related issues (optional)
Fixes: #2638