Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't log errors with missing CRDs for "get * all" commands #4002

Merged
merged 1 commit into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions cmd/flux/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package main

import (
"context"
"errors"
"fmt"
"os"
"strings"
Expand All @@ -27,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/discovery"
watchtools "k8s.io/client-go/tools/watch"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -176,6 +178,10 @@ func (get getCommand) run(cmd *cobra.Command, args []string) error {

err = kubeClient.List(ctx, get.list.asClientList(), listOpts...)
if err != nil {
var discErr *discovery.ErrGroupDiscoveryFailed
if getAll && (strings.Contains(err.Error(), "no matches for kind") || errors.As(err, &discErr)) {
return nil
}
return err
}

Expand Down
6 changes: 1 addition & 5 deletions cmd/flux/get_image_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package main

import (
"strings"

"github.com/spf13/cobra"

autov1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
Expand Down Expand Up @@ -57,9 +55,7 @@ var getImageAllCmd = &cobra.Command{

for _, c := range allImageCmd {
if err := c.run(cmd, args); err != nil {
if !strings.Contains(err.Error(), "no matches for kind") {
logger.Failuref(err.Error())
}
logger.Failuref(err.Error())
}
}

Expand Down