mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #78675 from hex108/bug_fix
Fix error case for ExtractFieldPathAsString
This commit is contained in:
commit
acfeb8a05e
@ -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 {
|
||||
|
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user