fromFieldPath tries to read the value from the supplied field path first as a plain string. If this fails, it falls back to reading it as JSON.
(from runtime.Object, path string)
| 64 | // fromFieldPath tries to read the value from the supplied field path first as a |
| 65 | // plain string. If this fails, it falls back to reading it as JSON. |
| 66 | func fromFieldPath(from runtime.Object, path string) ([]byte, error) { |
| 67 | fromMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(from) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | |
| 72 | str, err := fieldpath.Pave(fromMap).GetString(path) |
| 73 | if err == nil { |
| 74 | return []byte(str), nil |
| 75 | } |
| 76 | |
| 77 | in, err := fieldpath.Pave(fromMap).GetValue(path) |
| 78 | if err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | |
| 82 | return json.Marshal(in) |
| 83 | } |
| 84 | |
| 85 | // supportsConnectionDetails determines if the given XR supports native/classic |
| 86 | // connection details. |
no outgoing calls
no test coverage detected