| 71 | } |
| 72 | |
| 73 | func normalizeFieldPath(msgValue protoreflect.Message, fieldPath []string) []string { |
| 74 | newFieldPath := make([]string, 0, len(fieldPath)) |
| 75 | for i, fieldName := range fieldPath { |
| 76 | fields := msgValue.Descriptor().Fields() |
| 77 | fieldDesc := fields.ByTextName(fieldName) |
| 78 | if fieldDesc == nil { |
| 79 | fieldDesc = fields.ByJSONName(fieldName) |
| 80 | } |
| 81 | if fieldDesc == nil { |
| 82 | // return initial field path values if no matching message field was found |
| 83 | return fieldPath |
| 84 | } |
| 85 | |
| 86 | newFieldPath = append(newFieldPath, string(fieldDesc.Name())) |
| 87 | |
| 88 | // If this is the last element, we're done |
| 89 | if i == len(fieldPath)-1 { |
| 90 | break |
| 91 | } |
| 92 | |
| 93 | // Only singular message fields are allowed |
| 94 | if fieldDesc.Message() == nil || fieldDesc.Cardinality() == protoreflect.Repeated { |
| 95 | return fieldPath |
| 96 | } |
| 97 | |
| 98 | // Get the nested message |
| 99 | msgValue = msgValue.Get(fieldDesc).Message() |
| 100 | } |
| 101 | |
| 102 | return newFieldPath |
| 103 | } |
| 104 | |
| 105 | func populateFieldValueFromPath(msgValue protoreflect.Message, fieldPath []string, values []string) error { |
| 106 | if len(fieldPath) < 1 { |