Skip to content

Commit b9c84a0

Browse files
Merge pull request #22528 from sanchezl/oc_admin_must-gather_image
get must-gather image from imagestream
2 parents 97de2a0 + 6d1dc62 commit b9c84a0

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

pkg/oc/cli/admin/mustgather/mustgather.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import (
1919
"k8s.io/kubernetes/pkg/kubectl/scheme"
2020
"k8s.io/kubernetes/pkg/kubectl/util/templates"
2121

22+
"github.com/openshift/client-go/image/clientset/versioned/typed/image/v1"
23+
24+
"github.com/openshift/origin/pkg/image/util"
2225
"github.com/openshift/origin/pkg/oc/cli/rsync"
2326
)
2427

@@ -90,8 +93,18 @@ func (o *MustGatherOptions) Complete(f kcmdutil.Factory, cmd *cobra.Command, arg
9093
o.DestDir = fmt.Sprintf("must-gather.local.%06d", rand.Int63())
9194
}
9295
if len(o.Image) == 0 {
93-
// TODO lookup cluster specific default
94-
o.Image = "quay.io/openshift/origin-must-gather:v4.0"
96+
imageClient, err := v1.NewForConfig(o.Config)
97+
if err != nil {
98+
return err
99+
}
100+
imageStream, err := imageClient.ImageStreams("openshift").Get("must-gather", metav1.GetOptions{})
101+
if err != nil {
102+
return err
103+
}
104+
var ok bool
105+
if o.Image, ok = util.ResolveLatestTaggedImage(imageStream, "latest"); !ok {
106+
return fmt.Errorf("unable to to resolve must-gather image")
107+
}
95108
}
96109
o.PrinterCreated, err = printers.NewTypeSetter(scheme.Scheme).WrapToPrinter(&printers.NamePrinter{Operation: "created"}, nil)
97110
if err != nil {

0 commit comments

Comments
 (0)