Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix interpolation error msg output #292

Merged
merged 1 commit into from Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion interpolation/interpolation.go
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions interpolation/interpolation_test.go
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down