From b3067060623c6774a9936a2a87a3086798bdb250 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 29 Jun 2018 01:01:26 +0200 Subject: [PATCH] improve error message for invalid ndots number instead of printing the whole option, print the _number_ only, because that's what the error-message is pointing at; Before this change: invalid number for ndots option ndots:foobar After this change: invalid number for ndots option: foobar Signed-off-by: Sebastiaan van Stijn --- libnetwork/sandbox_dns_unix.go | 2 +- libnetwork/service_common_test.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libnetwork/sandbox_dns_unix.go b/libnetwork/sandbox_dns_unix.go index 1c4c48ad7b..4df8224478 100644 --- a/libnetwork/sandbox_dns_unix.go +++ b/libnetwork/sandbox_dns_unix.go @@ -369,7 +369,7 @@ dnsOpt: return fmt.Errorf("invalid ndots option %v", option) } if num, err := strconv.Atoi(parts[1]); err != nil { - return fmt.Errorf("invalid number for ndots option %v", option) + return fmt.Errorf("invalid number for ndots option: %v", parts[1]) } else if num >= 0 { // if the user sets ndots, use the user setting sb.ndotsSet = true diff --git a/libnetwork/service_common_test.go b/libnetwork/service_common_test.go index 51e0e36f20..ab87cea779 100644 --- a/libnetwork/service_common_test.go +++ b/libnetwork/service_common_test.go @@ -97,4 +97,10 @@ func TestDNSOptions(t *testing.T) { dnsOptionsList = resolvconf.GetOptions(currRC.Content) assert.Equal(t, 1, len(dnsOptionsList)) assert.Equal(t, "ndots:0", dnsOptionsList[0]) + + sb2.(*sandbox).config.dnsOptionsList = []string{"ndots:foobar"} + err = sb2.(*sandbox).setupDNS() + require.NoError(t, err) + err = sb2.(*sandbox).rebuildDNS() + require.EqualError(t, err, "invalid number for ndots option: foobar") }