diff --git a/pkg/cli/admin/mustgather/mustgather.go b/pkg/cli/admin/mustgather/mustgather.go index eecd0dbdff..b303283950 100644 --- a/pkg/cli/admin/mustgather/mustgather.go +++ b/pkg/cli/admin/mustgather/mustgather.go @@ -268,6 +268,7 @@ func (o *MustGatherOptions) completeImages(ctx context.Context) error { return fmt.Errorf("unable to resolve image stream '%v': %v", imageStream, err) } } + // If no images or --all flag is set, use default must-gather image if len(o.Images) == 0 || o.AllImages { var image string var err error @@ -284,12 +285,20 @@ func (o *MustGatherOptions) completeImages(ctx context.Context) error { pluginImages, err = o.annotatedCSVs(ctx) if err != nil { - return err + return fmt.Errorf("failed to list CSVs: %v", err) + } + for _, csv := range csvs.Items { + ann := csv.GetAnnotations() + if v, ok := ann[mgAnnotation]; ok { + pluginImages[v] = struct{}{} + } else { + o.log("WARNING: CSV operator %s doesn't have the must-gather-image annotation.", csv.GetName()) + } } cos, err := o.ConfigClient.ConfigV1().ClusterOperators().List(ctx, metav1.ListOptions{}) if err != nil { - return err + return fmt.Errorf("failed to list ClusterOperators: %v", err) } for _, item := range cos.Items { ann := item.GetAnnotations() @@ -304,7 +313,7 @@ func (o *MustGatherOptions) completeImages(ctx context.Context) error { } } o.log("Using must-gather plug-in image: %s", strings.Join(o.Images, ", ")) - + return nil }