BuildAuthChangeDetails computes a redacted, human-readable list of auth field changes. Only prefix, proxy_url, and disabled fields are tracked; sensitive data is never printed.
(oldAuth, newAuth *coreauth.Auth)
| 11 | // BuildAuthChangeDetails computes a redacted, human-readable list of auth field changes. |
| 12 | // Only prefix, proxy_url, and disabled fields are tracked; sensitive data is never printed. |
| 13 | func BuildAuthChangeDetails(oldAuth, newAuth *coreauth.Auth) []string { |
| 14 | changes := make([]string, 0, 3) |
| 15 | |
| 16 | // Handle nil cases by using empty Auth as default |
| 17 | if oldAuth == nil { |
| 18 | oldAuth = &coreauth.Auth{} |
| 19 | } |
| 20 | if newAuth == nil { |
| 21 | return changes |
| 22 | } |
| 23 | |
| 24 | // Compare prefix |
| 25 | oldPrefix := strings.TrimSpace(oldAuth.Prefix) |
| 26 | newPrefix := strings.TrimSpace(newAuth.Prefix) |
| 27 | if oldPrefix != newPrefix { |
| 28 | changes = append(changes, fmt.Sprintf("prefix: %s -> %s", oldPrefix, newPrefix)) |
| 29 | } |
| 30 | |
| 31 | // Compare proxy_url (redacted) |
| 32 | oldProxy := strings.TrimSpace(oldAuth.ProxyURL) |
| 33 | newProxy := strings.TrimSpace(newAuth.ProxyURL) |
| 34 | if oldProxy != newProxy { |
| 35 | changes = append(changes, fmt.Sprintf("proxy_url: %s -> %s", formatProxyURL(oldProxy), formatProxyURL(newProxy))) |
| 36 | } |
| 37 | |
| 38 | // Compare disabled |
| 39 | if oldAuth.Disabled != newAuth.Disabled { |
| 40 | changes = append(changes, fmt.Sprintf("disabled: %t -> %t", oldAuth.Disabled, newAuth.Disabled)) |
| 41 | } |
| 42 | |
| 43 | return changes |
| 44 | } |
no test coverage detected