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 0bba899 commit cb251f7
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions pkg/flux/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,24 @@ var (
}

helmRepositoryGVR = schema.GroupVersionResource{
Group: "source.toolkit.fluxcd.io",
Version: "v1",
Resource: "helmrepositories",
}

helmRepositoryGVRv1beta2 = schema.GroupVersionResource{
Group: "source.toolkit.fluxcd.io",
Version: "v1beta2",
Resource: "helmrepositories",
}

helmChartGVR = schema.GroupVersionResource{
Group: "source.toolkit.fluxcd.io",
Version: "v1",
Resource: "helmcharts",
}

helmChartGVRv1beta2 = schema.GroupVersionResource{
Group: "source.toolkit.fluxcd.io",
Version: "v1beta2",
Resource: "helmcharts",
Expand Down Expand Up @@ -505,7 +517,17 @@ 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") {
// let's try the deprecated v1beta2
helmRepositories, err = dc.Resource(helmRepositoryGVRv1beta2).
Namespace("").
List(context.TODO(), metav1.ListOptions{})
if err != nil {
return nil, err
}
} else {
return nil, err
}
}
for _, h := range helmRepositories.Items {
unstructured := h.UnstructuredContent()
Expand All @@ -521,7 +543,17 @@ 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") {
// let's try the deprecated v1beta2
helmCharts, err = dc.Resource(helmChartGVRv1beta2).
Namespace("").
List(context.TODO(), metav1.ListOptions{})
if err != nil {
return nil, err
}
} else {
return nil, err
}
}
for _, h := range helmCharts.Items {
unstructured := h.UnstructuredContent()
Expand Down

0 comments on commit cb251f7

Please sign in to comment.