feat: use AI provider keys at runtime (#25414)

This commit is contained in:
Michael Suchacz
2026-05-22 02:17:09 +02:00
committed by GitHub
parent 40878eeba4
commit 5968c3dac7
12 changed files with 567 additions and 104 deletions
+1
View File
@@ -710,6 +710,7 @@ var (
Identifier: rbac.RoleIdentifier{Name: "chatd"},
DisplayName: "Chat Daemon",
Site: rbac.Permissions(map[string][]policy.Action{
rbac.ResourceAIProvider.Type: {policy.ActionRead},
rbac.ResourceChat.Type: {policy.ActionCreate, policy.ActionRead, policy.ActionUpdate, policy.ActionDelete},
rbac.ResourceWorkspace.Type: {policy.ActionRead, policy.ActionUpdate},
rbac.ResourceDeploymentConfig.Type: {policy.ActionRead},
+20
View File
@@ -225,6 +225,26 @@ func AIProviderKey(t testing.TB, db database.Store, seed database.AIProviderKey,
return key
}
// AIProviderWithOptionalKey inserts an AI provider and, when apiKey is not
// empty, inserts a provider-scoped key for it.
func AIProviderWithOptionalKey(
t testing.TB,
db database.Store,
seed database.AIProvider,
apiKey string,
munge ...func(*database.InsertAIProviderParams),
) database.AIProvider {
t.Helper()
provider := AIProvider(t, db, seed, munge...)
if apiKey != "" {
AIProviderKey(t, db, database.AIProviderKey{
ProviderID: provider.ID,
APIKey: apiKey,
})
}
return provider
}
func ChatProvider(t testing.TB, db database.Store, seed database.ChatProvider, munge ...func(*database.InsertChatProviderParams)) database.ChatProvider {
t.Helper()
params := database.InsertChatProviderParams{