encodeAIProviderSettings serializes a settings value into the discriminated JSON form stored in ai_providers.settings. Empty settings return an invalid sql.NullString so the row stores SQL NULL and skips dbcrypt encryption entirely.
(s codersdk.AIProviderSettings)
| 743 | // settings return an invalid sql.NullString so the row stores SQL NULL |
| 744 | // and skips dbcrypt encryption entirely. |
| 745 | func encodeAIProviderSettings(s codersdk.AIProviderSettings) (sql.NullString, error) { |
| 746 | if s.IsZero() { |
| 747 | return sql.NullString{}, nil |
| 748 | } |
| 749 | out, err := json.Marshal(s) |
| 750 | if err != nil { |
| 751 | return sql.NullString{}, err |
| 752 | } |
| 753 | return sql.NullString{String: string(out), Valid: true}, nil |
| 754 | } |
| 755 | |
| 756 | // mergeAIProviderSettings overlays a patch onto an existing settings |
| 757 | // value. Write-only fields (Bedrock AccessKey and AccessKeySecret) use |
no test coverage detected