1
0
mirror of synced 2026-02-13 13:06:56 +00:00

Fix panic on reconcile with source of ExternalArtifact kind

Signed-off-by: Matheus Pimenta <matheuscscp@gmail.com>
This commit is contained in:
Matheus Pimenta
2025-11-17 13:28:22 +00:00
parent e95da82f5a
commit 69feb7214a
4 changed files with 47 additions and 33 deletions

View File

@@ -20,7 +20,6 @@ import (
"fmt"
"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/types"
helmv2 "github.com/fluxcd/helm-controller/api/v2"
sourcev1 "github.com/fluxcd/source-controller/api/v1"
@@ -67,7 +66,7 @@ func (obj helmReleaseAdapter) reconcileSource() bool {
return rhrArgs.syncHrWithSource
}
func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName) {
func (obj helmReleaseAdapter) getSource() (reconcileSource, sourceReference) {
var (
name string
ns string
@@ -78,21 +77,26 @@ func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName
if ns == "" {
ns = obj.Namespace
}
namespacedName := types.NamespacedName{
Name: name,
Namespace: ns,
srcRef := sourceReference{
kind: obj.Spec.ChartRef.Kind,
name: name,
namespace: ns,
}
if obj.Spec.ChartRef.Kind == sourcev1.HelmChartKind {
switch obj.Spec.ChartRef.Kind {
case sourcev1.HelmChartKind:
return reconcileWithSourceCommand{
apiType: helmChartType,
object: helmChartAdapter{&sourcev1.HelmChart{}},
force: true,
}, namespacedName
}, srcRef
case sourcev1.OCIRepositoryKind:
return reconcileCommand{
apiType: ociRepositoryType,
object: ociRepositoryAdapter{&sourcev1.OCIRepository{}},
}, srcRef
default:
return nil, srcRef
}
return reconcileCommand{
apiType: ociRepositoryType,
object: ociRepositoryAdapter{&sourcev1.OCIRepository{}},
}, namespacedName
default:
// default case assumes the HelmRelease is using a HelmChartTemplate
ns = obj.Spec.Chart.Spec.SourceRef.Namespace
@@ -104,9 +108,10 @@ func (obj helmReleaseAdapter) getSource() (reconcileSource, types.NamespacedName
apiType: helmChartType,
object: helmChartAdapter{&sourcev1.HelmChart{}},
force: true,
}, types.NamespacedName{
Name: name,
Namespace: ns,
}, sourceReference{
kind: sourcev1.HelmChartKind,
name: name,
namespace: ns,
}
}
}