Skip to content

Commit f0e58c8

Browse files
committed
Fix store inspect command
The output was formatted for a table, the the data is not multi-row, it's key-value, which lead to a poor display of the data available. The verbose flag did not work. Tested with several functions. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 3ec1410 commit f0e58c8

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

commands/store_inspect.go

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,33 @@ func runStoreInspect(cmd *cobra.Command, args []string) error {
4646
return fmt.Errorf("function '%s' not found for platform '%s'", functionName, targetPlatform)
4747
}
4848

49-
content := storeRenderItem(item, targetPlatform)
49+
verbose, err := cmd.Flags().GetBool("verbose")
50+
if err != nil {
51+
return err
52+
}
53+
54+
content := storeRenderItem(item, targetPlatform, verbose)
5055
fmt.Print(content)
5156

5257
return nil
5358
}
5459

55-
func storeRenderItem(item *storeV2.StoreFunction, platform string) string {
60+
func storeRenderItem(item *storeV2.StoreFunction, platform string, verbose bool) string {
5661
var b bytes.Buffer
5762
w := tabwriter.NewWriter(&b, 0, 0, 1, ' ', 0)
58-
fmt.Fprintln(w)
59-
fmt.Fprintln(w, "FUNCTION\tDESCRIPTION\tIMAGE\tPROCESS\tREPO")
60-
fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n",
61-
item.Title,
62-
storeRenderDescription(item.Description),
63-
item.GetImageName(platform),
64-
item.Fprocess,
65-
item.RepoURL,
66-
)
63+
fmt.Fprintf(w, "Info for: %s\n\n", item.Title)
64+
65+
fmt.Fprintf(w, "%s\t%s\n", "Name", item.Name)
66+
67+
desc := item.Description
68+
if !verbose {
69+
desc = storeRenderDescription(desc)
70+
}
71+
72+
fmt.Fprintf(w, "%s\t%s\n", "Description", desc)
73+
fmt.Fprintf(w, "%s\t%s\n", "Image", item.GetImageName(platform))
74+
fmt.Fprintf(w, "%s\t%s\n", "Process", item.Fprocess)
75+
fmt.Fprintf(w, "%s\t%s\n", "Repo URL", item.RepoURL)
6776

6877
fmt.Fprintln(w)
6978
w.Flush()

0 commit comments

Comments
 (0)