MCPcopy Index your code
hub / github.com/coder/coder / encodeAIProviderSettings

Function encodeAIProviderSettings

coderd/ai_providers.go:745–754  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

743// settings return an invalid sql.NullString so the row stores SQL NULL
744// and skips dbcrypt encryption entirely.
745func 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

Callers 3

SeedAIProvidersFromEnvFunction · 0.85
aiProvidersCreateMethod · 0.85
aiProvidersUpdateMethod · 0.85

Calls 2

IsZeroMethod · 0.45
MarshalMethod · 0.45

Tested by

no test coverage detected