Skip to content

Commit

Permalink
debugging interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jiahao6635 committed Jan 17, 2024
1 parent 96b4427 commit b6f4534
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
5 changes: 2 additions & 3 deletions src/handlers/playbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use amp_common::sync::Synchronization;
use std::sync::Arc;

use axum::extract::{Path, Query, State};
use axum::extract::{Path, State};
use axum::http::StatusCode;
use axum::response::IntoResponse;
use axum::Json;
Expand Down Expand Up @@ -65,10 +65,9 @@ pub async fn create(
)]
pub async fn detail(
Path(params): Path<GetPlaybookRequest>,
Query(recursive): Query<bool>,
State(ctx): State<Arc<Context>>,
) -> Result<impl IntoResponse> {
Ok(Json(PlaybookService::get(ctx, params.id, params.reference, params.path, recursive).await?))
Ok(Json(PlaybookService::get(ctx, params.id, params.reference, params.path, true).await?))
}
/// Update a playbook.
#[utoipa::path(
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use tracing_subscriber::EnvFilter;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let filter = EnvFilter::builder().with_default_directive(LevelFilter::INFO.into()).from_env_lossy();
let filter = EnvFilter::builder().with_default_directive(LevelFilter::DEBUG.into()).from_env_lossy();
tracing_subscriber::fmt().with_env_filter(filter).init();

// This returns an error if the `.env` file doesn't exist, but that's not what we want
Expand Down
39 changes: 20 additions & 19 deletions src/services/playbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ use amp_common::scm::content::Content;
use amp_common::scm::git::Tree;
use amp_common::sync::Synchronization;
use std::sync::Arc;
use tracing::info;
use tracing::{info};
use url::Url;

use uuid::Uuid;

Expand All @@ -42,24 +43,24 @@ impl PlaybookService {
let playbook_result = ctx.client.playbooks().get(&id.to_string()).map_err(ApiError::NotFoundPlaybook).ok();
match playbook_result {
Some(playbook) => {
let repo = playbook.preface.repository.unwrap_or_default().repo;
match path.is_some() {
true => {
let content = ctx
.github_client
.contents()
.find(repo.as_str(), path.unwrap().as_str(), reference.as_str())
.ok();
files_response.content = content.unwrap_or(empty_content());
}
false => {
let tree = ctx
.github_client
.git()
.git_trees(repo.as_str(), reference.as_str(), Option::from(recursive))
.ok()
.unwrap_or_default();
files_response.tree = tree.unwrap_or_default();
let repository = playbook.preface.manifest.unwrap_or_default().meta.repository;
if let Ok(url) = Url::parse(repository.as_str()) {
let repo = &url.path()[1..];
match path.is_some() {
true => {
let content =
ctx.github_client.contents().find(repo, path.unwrap().as_str(), reference.as_str()).ok();
files_response.content = content.unwrap_or(empty_content());
}
false => {
let tree = ctx
.github_client
.git()
.git_trees(repo, reference.as_str(), Option::from(recursive))
.ok()
.unwrap_or_default();
files_response.tree = tree.unwrap_or_default();
}
}
}
}
Expand Down

0 comments on commit b6f4534

Please sign in to comment.