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 [`create_local_tenant`] for a tenant-owned Docker container or
4//! [`create_external_tenant`] for a user-supplied database.
5//!
6//! Copyright (c) systemprompt.io — Business Source License 1.1.
7//! See <https://systemprompt.io> for licensing details.
8
9mod local;
10
11pub use local::{create_external_tenant, create_local_tenant};
12
13pub fn sanitize_database_name(name: &str) -> String {
14    let sanitized: String = name
15        .chars()
16        .map(|c| {
17            if c.is_ascii_alphanumeric() || c == '_' {
18                c
19            } else {
20                '_'
21            }
22        })
23        .collect();
24
25    if sanitized.is_empty() {
26        "systemprompt".to_owned()
27    } else if sanitized.chars().next().is_some_and(|c| c.is_ascii_digit()) {
28        format!("db_{}", sanitized)
29    } else {
30        sanitized
31    }
32}