From a5bb117ff072eadc59e77e74be9cb9c728c0d106 Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Mon, 4 Nov 2024 14:38:23 -0600 Subject: [PATCH] bake: improve error when using incorrect format for setting labels Improves the error message when using an incorrect format for setting labels. This includes the intended format directly in the error message instead of assuming the user knows what the format is. Signed-off-by: Jonathan A. Sternberg --- bake/bake.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/bake/bake.go b/bake/bake.go index e56980e7..8e4077c0 100644 --- a/bake/bake.go +++ b/bake/bake.go @@ -725,10 +725,12 @@ type Target struct { linked bool } -var _ hclparser.WithEvalContexts = &Target{} -var _ hclparser.WithGetName = &Target{} -var _ hclparser.WithEvalContexts = &Group{} -var _ hclparser.WithGetName = &Group{} +var ( + _ hclparser.WithEvalContexts = &Target{} + _ hclparser.WithGetName = &Target{} + _ hclparser.WithEvalContexts = &Group{} + _ hclparser.WithGetName = &Group{} +) func (t *Target) normalize() { t.Annotations = removeDupes(t.Annotations) @@ -865,7 +867,7 @@ func (t *Target) AddOverrides(overrides map[string]Override) error { t.Dockerfile = &value case "args": if len(keys) != 2 { - return errors.Errorf("args require name") + return errors.Errorf("invalid format for args, expecting args.=") } if t.Args == nil { t.Args = map[string]*string{} @@ -873,7 +875,7 @@ func (t *Target) AddOverrides(overrides map[string]Override) error { t.Args[keys[1]] = &value case "contexts": if len(keys) != 2 { - return errors.Errorf("contexts require name") + return errors.Errorf("invalid format for contexts, expecting contexts.=") } if t.Contexts == nil { t.Contexts = map[string]string{} @@ -881,7 +883,7 @@ func (t *Target) AddOverrides(overrides map[string]Override) error { t.Contexts[keys[1]] = value case "labels": if len(keys) != 2 { - return errors.Errorf("labels require name") + return errors.Errorf("invalid format for labels, expecting labels.=") } if t.Labels == nil { t.Labels = map[string]*string{}