From ed6f4ea37584a9d0d226d053f3611797d7504453 Mon Sep 17 00:00:00 2001 From: nmiletic Date: Wed, 31 Aug 2022 09:21:11 +0200 Subject: [PATCH] Dump labels and annotations for function via getmeta cli (#2525) Co-authored-by: Nemanja Miletic --- pkg/fission-cli/cmd/function/getmeta.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pkg/fission-cli/cmd/function/getmeta.go b/pkg/fission-cli/cmd/function/getmeta.go index e0f54d2e..108aa4ad 100644 --- a/pkg/fission-cli/cmd/function/getmeta.go +++ b/pkg/fission-cli/cmd/function/getmeta.go @@ -18,8 +18,6 @@ package function import ( "fmt" - "os" - "text/tabwriter" "github.com/pkg/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -46,10 +44,20 @@ func (opts *GetMetaSubCommand) do(input cli.Input) error { return errors.Wrap(err, "error getting function") } - w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0) - fmt.Fprintf(w, "%v\t%v\n", "NAME", "ENV") - fmt.Fprintf(w, "%v\t%v\n", fn.ObjectMeta.Name, fn.Spec.Environment.Name) - w.Flush() + fmt.Printf("Name: %v\n", fn.ObjectMeta.Name) + fmt.Printf("Environment: %v\n", fn.Spec.Environment.Name) + if len(fn.ObjectMeta.Labels) != 0 { + fmt.Println("Labels:") + for k, v := range fn.ObjectMeta.Labels { + fmt.Printf(" %s=%s\n", k, v) + } + } + if len(fn.ObjectMeta.Annotations) != 0 { + fmt.Println("Annotations:") + for k, v := range fn.ObjectMeta.Annotations { + fmt.Printf(" %s=%s\n", k, v) + } + } return nil }