Skip to content

Commit a6f401b

Browse files
authored
Merge pull request #12 from onetimesecret/fix/version-single-source
Make config optional, add migration commands, single-source version
2 parents 57c4870 + 8c53354 commit a6f401b

38 files changed

+2333
-206
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ repos:
9393

9494
# Ruff - fast linting and formatting
9595
- repo: https://github.com/astral-sh/ruff-pre-commit
96-
rev: v0.8.3
96+
rev: v0.9.2
9797
hooks:
9898
- id: ruff
9999
args: [--fix]

CLAUDE.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ When running git commands with long output, use `git --no-pager diff` etc.
4848
## Architecture
4949

5050
This is a dual-purpose service orchestration tool:
51+
5152
1. **Container management**: OneTimeSecret containers via Podman Quadlets (systemd integration)
5253
2. **Service management**: Native systemd services for dependencies (Valkey, Redis)
5354

@@ -63,17 +64,20 @@ This is a dual-purpose service orchestration tool:
6364
### Commands (`src/ots_containers/commands/`)
6465

6566
#### Container Commands
67+
6668
- **instance.py** - Main operations: `deploy`, `redeploy`, `undeploy`, `start`, `stop`, `restart`, `status`, `logs`, `list`
6769
- **assets.py** - `sync` command for static asset updates
6870
- **image.py** - Container image management
6971
- **proxy.py** - Caddy reverse proxy configuration
7072

7173
#### Service Commands (`service/`)
74+
7275
- **app.py** - Service lifecycle: `init`, `start`, `stop`, `restart`, `status`, `logs`, `enable`, `disable`, `list_instances`
7376
- **packages.py** - Service package definitions: `VALKEY`, `REDIS` with config paths, secrets handling, systemd templates
74-
- **_helpers.py** - Shared utilities: config file management, secrets creation, systemctl wrappers
77+
- **\_helpers.py** - Shared utilities: config file management, secrets creation, systemctl wrappers
7578

7679
#### Cloud-Init Commands (`cloudinit/`)
80+
7781
- **app.py** - Cloud-init generation: `generate`, `validate`
7882
- **templates.py** - DEB822-style apt sources templates for Debian 13 (Trixie), PostgreSQL, and Valkey repositories
7983

@@ -87,6 +91,6 @@ This is a dual-purpose service orchestration tool:
8791
- **Service secrets separation**: Sensitive data in separate files with restricted permissions (mode 0640, owned by service user)
8892
- **Package-provided templates**: Uses existing systemd templates (`valkey-server@.service`) rather than creating custom units
8993
- ## Verification
90-
Don't invent technical rationales. When working with runtime behavior, get or
91-
ask for actual output (podman ps, systemctl status, etc.) before changing code.
92-
Documentation and memories are not substitutes for verified information.
94+
Don't invent technical rationales. When working with runtime behavior, get or
95+
ask for actual output (podman ps, systemctl status, etc.) before changing code.
96+
Documentation and memories are not substitutes for verified information.

NETWORKING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ which port the application listens on.
1717
The quadlet template passes the instance number as the PORT:
1818

1919
**onetime@.container**:
20+
2021
```ini
2122
[Container]
2223
Image=ghcr.io/onetimesecret/onetimesecret:current

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Service orchestration CLI for [OneTimeSecret](https://github.com/onetimesecret/onetimesecret) infrastructure.
44

55
**Dual-purpose management tool:**
6+
67
- **Container orchestration**: Containerized OTS deployments via Podman Quadlets (systemd integration)
78
- **Service management**: Native systemd services for dependencies (Valkey, Redis)
89

@@ -39,10 +40,10 @@ ots-containers --version
3940

4041
Three container types with explicit systemd unit naming:
4142

42-
| Type | Unit Name | Identifier | Use |
43-
|------|-----------|------------|-----|
44-
| `--web` | `onetime-web@{port}` | Port number | HTTP servers |
45-
| `--worker` | `onetime-worker@{id}` | Name/number | Background jobs |
43+
| Type | Unit Name | Identifier | Use |
44+
| ------------- | ------------------------ | ----------- | --------------- |
45+
| `--web` | `onetime-web@{port}` | Port number | HTTP servers |
46+
| `--worker` | `onetime-worker@{id}` | Name/number | Background jobs |
4647
| `--scheduler` | `onetime-scheduler@{id}` | Name/number | Scheduled tasks |
4748

4849
### Managing OTS Containers

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ build-backend = "hatchling.build"
1313

1414
[project]
1515
name = "ots-containers"
16-
version = "0.3.0"
16+
version = "0.3.1"
1717
description = "Service orchestration for OneTimeSecret: Podman Quadlets and systemd service management"
1818
readme = "README.md"
1919
requires-python = ">=3.11"

src/ots_containers/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# src/ots_containers/__init__.py
22

3-
__version__ = "0.2.2"
3+
from importlib.metadata import PackageNotFoundError, version
4+
5+
try:
6+
__version__ = version("ots-containers")
7+
except PackageNotFoundError:
8+
__version__ = "0.0.0+dev"

src/ots_containers/commands/README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ ots-containers <topic> <command> [identifiers] [flags]
1212

1313
Three container types, each with explicit naming:
1414

15-
| Type | Systemd Unit | Identifier | Use |
16-
|------|--------------|------------|-----|
17-
| `web` | `onetime-web@{port}` | Port number | HTTP servers |
18-
| `worker` | `onetime-worker@{id}` | Name or number | Background jobs |
15+
| Type | Systemd Unit | Identifier | Use |
16+
| ----------- | ------------------------ | -------------- | --------------- |
17+
| `web` | `onetime-web@{port}` | Port number | HTTP servers |
18+
| `worker` | `onetime-worker@{id}` | Name or number | Background jobs |
1919
| `scheduler` | `onetime-scheduler@{id}` | Name or number | Scheduled tasks |
2020

2121
## Command Syntax
@@ -39,14 +39,14 @@ ots instances logs --scheduler -f # only scheduler logs
3939

4040
Each topic is a separate module with its own `cyclopts.App`:
4141

42-
| Topic | Purpose |
43-
|-------|---------|
44-
| `instance` | Container lifecycle and runtime control |
45-
| `service` | Native systemd services (Valkey, Redis) |
46-
| `image` | Container image management |
47-
| `assets` | Static asset management |
48-
| `cloudinit` | Cloud-init configuration generation |
49-
| `env` | Environment file management |
42+
| Topic | Purpose |
43+
| ----------- | --------------------------------------- |
44+
| `instance` | Container lifecycle and runtime control |
45+
| `service` | Native systemd services (Valkey, Redis) |
46+
| `image` | Container image management |
47+
| `assets` | Static asset management |
48+
| `cloudinit` | Cloud-init configuration generation |
49+
| `env` | Environment file management |
5050

5151
To add a new topic, create a module and register it in `cli.py`.
5252

@@ -55,24 +55,28 @@ To add a new topic, create a module and register it in `cli.py`.
5555
Commands are categorized by their impact:
5656

5757
### High-level (affects config + state)
58+
5859
Commands that modify quadlet templates, database records, or both:
60+
5961
- `deploy`, `redeploy`, `undeploy`
6062

6163
These commands should document their config impact in the docstring.
6264

6365
### Low-level (runtime control only)
66+
6467
Commands that only interact with systemd, no config changes:
68+
6569
- `start`, `stop`, `restart`, `status`, `logs`, `enable`, `disable`, `exec`
6670

6771
These commands should explicitly state they do NOT refresh config.
6872

6973
## Naming Conventions
7074

71-
| Pattern | Example | Use for |
72-
|---------|---------|---------|
73-
| Verb | `deploy`, `sync` | Actions |
74-
| `--flag` | `--force`, `--yes` | Boolean options |
75-
| `--option VALUE` | `--delay 5`, `--lines 50` | Value options |
75+
| Pattern | Example | Use for |
76+
| ------------------ | ---------------------------------- | ----------------------- |
77+
| Verb | `deploy`, `sync` | Actions |
78+
| `--flag` | `--force`, `--yes` | Boolean options |
79+
| `--option VALUE` | `--delay 5`, `--lines 50` | Value options |
7680
| `--type` shortcuts | `--web`, `--worker`, `--scheduler` | Instance type selection |
7781

7882
## Default Commands

src/ots_containers/commands/assets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# src/ots_containers/commands/assets.py
2+
23
"""Asset management commands for OTS containers."""
34

45
from typing import Annotated
@@ -25,5 +26,4 @@ def sync(
2526
on initial setup.
2627
"""
2728
cfg = Config()
28-
cfg.validate()
2929
assets_module.update(cfg, create_volume=create_volume)

src/ots_containers/commands/cloudinit/app.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# src/ots_containers/commands/cloudinit/app.py
2+
23
"""Cloud-init configuration generation commands.
34
45
Generates cloud-init YAML with Debian 13 (Trixie) DEB822-style apt sources.
@@ -74,7 +75,10 @@ def generate(
7475
"Warning: --include-postgresql specified but no --postgresql-key provided",
7576
file=sys.stderr,
7677
)
77-
print("PostgreSQL repository will use inline key placeholder", file=sys.stderr)
78+
print(
79+
"PostgreSQL repository will use inline key placeholder",
80+
file=sys.stderr,
81+
)
7882

7983
if include_valkey and valkey_key:
8084
valkey_gpg = Path(valkey_key).read_text()

src/ots_containers/commands/cloudinit/templates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# src/ots_containers/commands/cloudinit/templates.py
2+
23
"""Cloud-init configuration templates with Debian 13 DEB822 apt sources."""
34

45

0 commit comments

Comments
 (0)