diff --git a/deploy/k8s/rbac.yaml b/deploy/k8s/rbac.yaml index 309aeb9..bdd11fb 100644 --- a/deploy/k8s/rbac.yaml +++ b/deploy/k8s/rbac.yaml @@ -30,6 +30,7 @@ rules: - source.toolkit.fluxcd.io - kustomize.toolkit.fluxcd.io - helm.toolkit.fluxcd.io + - infra.contrib.fluxcd.io resources: - gitrepositories - ocirepositories @@ -38,6 +39,7 @@ rules: - helmcharts - kustomizations - helmreleases + - terraforms verbs: - get - watch diff --git a/pkg/flux/flux.go b/pkg/flux/flux.go index 4481ab5..c41dfa5 100644 --- a/pkg/flux/flux.go +++ b/pkg/flux/flux.go @@ -405,7 +405,12 @@ func State(c *kubernetes.Clientset, dc *dynamic.DynamicClient) (*FluxState, erro Namespace(""). List(context.TODO(), metav1.ListOptions{}) if err != nil { - return nil, err + if strings.Contains(err.Error(), "the server could not find the requested resource") { + // tofu-controller is not mandatory, ignore error + tfResources = &unstructured.UnstructuredList{} + } else { + return nil, err + } } for _, t := range tfResources.Items { unstructured := t.UnstructuredContent()