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

@@ -15,11 +15,17 @@ import (
"github.com/fluxcd/flux2/v2/internal/utils"
)
type sourceReference struct {
kind string
name string
namespace string
}
type reconcileWithSource interface {
adapter
reconcilable
reconcileSource() bool
getSource() (reconcileSource, types.NamespacedName)
getSource() (reconcileSource, sourceReference)
}
type reconcileSource interface {
@@ -61,14 +67,17 @@ func (reconcile reconcileWithSourceCommand) run(cmd *cobra.Command, args []strin
}
if reconcile.object.reconcileSource() || reconcile.force {
reconcileCmd, nsName := reconcile.object.getSource()
nsCopy := *kubeconfigArgs.Namespace
if nsName.Namespace != "" {
*kubeconfigArgs.Namespace = nsName.Namespace
reconcileCmd, srcRef := reconcile.object.getSource()
if reconcileCmd == nil {
return fmt.Errorf("cannot reconcile source of kind %s", srcRef.kind)
}
err := reconcileCmd.run(nil, []string{nsName.Name})
if err != nil {
nsCopy := *kubeconfigArgs.Namespace
if srcRef.namespace != "" {
*kubeconfigArgs.Namespace = srcRef.namespace
}
if err := reconcileCmd.run(nil, []string{srcRef.name}); err != nil {
return err
}
*kubeconfigArgs.Namespace = nsCopy