From 8c9eb43102d4a47fcf6f28ece98d7cc7ec645f03 Mon Sep 17 00:00:00 2001 From: Haoxiang Zhou Date: Thu, 6 Aug 2020 14:48:05 +0100 Subject: [PATCH] Clean up Signed-off-by: Haoxiang Zhou --- cmd/ctl/pkg/status/certificate/certificate.go | 25 ++++++++----------- cmd/ctl/pkg/status/certificate/types.go | 1 - 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/cmd/ctl/pkg/status/certificate/certificate.go b/cmd/ctl/pkg/status/certificate/certificate.go index 3a353df9a..7f4f3e58a 100644 --- a/cmd/ctl/pkg/status/certificate/certificate.go +++ b/cmd/ctl/pkg/status/certificate/certificate.go @@ -42,7 +42,7 @@ import ( var ( long = templates.LongDesc(i18n.T(` -Get details about the current status of a cert-manager Certificate resource, including information on related resources like CertificateRequest.`)) +Get details about the current status of a cert-manager Certificate resource, including information on related resources like CertificateRequest or Order.`)) example = templates.Examples(i18n.T(` # Query status of Certificate with name 'my-crt' in namespace 'my-namespace' @@ -195,22 +195,19 @@ func (o *Options) Run(args []string) error { status = status.withClusterIssuer(clusterIssuer, issuerErr) } - // Nothing to output about Order and Challenge if no CR, stop early - if req == nil { - fmt.Fprintf(o.Out, status.String()) - return nil - } + // Nothing to output about Order and Challenge if no CR + if req != nil { + // Get Order + order, orderErr := findMatchingOrder(o.CMClient, ctx, req) + if orderErr != nil { + orderErr = fmt.Errorf("error when finding Order: %w\n", orderErr) + } else if order == nil { + orderErr = errors.New("No Order found for this Certificate\n") + } - // Get Order - order, orderErr := findMatchingOrder(o.CMClient, ctx, req) - if orderErr != nil { - orderErr = fmt.Errorf("error when finding Order: %w\n", orderErr) - } else if order == nil { - orderErr = errors.New("No Order found for this Certificate\n") + status.withOrder(order, orderErr) } - status.withOrder(order, orderErr) - fmt.Fprintf(o.Out, status.String()) return nil diff --git a/cmd/ctl/pkg/status/certificate/types.go b/cmd/ctl/pkg/status/certificate/types.go index 5962273d1..d5f0fae45 100644 --- a/cmd/ctl/pkg/status/certificate/types.go +++ b/cmd/ctl/pkg/status/certificate/types.go @@ -408,7 +408,6 @@ func (crStatus *CRStatus) String() string { prefixWriter := describe.NewPrefixWriter(tabWriter) util.DescribeEvents(crStatus.Events, prefixWriter, 1) tabWriter.Flush() - fmt.Println(buf.Bytes()) infos += buf.String() buf.Reset() return infos