mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +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) {
|
func ExtractFieldPathAsString(obj interface{}, fieldPath string) (string, error) {
|
||||||
accessor, err := meta.Accessor(obj)
|
accessor, err := meta.Accessor(obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
if path, subscript, ok := SplitMaybeSubscriptedPath(fieldPath); ok {
|
if path, subscript, ok := SplitMaybeSubscriptedPath(fieldPath); ok {
|
||||||
|
@ -33,9 +33,10 @@ func TestExtractFieldPathAsString(t *testing.T) {
|
|||||||
expectedMessageFragment string
|
expectedMessageFragment string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "not an API object",
|
name: "not an API object",
|
||||||
fieldPath: "metadata.name",
|
fieldPath: "metadata.name",
|
||||||
obj: "",
|
obj: "",
|
||||||
|
expectedMessageFragment: "object does not implement the Object interfaces",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "ok - namespace",
|
name: "ok - namespace",
|
||||||
|
Loading…
Reference in New Issue
Block a user