mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-11-28 08:06:16 +00:00
feat: deploy single items to a workspace of this instance on the server
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
19afc8b691
commit
a515ece130
@@ -34,9 +34,12 @@
|
||||
} from '$lib/utils_deployable'
|
||||
import {
|
||||
checkItemExists,
|
||||
deployFromWorkspace,
|
||||
deployItem,
|
||||
getItemValue,
|
||||
getOnBehalfOf
|
||||
getOnBehalfOf,
|
||||
serverDeployKind,
|
||||
type DeployResult
|
||||
} from '$lib/utils_workspace_deploy'
|
||||
import type { App } from './apps/types'
|
||||
import { getAllGridItems } from './apps/editor/appUtils'
|
||||
@@ -382,16 +385,35 @@
|
||||
const target = workspaceToDeployTo
|
||||
deploymentStatus[statusPath] = { status: 'loading' }
|
||||
|
||||
const result = await deployItem({
|
||||
kind,
|
||||
path,
|
||||
workspaceFrom: $operatingWorkspace!,
|
||||
workspaceTo: target!,
|
||||
additionalInformation,
|
||||
onBehalfOf: getOnBehalfOfForDeploy(statusPath, kind),
|
||||
onBehalfOfPrincipal: getOnBehalfOfPermissionedAsForDeploy(statusPath, kind),
|
||||
targetBaseUrl: isRemote ? remoteTarget?.base_url : undefined
|
||||
})
|
||||
const onBehalfOf = getOnBehalfOfForDeploy(statusPath, kind)
|
||||
const onBehalfOfPrincipal = getOnBehalfOfPermissionedAsForDeploy(statusPath, kind)
|
||||
const serverKind = serverDeployKind(kind, additionalInformation)
|
||||
let result: DeployResult
|
||||
if (isRemote) {
|
||||
// The server deploy writes only to this instance; another one is reached through the
|
||||
// remote-deploy proxy, which the client-side deploy calls route by route.
|
||||
result = await deployItem({
|
||||
kind,
|
||||
path,
|
||||
workspaceFrom: $operatingWorkspace!,
|
||||
workspaceTo: target!,
|
||||
additionalInformation,
|
||||
onBehalfOf,
|
||||
onBehalfOfPrincipal,
|
||||
targetBaseUrl: remoteTarget?.base_url
|
||||
})
|
||||
} else if (serverKind) {
|
||||
result = await deployFromWorkspace({
|
||||
kind: serverKind,
|
||||
path,
|
||||
workspaceFrom: $operatingWorkspace!,
|
||||
workspaceTo: target!,
|
||||
onBehalfOf,
|
||||
onBehalfOfPrincipal
|
||||
})
|
||||
} else {
|
||||
result = { success: false, error: `Cannot deploy ${kind} ${path}` }
|
||||
}
|
||||
|
||||
// The statuses on screen are the current destination's; this deploy went to `target`.
|
||||
if (target !== workspaceToDeployTo) return
|
||||
|
||||
@@ -24,6 +24,7 @@ import type { UserDraftItemKind } from '$lib/gen'
|
||||
import { get } from 'svelte/store'
|
||||
import { userWorkspaces } from '$lib/stores'
|
||||
import { apiBaseUrl } from './apiBaseUrl.svelte'
|
||||
import type { TriggerKind } from './components/triggers'
|
||||
import { capabilitiesIn } from '$lib/roleCapabilities'
|
||||
import { roleCanAuthor } from '$lib/editRights'
|
||||
import type { ProtectionRuleset, RoleCapabilities } from '$lib/gen'
|
||||
@@ -174,6 +175,32 @@ function legacyTriggerKind(kind: TriggerDeployKind) {
|
||||
return map[kind]
|
||||
}
|
||||
|
||||
/** The server deploy's kind for each trigger kind `DeployWorkspace.svelte` names. */
|
||||
const SERVER_TRIGGER_KIND: Partial<Record<TriggerKind, Kind>> = {
|
||||
schedules: 'schedule',
|
||||
routes: 'http_trigger',
|
||||
websockets: 'websocket_trigger',
|
||||
kafka: 'kafka_trigger',
|
||||
nats: 'nats_trigger',
|
||||
postgres: 'postgres_trigger',
|
||||
mqtt: 'mqtt_trigger',
|
||||
amqp: 'amqp_trigger',
|
||||
sqs: 'sqs_trigger',
|
||||
gcp: 'gcp_trigger',
|
||||
azure: 'azure_trigger',
|
||||
emails: 'email_trigger'
|
||||
}
|
||||
|
||||
/**
|
||||
* The kind the server deploy takes, resolving the generic `'trigger'` `DeployWorkspace.svelte`
|
||||
* uses. Undefined for a trigger whose sub-kind is unknown or not deployable.
|
||||
*/
|
||||
export function serverDeployKind(kind: Kind, info?: AdditionalInformation): Kind | undefined {
|
||||
if (kind !== 'trigger') return kind
|
||||
const legacy = info?.triggers?.kind
|
||||
return legacy && SERVER_TRIGGER_KIND[legacy]
|
||||
}
|
||||
|
||||
/** An identity in both formats the app policy stores it in. */
|
||||
export type AppIdentity = { email: string; permissionedAs: string }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user