(data any, m masker.Masker)
| 493 | } |
| 494 | |
| 495 | func applyMaskerToData(data any, m masker.Masker) (any, error) { |
| 496 | switch data := data.(type) { |
| 497 | case map[string]any: |
| 498 | // Recursively apply the masker to the object. |
| 499 | for key, value := range data { |
| 500 | maskedValue, err := applyMaskerToData(value, m) |
| 501 | if err != nil { |
| 502 | return nil, err |
| 503 | } |
| 504 | data[key] = maskedValue |
| 505 | } |
| 506 | case []any: |
| 507 | // Recursively apply the masker to the array. |
| 508 | for i, value := range data { |
| 509 | maskedValue, err := applyMaskerToData(value, m) |
| 510 | if err != nil { |
| 511 | return nil, err |
| 512 | } |
| 513 | data[i] = maskedValue |
| 514 | } |
| 515 | default: |
| 516 | // Apply the masker to the atomic value. |
| 517 | if wrappedValue, ok := getRowValueFromJSONAtomicMember(data); ok { |
| 518 | maskedValue := m.Mask(&masker.MaskData{Data: wrappedValue}) |
| 519 | return getJSONMemberFromRowValue(maskedValue), nil |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | return data, nil |
| 524 | } |
| 525 | |
| 526 | func getJSONMemberFromRowValue(rowValue *v1pb.RowValue) any { |
| 527 | switch rowValue := rowValue.Kind.(type) { |
no test coverage detected