From 10d26fa407010a0abf04c8c67ea4df4fd8615980 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Wed, 26 Oct 2022 00:44:26 -0700 Subject: [PATCH] Make the custom column display code support entries that lack a newly configured custom column --- client/lib/lib.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/lib/lib.go b/client/lib/lib.go index 0859aaa..7f5e6eb 100644 --- a/client/lib/lib.go +++ b/client/lib/lib.go @@ -397,12 +397,18 @@ func AddToDbIfNew(db *gorm.DB, entry data.HistoryEntry) { } } -func getCustomColumnValue(header string, entry *data.HistoryEntry) (string, error) { +func getCustomColumnValue(ctx *context.Context, header string, entry *data.HistoryEntry) (string, error) { for _, c := range entry.CustomColumns { if strings.EqualFold(c.Name, header) { return c.Val, nil } } + config := hctx.GetConf(ctx) + for _, c := range config.CustomColumns { + if strings.EqualFold(c.ColumnName, header) { + return "", nil + } + } return "", fmt.Errorf("failed to find a column matching the column name %#v (is there a typo?)", header) } @@ -434,7 +440,7 @@ func DisplayResults(ctx *context.Context, results []*data.HistoryEntry) error { case "Command": row = append(row, result.Command) default: - customColumnValue, err := getCustomColumnValue(header, result) + customColumnValue, err := getCustomColumnValue(ctx, header, result) if err != nil { return err }