From 579107cf2e243e1c8a49e793baa9ca607bad1f13 Mon Sep 17 00:00:00 2001 From: Rober Morales-Chaparro Date: Sun, 3 Dec 2017 14:15:40 +0100 Subject: [PATCH] Improve error message in case invalid env var found If you set an env var with non-yaml content but accidentally collides with a possible configuration env var,... The current error is ```configuration error: error parsing /etc/docker/registry/config.yml: yaml: unmarshal errors: line 1: cannot unmarshal !!str `tcp://1...` into configuration.Parameters``` With this change we can see at least which is the problematic env var. Some orchestrators such as docker-compose set env vars on top on user env vars, so debugging can be tricky if you are not passing vars, and the error is pointing you to a problably valid config file. Signed-off-by: Rober Morales-Chaparro Signed-off-by: Rober Morales-Chaparro --- configuration/parser.go | 1 + 1 file changed, 1 insertion(+) diff --git a/configuration/parser.go b/configuration/parser.go index 934a942af..1306b0c20 100644 --- a/configuration/parser.go +++ b/configuration/parser.go @@ -206,6 +206,7 @@ func (p *Parser) overwriteStruct(v reflect.Value, fullpath string, path []string fieldVal := reflect.New(sf.Type) err := yaml.Unmarshal([]byte(payload), fieldVal.Interface()) if err != nil { + logrus.Warnf("Error parsing environment variable %s", fullpath) return err } field.Set(reflect.Indirect(fieldVal))