Skip to content

Commit

Permalink
Fix return value for ExtractFieldPathAsString
Browse files Browse the repository at this point in the history
  • Loading branch information
hex108 committed Jun 4, 2019
1 parent 9f85c5c commit 40f3f3b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/fieldpath/fieldpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions pkg/fieldpath/fieldpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 40f3f3b

Please sign in to comment.