Fix return value for ExtractFieldPathAsString

This commit is contained in:
Jun Gong 2019-06-04 11:52:26 +08:00
parent 9f85c5c4b5
commit 40f3f3bd0e
2 changed files with 5 additions and 4 deletions

View File

@ -46,7 +46,7 @@ func FormatMap(m map[string]string) (fmtStr string) {
func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error) {
accessor, err := meta.Accessor(obj)
if err != nil {
return "", nil
return "", err
}
if path, subscript, ok := SplitMaybeSubscriptedPath(fieldPath); ok {

View File

@ -33,9 +33,10 @@ func TestExtractFieldPathAsString(t *testing.T) {
expectedMessageFragment string
}{
{
name: "not an API object",
fieldPath: "metadata.name",
obj: "",
name: "not an API object",
fieldPath: "metadata.name",
obj: "",
expectedMessageFragment: "object does not implement the Object interfaces",
},
{
name: "ok - namespace",