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:
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -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"},
|
||||
|
Reference in New Issue
Block a user