Skip to content

Commit

Permalink
Prevent segfault with empty kustomization
Browse files Browse the repository at this point in the history
I'm not entirely sure when this happens, but the kustomize can be nil.
Accessing Images then leads to a nil-deref.
With this approach, the updater defaults to empty images when it cannot get the real ones.
  • Loading branch information
Markus Ongyerth committed Jan 25, 2025
1 parent 980eff5 commit a019603
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/argocd/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,18 @@ func writeKustomization(app *v1alpha1.Application, wbc *WriteBackConfig, gitC gi
if kustFile == "" {
return fmt.Errorf("could not find kustomization in %s", base), false
}
source := getApplicationSource(app)
if source == nil {
return fmt.Errorf("failed to find source for kustomization in %s", base), false
}

kustomize := source.Kustomize
images := v1alpha1.KustomizeImages{}
if kustomize != nil {
images = kustomize.Images
}

filterFunc, err := imagesFilter(getApplicationSource(app).Kustomize.Images)
filterFunc, err := imagesFilter(images)
if err != nil {
return err, false
}
Expand Down

0 comments on commit a019603

Please sign in to comment.