(zw *zip.Writer, configPath string)
| 203 | } |
| 204 | |
| 205 | func addRedactedConfig(zw *zip.Writer, configPath string) error { |
| 206 | w, err := zw.Create("client_config.redacted.json") |
| 207 | if err != nil { |
| 208 | return err |
| 209 | } |
| 210 | raw, err := os.ReadFile(configPath) |
| 211 | if err != nil { |
| 212 | _, writeErr := fmt.Fprintf(w, "unable to read config %q: %v\n", configPath, err) |
| 213 | return writeErr |
| 214 | } |
| 215 | redacted, err := redactConfigJSON(raw) |
| 216 | if err != nil { |
| 217 | _, writeErr := fmt.Fprintf(w, "unable to parse config as JSON; raw config omitted: %v\n", err) |
| 218 | return writeErr |
| 219 | } |
| 220 | _, err = w.Write(redacted) |
| 221 | return err |
| 222 | } |
| 223 | |
| 224 | func redactConfigJSON(raw []byte) ([]byte, error) { |
| 225 | dec := json.NewDecoder(bytes.NewReader(raw)) |
no test coverage detected