From 87dbb3ec350dd13696bab20c1fd2775de876827a Mon Sep 17 00:00:00 2001 From: Martin Povolny Date: Sun, 18 Dec 2022 10:26:55 +0100 Subject: [PATCH] feat: Print a warning message when an invalid custom field is specified. --- pkg/jira/create.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/jira/create.go b/pkg/jira/create.go index 835ec113..84182b49 100644 --- a/pkg/jira/create.go +++ b/pkg/jira/create.go @@ -3,7 +3,9 @@ package jira import ( "context" "encoding/json" + "fmt" "net/http" + "os" "strconv" "strings" @@ -196,11 +198,13 @@ func constructCustomFields(fields map[string]string, data *createRequest) { data.Fields.M.customFields = make(customField) for key, val := range fields { + found := false for _, configured := range configuredFields { identifier := strings.ReplaceAll(strings.ToLower(strings.TrimSpace(configured.Name)), " ", "-") if identifier != strings.ToLower(key) { continue } + found = true switch configured.Schema.DataType { case customFieldFormatOption: @@ -230,6 +234,9 @@ func constructCustomFields(fields map[string]string, data *createRequest) { data.Fields.M.customFields[configured.Key] = val } } + if !found { + fmt.Fprintf(os.Stderr, "\nInvalid custom field specified: %s\n", key) + } } }