config: seperate AssertValid and AssertStructValid

Added an error structure to make it possible to get the specifics of the failure.
This commit is contained in:
Alex Crawford
2014-10-28 20:04:43 -07:00
parent 6e2db882e6
commit 88e8265cd6
4 changed files with 41 additions and 28 deletions

View File

@@ -61,7 +61,7 @@ func (uc Update) File() (*File, error) {
if config.IsZero(uc.Update) {
return nil, nil
}
if err := config.AssertValid(uc.Update); err != nil {
if err := config.AssertStructValid(uc.Update); err != nil {
return nil, err
}

View File

@@ -17,7 +17,6 @@
package system
import (
"errors"
"io"
"reflect"
"strings"
@@ -101,7 +100,7 @@ func TestUpdateFile(t *testing.T) {
},
{
config: config.Update{RebootStrategy: "wizzlewazzle"},
err: errors.New("invalid value \"wizzlewazzle\" for option \"RebootStrategy\" (valid options: \"best-effort,etcd-lock,reboot,false\")"),
err: &config.ErrorValid{Value: "wizzlewazzle", Field: "RebootStrategy", Valid: []string{"best-effort", "etcd-lock", "reboot", "false"}},
},
{
config: config.Update{Group: "master", Server: "http://foo.com"},