Merge pull request #78675 from hex108/bug_fix

Fix error case for ExtractFieldPathAsString
This commit is contained in:
Kubernetes Prow Robot 2019-07-30 03:35:04 -07:00 committed by GitHub
commit acfeb8a05e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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",