1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-06-29 01:01:26 +02:00
parent 6e260332e8
commit b306706062
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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")
}