From a658ff5e4f4bb866f31f62e66cb8d52a950a7b93 Mon Sep 17 00:00:00 2001 From: Stephan Huber Date: Fri, 13 Dec 2024 16:23:06 +0100 Subject: [PATCH] feat: Rename app:migrate to app:adopt --- README.md | 4 ++-- src/api/error.rs | 6 ++---- src/api/handlers/apps/run.rs | 6 +++--- src/api/router.rs | 8 ++++---- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 400a3e3..670637f 100644 --- a/README.md +++ b/README.md @@ -181,8 +181,8 @@ Here's a short list of avaiable commands app (similar to `docker-compose rm`) * `scottyctl app:create` Create a new app * `scottyctl app:destroy` Destroy a managed app -* `scottyctl app:migrate ` Migrates a legacy app, so it can be - controlled by scotty. Please not that most likely you need to adjust the +* `scottyctl app:adopt ` adopts a legacy app, so it can be + controlled by scotty. Please note that most likely you need to adjust the created `.scotty.yml` file to match your needs. * `scottyctl app:info` Display some info about the app * `scottyctl notify:add` Adds a new service to notify on app changes diff --git a/src/api/error.rs b/src/api/error.rs index a816a87..32fc706 100644 --- a/src/api/error.rs +++ b/src/api/error.rs @@ -70,10 +70,8 @@ pub enum AppError { #[error("Can't create app from an existing .scotty.yml file")] CantCreateAppWithScottyYmlFile, - #[error( - "Cant migrate app {0} with existing settings, app can already be controlled by scotty!" - )] - CantMigrateAppWithExistingSettings(String), + #[error("Cant adopt app {0} with existing settings, app can already be controlled by scotty!")] + CantAdoptAppWithExistingSettings(String), } impl AppError { fn get_error_msg(&self) -> (axum::http::StatusCode, String) { diff --git a/src/api/handlers/apps/run.rs b/src/api/handlers/apps/run.rs index 9e96a22..4a77f31 100644 --- a/src/api/handlers/apps/run.rs +++ b/src/api/handlers/apps/run.rs @@ -151,14 +151,14 @@ pub async fn destroy_app_handler( #[utoipa::path( get, - path = "/api/v1/apps/migrate/{app_id}", + path = "/api/v1/apps/adopt/{app_id}", responses( (status = 200, response = inline(AppData)), (status = 400, response = inline(AppError)) ) )] #[debug_handler] -pub async fn migrate_app_handler( +pub async fn adopt_app_handler( Path(app_id): Path, State(state): State, ) -> Result { @@ -171,7 +171,7 @@ pub async fn migrate_app_handler( let app_data = inspect_app(&state, &docker_compose_path).await?; if app_data.settings.is_some() { - return Err(AppError::CantMigrateAppWithExistingSettings(app_id.clone())); + return Err(AppError::CantAdoptAppWithExistingSettings(app_id.clone())); } let environment = collect_environment_from_app(&state, &app_data).await?; let app_data = app_data.create_settings_from_runtime(&environment).await?; diff --git a/src/api/router.rs b/src/api/router.rs index 255c195..c9eb212 100644 --- a/src/api/router.rs +++ b/src/api/router.rs @@ -15,9 +15,9 @@ use crate::api::handlers::apps::list::__path_list_apps_handler; use crate::api::handlers::apps::list::list_apps_handler; use crate::api::handlers::apps::notify::__path_add_notification_handler; use crate::api::handlers::apps::notify::__path_remove_notification_handler; +use crate::api::handlers::apps::run::__path_adopt_app_handler; use crate::api::handlers::apps::run::__path_destroy_app_handler; use crate::api::handlers::apps::run::__path_info_app_handler; -use crate::api::handlers::apps::run::__path_migrate_app_handler; use crate::api::handlers::apps::run::__path_purge_app_handler; use crate::api::handlers::apps::run::__path_rebuild_app_handler; use crate::api::handlers::apps::run::__path_run_app_handler; @@ -56,9 +56,9 @@ use super::basic_auth::auth; use super::handlers::apps::create::create_app_handler; use super::handlers::apps::notify::add_notification_handler; use super::handlers::apps::notify::remove_notification_handler; +use super::handlers::apps::run::adopt_app_handler; use super::handlers::apps::run::destroy_app_handler; use super::handlers::apps::run::info_app_handler; -use super::handlers::apps::run::migrate_app_handler; use super::handlers::apps::run::purge_app_handler; use super::handlers::apps::run::rebuild_app_handler; use super::handlers::apps::run::run_app_handler; @@ -90,7 +90,7 @@ use super::handlers::tasks::task_list_handler; blueprints_handler, add_notification_handler, remove_notification_handler, - migrate_app_handler, + adopt_app_handler, ), components( schemas( GitlabContext, WebhookContext, MattermostContext, NotificationReceiver, AddNotificationRequest, TaskList, File, FileList, CreateAppRequest, AppData, AppDataVec, TaskDetails, ContainerState, AppSettings, AppStatus, AppTtl, ServicePortMapping, RunningAppContext) @@ -113,7 +113,7 @@ impl ApiRoutes { .route("/api/v1/apps/rebuild/:app_id", get(rebuild_app_handler)) .route("/api/v1/apps/info/:app_id", get(info_app_handler)) .route("/api/v1/apps/destroy/:app_id", get(destroy_app_handler)) - .route("/api/v1/apps/migrate/:app_id", get(migrate_app_handler)) + .route("/api/v1/apps/adopt/:app_id", get(adopt_app_handler)) .route( "/api/v1/apps/create", post(create_app_handler).layer(DefaultBodyLimit::max(