diff --git a/pkg/flux/flux.go b/pkg/flux/flux.go index 6bedcd8..8ad0d3d 100644 --- a/pkg/flux/flux.go +++ b/pkg/flux/flux.go @@ -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("").