Skip to content

Commit

Permalink
feat: Rename app:migrate to app:adopt
Browse files Browse the repository at this point in the history
  • Loading branch information
stmh committed Dec 13, 2024
1 parent 5c165ca commit a658ff5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <app_name>` Migrates a legacy app, so it can be
controlled by scotty. Please not that most likely you need to adjust the
* `scottyctl app:adopt <app_name>` 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
Expand Down
6 changes: 2 additions & 4 deletions src/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions src/api/handlers/apps/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
State(state): State<SharedAppState>,
) -> Result<impl IntoResponse, AppError> {
Expand All @@ -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?;
Expand Down
8 changes: 4 additions & 4 deletions src/api/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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(
Expand Down

0 comments on commit a658ff5

Please sign in to comment.