Skip to content

Commit

Permalink
move project to ws
Browse files Browse the repository at this point in the history
  • Loading branch information
lyang2821 committed Aug 29, 2024
1 parent 8b1d3da commit 0c72237
Show file tree
Hide file tree
Showing 13 changed files with 731 additions and 577 deletions.
84 changes: 76 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 2 additions & 12 deletions lapdev-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ pub async fn get_project_branches(
TypedHeader(cookie): TypedHeader<Cookie>,
Path((org_id, project_id)): Path<(Uuid, Uuid)>,
State(state): State<CoreState>,
info: RequestInfo,
) -> Result<Response, ApiError> {
let (user, project) = state.get_project(&cookie, org_id, project_id).await?;
let auth = if let Ok(Some(oauth)) = state.db.get_oauth(project.oauth_id).await {
Expand All @@ -131,10 +130,7 @@ pub async fn get_project_branches(
.await?;
(oauth.provider_login, oauth.access_token)
};
let branches = state
.conductor
.project_branches(user.id, &project, auth, info.ip, info.user_agent)
.await?;
let branches = state.conductor.project_branches(&project, auth).await?;
Ok(Json(branches).into_response())
}

Expand Down Expand Up @@ -171,13 +167,7 @@ pub async fn create_project_prebuild(
let (user, project) = state.get_project(&cookie, org_id, project_id).await?;
let repo = state
.conductor
.get_project_repo_details(
&user,
&project,
Some(&prebuild.branch),
info.ip.clone(),
info.user_agent.clone(),
)
.get_project_repo_details(&user, &project, Some(&prebuild.branch))
.await?;
let prebuild = state
.conductor
Expand Down
14 changes: 13 additions & 1 deletion lapdev-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,18 @@ pub struct RepoComposeService {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum BuildTarget {
Workspace { id: Uuid, name: String },
Prebuild(Uuid),
Prebuild { id: Uuid, project: Uuid },
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct RepoBuildInfo {
pub target: BuildTarget,
pub osuser: String,
pub repo_name: String,
pub repo_url: String,
pub head: String,
pub branch: String,
pub auth: (String, String),
pub env: Vec<(String, String)>,
// the cpu cores that this build will use
pub cpus: CpuCore,
Expand Down Expand Up @@ -359,6 +363,14 @@ pub struct StartWorkspaceRequest {
pub workspace_name: String,
}

#[derive(Serialize, Deserialize, Debug)]
pub struct ProjectRequest {
pub id: Uuid,
pub osuser: String,
pub repo_url: String,
pub auth: (String, String),
}

#[derive(Serialize, Deserialize, Debug)]
pub struct DeleteWorkspaceRequest {
pub osuser: String,
Expand Down
4 changes: 2 additions & 2 deletions lapdev-conductor/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl ConductorService for ConductorRpc {
.add_workspace_update_event(None, id, WorkspaceUpdateEvent::Stdout(line))
.await;
}
BuildTarget::Prebuild(id) => {
BuildTarget::Prebuild { id, .. } => {
self.conductor
.add_prebuild_update_event(id, PrebuildUpdateEvent::Stdout(line))
.await;
Expand Down Expand Up @@ -62,7 +62,7 @@ impl ConductorService for ConductorRpc {
.add_workspace_update_event(None, id, WorkspaceUpdateEvent::Stderr(line))
.await;
}
BuildTarget::Prebuild(id) => {
BuildTarget::Prebuild { id, .. } => {
self.conductor
.add_prebuild_update_event(id, PrebuildUpdateEvent::Stderr(line))
.await;
Expand Down
Loading

0 comments on commit 0c72237

Please sign in to comment.