NormalizeServiceAccountJSON normalizes the given JSON-encoded service account payload. It returns the normalized JSON (with sanitized private_key) or, if normalization fails, the original bytes and the encountered error.
(raw []byte)
| 14 | // It returns the normalized JSON (with sanitized private_key) or, if normalization fails, |
| 15 | // the original bytes and the encountered error. |
| 16 | func NormalizeServiceAccountJSON(raw []byte) ([]byte, error) { |
| 17 | if len(raw) == 0 { |
| 18 | return raw, nil |
| 19 | } |
| 20 | var payload map[string]any |
| 21 | if err := json.Unmarshal(raw, &payload); err != nil { |
| 22 | return raw, err |
| 23 | } |
| 24 | normalized, err := NormalizeServiceAccountMap(payload) |
| 25 | if err != nil { |
| 26 | return raw, err |
| 27 | } |
| 28 | out, err := json.Marshal(normalized) |
| 29 | if err != nil { |
| 30 | return raw, err |
| 31 | } |
| 32 | return out, nil |
| 33 | } |
| 34 | |
| 35 | // NormalizeServiceAccountMap returns a copy of the given service account map with |
| 36 | // a sanitized private_key field that is guaranteed to contain a valid RSA PRIVATE KEY PEM block. |
nothing calls this directly
no test coverage detected