Skip to main content

systemprompt_cli/commands/cloud/tenant/create/
mod.rs

1//! Tenant creation flows for the `cloud tenant create` command.
2//!
3//! Routes to the cloud-subscription flow ([`create_cloud_tenant`]) or one of
4//! the local flows ([`create_local_tenant`] for a tenant-owned Docker
5//! container, [`create_external_tenant`] for a user-supplied database).
6//!
7//! Copyright (c) systemprompt.io — Business Source License 1.1.
8//! See <https://systemprompt.io> for licensing details.
9
10mod cloud;
11mod local;
12pub mod progress;
13
14pub use cloud::create_cloud_tenant;
15pub use local::{create_external_tenant, create_local_tenant};
16pub use systemprompt_cloud::tenants::swap_to_external_host;
17
18fn sanitize_database_name(name: &str) -> String {
19    let sanitized: String = name
20        .chars()
21        .map(|c| {
22            if c.is_ascii_alphanumeric() || c == '_' {
23                c
24            } else {
25                '_'
26            }
27        })
28        .collect();
29
30    if sanitized.is_empty() {
31        "systemprompt".to_owned()
32    } else if sanitized.chars().next().is_some_and(|c| c.is_ascii_digit()) {
33        format!("db_{}", sanitized)
34    } else {
35        sanitized
36    }
37}