Skip to content

Commit

Permalink
fix: making tofu-controller optional
Browse files Browse the repository at this point in the history
  • Loading branch information
laszlocph committed Oct 2, 2024
1 parent 9e3ad3e commit 1111b5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions deploy/k8s/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ rules:
- source.toolkit.fluxcd.io
- kustomize.toolkit.fluxcd.io
- helm.toolkit.fluxcd.io
- infra.contrib.fluxcd.io
resources:
- gitrepositories
- ocirepositories
Expand All @@ -38,6 +39,7 @@ rules:
- helmcharts
- kustomizations
- helmreleases
- terraforms
verbs:
- get
- watch
Expand Down
7 changes: 6 additions & 1 deletion pkg/flux/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 1111b5f

Please sign in to comment.