From 4bfef4b9e114d2636cc62c6e037946b831313706 Mon Sep 17 00:00:00 2001 From: Ulysses Souza Date: Wed, 27 Jul 2022 15:10:36 +0200 Subject: [PATCH] Fix interpolation error msg output Signed-off-by: Ulysses Souza --- interpolation/interpolation.go | 2 +- interpolation/interpolation_test.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/interpolation/interpolation.go b/interpolation/interpolation.go index 9c36e6d8..befc6f04 100644 --- a/interpolation/interpolation.go +++ b/interpolation/interpolation.go @@ -115,7 +115,7 @@ func newPathError(path Path, err error) error { return nil case *template.InvalidTemplateError: return errors.Errorf( - "invalid interpolation format for %s: %#v. You may need to escape any $ with another $", + "invalid interpolation format for %s.\nYou may need to escape any $ with another $.\n%s", path, err.Template) default: return errors.Wrapf(err, "error while interpolating %s", path) diff --git a/interpolation/interpolation_test.go b/interpolation/interpolation_test.go index 9743950f..b67eee40 100644 --- a/interpolation/interpolation_test.go +++ b/interpolation/interpolation_test.go @@ -73,7 +73,9 @@ func TestInvalidInterpolation(t *testing.T) { }, } _, err := Interpolate(services, Options{LookupValue: defaultMapping}) - assert.Error(t, err, `invalid interpolation format for servicea.image: "${". You may need to escape any $ with another $`) + assert.Error(t, err, `invalid interpolation format for servicea.image. +You may need to escape any $ with another $. +${`) } func TestInterpolateWithDefaults(t *testing.T) { @@ -131,8 +133,8 @@ func TestValidUnexistentInterpolation(t *testing.T) { } getFullErrorMsg := func(msg string) string { - return fmt.Sprintf("invalid interpolation format for myservice.environment.TESTVAR: "+ - "\"required variable FOO is missing a value: %s\". You may need to escape any $ with another $", msg) + return fmt.Sprintf("invalid interpolation format for myservice.environment.TESTVAR.\n"+ + "You may need to escape any $ with another $.\nrequired variable FOO is missing a value: %s", msg) } for _, testcase := range testcases {