AIProviderSettings parses the on-disk JSON form back into a codersdk settings value. SQL NULL and the empty string decode to the zero value.
(col sql.NullString)
| 77 | // settings value. SQL NULL and the empty string decode to the zero |
| 78 | // value. |
| 79 | func AIProviderSettings(col sql.NullString) (codersdk.AIProviderSettings, error) { |
| 80 | if !col.Valid || col.String == "" { |
| 81 | return codersdk.AIProviderSettings{}, nil |
| 82 | } |
| 83 | var s codersdk.AIProviderSettings |
| 84 | if err := json.Unmarshal([]byte(col.String), &s); err != nil { |
| 85 | return codersdk.AIProviderSettings{}, err |
| 86 | } |
| 87 | return s, nil |
| 88 | } |
| 89 | |
| 90 | // maskAIProviderKeys converts the supplied database rows into the |
| 91 | // public-facing AIProviderKey shape, preserving order. Plaintext is |