mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-10-22 00:03:35 +00:00
refactor(git-sync): move gitInitRepo hub path resolution to backend
This commit is contained in:
@@ -124,6 +124,10 @@ pub fn workspaced_service() -> Router {
|
||||
)
|
||||
.route("/edit_datatable_config", post(edit_datatable_config))
|
||||
.route("/git_sync_enabled", get(get_git_sync_enabled))
|
||||
.route(
|
||||
"/git_init_repo_script_path",
|
||||
get(get_git_init_repo_script_path),
|
||||
)
|
||||
.route("/edit_git_sync_config", post(edit_git_sync_config))
|
||||
.route("/edit_git_sync_repository", post(edit_git_sync_repository))
|
||||
.route(
|
||||
@@ -2535,6 +2539,12 @@ async fn get_git_sync_enabled(
|
||||
})))
|
||||
}
|
||||
|
||||
async fn get_git_init_repo_script_path() -> JsonResult<serde_json::Value> {
|
||||
Ok(Json(serde_json::json!({
|
||||
"script_path": windmill_common::workspaces::LATEST_GIT_INIT_REPO_SCRIPT_PATH,
|
||||
})))
|
||||
}
|
||||
|
||||
async fn edit_git_sync_config(
|
||||
authed: ApiAuthed,
|
||||
Extension(db): Extension<DB>,
|
||||
|
||||
@@ -4376,6 +4376,27 @@ paths:
|
||||
type: integer
|
||||
nullable: true
|
||||
|
||||
/w/{workspace}/workspaces/git_init_repo_script_path:
|
||||
get:
|
||||
summary: Get the latest git init repository hub script path
|
||||
operationId: getGitInitRepoScriptPath
|
||||
tags:
|
||||
- workspace
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/WorkspaceId"
|
||||
responses:
|
||||
"200":
|
||||
description: Latest hub script path used to initialize a git repository
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
script_path:
|
||||
type: string
|
||||
required:
|
||||
- script_path
|
||||
|
||||
/w/{workspace}/workspaces/edit_git_sync_config:
|
||||
post:
|
||||
summary: edit workspace git sync settings
|
||||
|
||||
@@ -159,6 +159,8 @@ pub enum ObjectType {
|
||||
|
||||
pub const LATEST_GIT_SYNC_SCRIPT_PATH: &str = "hub/28217/sync-script-to-git-repo-windmill";
|
||||
|
||||
pub const LATEST_GIT_INIT_REPO_SCRIPT_PATH: &str = "hub/28219/git-sync%3A-init-repository-windmill";
|
||||
|
||||
/// Prefix used to identify fork workspaces. A workspace whose id starts with this string is a
|
||||
/// fork of another workspace.
|
||||
pub const WM_FORK_PREFIX: &str = "wm-fork-";
|
||||
|
||||
@@ -301,9 +301,10 @@ export function createGitSyncContext(workspace: string) {
|
||||
const detectionTimestamp = Date.now()
|
||||
|
||||
try {
|
||||
const { script_path } = await WorkspaceService.getGitInitRepoScriptPath({ workspace })
|
||||
const jobId = await JobService.runScriptByPath({
|
||||
workspace,
|
||||
path: hubPaths.gitInitRepo,
|
||||
path: script_path,
|
||||
requestBody: {
|
||||
workspace_id: workspace,
|
||||
repo_url_resource_path: repo.git_repo_resource_path,
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
Edit3
|
||||
} from 'lucide-svelte'
|
||||
import GitDiffPreview from '../GitDiffPreview.svelte'
|
||||
import { JobService } from '$lib/gen'
|
||||
import { JobService, WorkspaceService } from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import { sendUserToast } from '$lib/toast'
|
||||
import hubPaths from '$lib/hubPaths.json'
|
||||
import { jobManager } from '$lib/services/JobManager'
|
||||
import type { SyncResponse, SettingsResponse, SettingsObject } from '$lib/git-sync'
|
||||
|
||||
@@ -158,9 +157,10 @@
|
||||
currentGitSyncSettings?.repositories?.[repoIndex!]?.use_individual_branch === true
|
||||
}
|
||||
|
||||
const { script_path } = await WorkspaceService.getGitInitRepoScriptPath({ workspace })
|
||||
const jobId = await JobService.runScriptByPath({
|
||||
workspace,
|
||||
path: hubPaths.gitInitRepo,
|
||||
path: script_path,
|
||||
requestBody: payload,
|
||||
skipPreprocessor: true
|
||||
})
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
import { Button, Alert } from '$lib/components/common'
|
||||
import { Loader2, CheckCircle2, XCircle, Terminal, ChevronDown, ChevronUp } from 'lucide-svelte'
|
||||
import GitDiffPreview from '../GitDiffPreview.svelte'
|
||||
import { JobService } from '$lib/gen'
|
||||
import { JobService, WorkspaceService } from '$lib/gen'
|
||||
import { workspaceStore } from '$lib/stores'
|
||||
import hubPaths from '$lib/hubPaths.json'
|
||||
import { jobManager } from '$lib/services/JobManager'
|
||||
import type { SyncResponse, SettingsObject } from '$lib/git-sync'
|
||||
|
||||
@@ -89,9 +88,10 @@
|
||||
settings_json: JSON.stringify(uiState)
|
||||
}
|
||||
|
||||
const { script_path } = await WorkspaceService.getGitInitRepoScriptPath({ workspace })
|
||||
const jobId = await JobService.runScriptByPath({
|
||||
workspace,
|
||||
path: hubPaths.gitInitRepo,
|
||||
path: script_path,
|
||||
requestBody: payload,
|
||||
skipPreprocessor: true
|
||||
})
|
||||
|
||||
@@ -93,7 +93,6 @@ export function rawAppToHubUrl(hubBaseUrl: string, summary?: string): URL {
|
||||
|
||||
type HubPaths = {
|
||||
gitSyncTest: string
|
||||
gitInitRepo: string
|
||||
slackErrorHandler: string
|
||||
slackRecoveryHandler: string
|
||||
slackSuccessHandler: string
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
"deprecated_gitSync_latest": "hub/28180/sync-script-to-git-repo-windmill",
|
||||
"deprecated_gitSync_25": "hub/28183/sync-script-to-git-repo-windmill",
|
||||
"gitSyncTest": "hub/28184/git-repo-test-read-write-windmill",
|
||||
"gitInitRepo": "hub/28219/git-sync%3A-init-repository-windmill",
|
||||
"slackErrorHandler": "hub/19741/workspace-or-schedule-error-handler-slack",
|
||||
"slackErrorHandler_0": "hub/9079/workspace-or-schedule-error-handler-slack",
|
||||
"slackErrorHandler_1": "hub/9206/workspace-or-schedule-error-handler-slack",
|
||||
|
||||
Reference in New Issue
Block a user