Command Line Interface
The Command Line Interface (CLI) lets administrators manage a DTaaS installation from the shell. It covers the whole deployment lifecycle: generating and validating the configuration, generating deployment files for each supported scenario, installing and uninstalling a deployment, updating certificates and configuration in place, and adding, removing, pausing and resuming users.
The user guide is the admin CLI page, and the full
command reference is in cli/README.md. This page describes the
internal structure for contributors.
Command Surface
Every command follows the grammar dtaas <noun> <verb>. The four nouns
are listed in workflow order.
Package Structure
The CLI package is organised as follows:
Architecture and Design
The CLI is a Python package that uses the Click framework for command
parsing. Each noun is a Click group in its own cmd_<noun>.py module,
and cmd.py attaches the groups to the root dtaas group. Command
modules parse options, load and validate the configuration, and call
functions in pkg/. Docker operations go through python-on-whales.
dtaas.toml is the single source of truth. Every command reads it
through the Config class in pkg/config.py, and
platform update --config re-applies it to an installed deployment so
that the deployment does not drift from it.
The CLI also keeps two files of its own. dtaas.users.registry.json
(pkg/registry.py) records the additional users added with user add,
and .dtaas.state.json (pkg/state.py) caches what is known about the
provisioned user containers.
GitLab account provisioning in pkg/gitlab/ is built on the
gitlab_common library. src/pkg/build.py vendors it from
lib/gitlab_common/ into the source tree, so run it before running the
tests:
Main Modules
| Module | Purpose |
|---|---|
cmd.py |
Root group; attaches the four noun groups |
cmd_user.py |
User add/delete/status command definitions |
pkg/config*.py |
TOML parsing, validation, in-place updates |
pkg/project.py |
Template copying (config generate, deployment generate) |
pkg/deploy.py |
Install/uninstall orchestration |
pkg/lifecycle.py |
Platform status, stop, start, pause, resume |
pkg/cert_*.py |
Certificate validation and rotation |
pkg/users*.py |
User workspace lifecycle |
pkg/registry.py |
Registry of additional users |
pkg/state.py |
Runtime state of user containers |
pkg/utils.py |
YAML/TOML I/O, template substitution |
Sequence Diagram
The following diagram shows how dtaas user add provisions a user:
sequenceDiagram
actor Admin
participant CLI as Click CLI
participant Config as pkg/config.py
participant Registry as pkg/registry.py
participant Users as pkg/users.py
participant Utils as pkg/utils.py
participant Docker as Docker Compose
participant FS as File System
Admin ->> CLI: dtaas user add alice --email ...
activate CLI
CLI ->> Config: Config()
activate Config
Config ->> Utils: import_toml("dtaas.toml")
Utils -->> Config: config data
deactivate Config
CLI ->> Registry: stage the new user
CLI ->> Users: add_users(config_obj, start_only, passwords)
activate Users
Users ->> Registry: load_registry()
Registry -->> Users: user list
Users ->> Config: get_server_dns() / get_path()
Config -->> Users: server DNS, installation path
Users ->> Config: get_resource_limits() / get_tls()
Config -->> Users: resource limits, TLS setting
Users ->> FS: Copy workspace files for each user
Users ->> Users: generate compose service entries
Users ->> Utils: export_yaml(compose)
Utils ->> FS: Write user compose file
Users ->> Docker: docker compose up -d (new users only)
Docker -->> Users: Containers started
Users -->> CLI: None (success)
deactivate Users
CLI -->> Admin: "Users added successfully"
deactivate CLI
Error Handling Pattern
The CLI handles errors in two ways:
- Most modules under
src/pkg/raise exceptions. config.pyandutils.pyreturn(result, Exception | None)pairs, and callers check the error before using the result.
The command modules turn both kinds of error into
click.ClickException, so the user sees a short message instead of a
traceback. Test commands with Click's CliRunner rather than
subprocess.
Resource Limits Configuration
Administrators can limit the resources each user container may use, so
that one user cannot take over a shared server. The limits are set in
the [common.resources] section of dtaas.toml. The set_limits flag
turns enforcement on and off. When it is false, user containers are
created without limits and the other fields are ignored. The defaults
come from the dtaas.toml template:
| Parameter | Description | Default |
|---|---|---|
cpus |
CPU core allocation | 4 |
mem_limit |
Memory limit | 4G |
pids_limit |
Maximum process count | 4960 |
shm_size |
Shared memory size | 512m |