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 cb251f7 commit fc14c02
Showing 1 changed file with 3 additions and 28 deletions.
31 changes: 3 additions & 28 deletions pkg/flux/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,36 +482,11 @@ func State(c *kubernetes.Clientset, dc *dynamic.DynamicClient) (*FluxState, erro
fluxState.Kustomizations = append(fluxState.Kustomizations, kustomization)
}

helmReleases, err := dc.Resource(helmReleaseGVR).
Namespace("").
List(context.TODO(), metav1.ListOptions{})
helmReleases, err := helmReleases(dc)
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).
Namespace("").
List(context.TODO(), metav1.ListOptions{})
if err != nil {
if !strings.Contains(err.Error(), "the server could not find the requested resource") {
return nil, err
} else {
// helm-controller is not mandatory, ignore error
helmReleases = &unstructured.UnstructuredList{}
}
}
} else {
return nil, err
}
}
for _, h := range helmReleases.Items {
unstructured := h.UnstructuredContent()
var helmRelease helmv2beta2.HelmRelease
err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructured, &helmRelease)
if err != nil {
return nil, err
}
fluxState.HelmReleases = append(fluxState.HelmReleases, helmRelease)
return nil, err
}
fluxState.HelmReleases = helmReleases

helmRepositories, err := dc.Resource(helmRepositoryGVR).
Namespace("").
Expand Down

0 comments on commit fc14c02

Please sign in to comment.