Skip to content

Commit

Permalink
Reducing log spam
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Oct 2, 2024
1 parent 1111b5f commit 0bba899
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions pkg/flux/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ var (
}

helmReleaseGVR = schema.GroupVersionResource{
Group: "helm.toolkit.fluxcd.io",
Version: "v2",
Resource: "helmreleases",
}

helmReleaseGVRV2beta2 = schema.GroupVersionResource{
Group: "helm.toolkit.fluxcd.io",
Version: "v2beta2",
Resource: "helmreleases",
Expand Down Expand Up @@ -284,14 +290,24 @@ func helmReleases(dc *dynamic.DynamicClient) ([]helmv2beta2.HelmRelease, error)
List(context.TODO(), metav1.ListOptions{})
if err != nil {
if strings.Contains(err.Error(), "the server could not find the requested resource") {
// let's try the deprecated v2beta1
helmReleases, err = dc.Resource(helmReleaseGVRV2beta1).
// let's try the deprecated v2beta2
helmReleases, err = dc.Resource(helmReleaseGVRV2beta2).
Namespace("").
List(context.TODO(), metav1.ListOptions{})
if err != nil {
if strings.Contains(err.Error(), "the server could not find the requested resource") {
// helm-controller is not mandatory, ignore error
return releases, nil
// let's try the deprecated v2beta1
helmReleases, err = dc.Resource(helmReleaseGVRV2beta1).
Namespace("").
List(context.TODO(), metav1.ListOptions{})
if err != nil {
if strings.Contains(err.Error(), "the server could not find the requested resource") {
// helm-controller is not mandatory, ignore error
return releases, nil
} else {
return nil, err
}
}
} else {
return nil, err
}
Expand Down

0 comments on commit 0bba899

Please sign in to comment.