mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-04 08:09:16 +00:00
fixup! feat: create a service account from the run-as picker at deploy
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
62ebe343e1
commit
4c72597dcf
@@ -134,11 +134,13 @@ export async function createPendingServiceAccount(
|
||||
const account = getPendingServiceAccount(workspace, permissionedAs)
|
||||
if (!account || !permissionedAs) return undefined
|
||||
const { username } = account
|
||||
const exists = await UserService.getUser({ workspace, username }).then(
|
||||
() => true,
|
||||
() => false
|
||||
)
|
||||
if (!exists) {
|
||||
const existing = await UserService.getUser({ workspace, username }).catch(() => undefined)
|
||||
// Someone may have taken the name since it was picked: granting to it would hand a person, or
|
||||
// a disabled account, what was meant for the new one.
|
||||
if (existing && (!existing.is_service_account || existing.disabled)) {
|
||||
throw new Error(`${username} is already taken by a user that is not an enabled service account`)
|
||||
}
|
||||
if (!existing) {
|
||||
await WorkspaceService.createServiceAccount({
|
||||
workspace,
|
||||
requestBody: { username, operator: true }
|
||||
@@ -184,7 +186,7 @@ export async function createPolicyServiceAccount(
|
||||
if (email) policy.on_behalf_of_email = email
|
||||
return true
|
||||
} catch (e) {
|
||||
sendUserToast(`Could not create ${policy.on_behalf_of}: ${e?.body ?? e}`, true)
|
||||
sendUserToast(`Could not create ${policy.on_behalf_of}: ${e?.body ?? e?.message ?? e}`, true)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
const created = await createPendingServiceAccount(targetWorkspace, runsAs)
|
||||
if (created) email = created
|
||||
} catch (e) {
|
||||
sendUserToast(`Could not create ${runsAs}: ${e?.body ?? e}`, true)
|
||||
sendUserToast(`Could not create ${runsAs}: ${e?.body ?? e?.message ?? e}`, true)
|
||||
return
|
||||
} finally {
|
||||
deploying = false
|
||||
|
||||
Reference in New Issue
Block a user