Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
63cb89b
feat(config): add Proxmox LXC provider configuration
mzyy94 Mar 29, 2026
dffc5f3
feat(provider): add Proxmox LXC provider implementation
mzyy94 Mar 29, 2026
621e9b6
test(provider): add Proxmox LXC provider unit tests
mzyy94 Mar 29, 2026
3315ea4
feat(provider): register Proxmox LXC provider
mzyy94 Mar 29, 2026
337de45
test(sabliercmd): update testdata for ProxmoxLXC config fields
mzyy94 Mar 29, 2026
27ad88f
docs(provider): add Proxmox LXC provider documentation
mzyy94 Mar 29, 2026
89e2469
docs(provider): add Proxmox LXC to sidebar with icon
mzyy94 Mar 30, 2026
6bf7473
feat(provider): support node/vmid format for Proxmox LXC instance names
mzyy94 Mar 30, 2026
ee5aa83
fix(provider): check network interfaces for Proxmox LXC readiness
mzyy94 Mar 30, 2026
626c84a
fix(provider): report unrecoverable state on Proxmox LXC start failure
mzyy94 Mar 30, 2026
f3d739d
refactor(provider): use UPID-based async task tracking for Proxmox LX…
mzyy94 Apr 1, 2026
c3e3d84
test(provider): add integration tests for Proxmox LXC provider
mzyy94 Apr 1, 2026
a9d0b94
test(provider): use external test package for Proxmox LXC tests
mzyy94 Apr 1, 2026
9953bad
docs: add Proxmox LXC to provider lists and documentation
mzyy94 Apr 3, 2026
c9ea7a6
fix(provider): allow Proxmox LXC to resolve containers without sablie…
mzyy94 Apr 7, 2026
ddf4070
chore: got mod tidy
mzyy94 Apr 16, 2026
6e482fc
docs(proxmox-lxc): fix failed-start TTL description to match implemen…
mzyy94 Apr 16, 2026
607c83f
fix(proxmox-lxc): use write lock for pendingTasks to prevent data rac…
mzyy94 Apr 16, 2026
323887a
Merge branch 'main' into proxmox-lxc-provider
mzyy94 Apr 16, 2026
b3a5364
Merge branch 'main' into proxmox-lxc-provider
mzyy94 May 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Whether you don't want to overload your Raspberry Pi, or your QA environment is
- [Docker Swarm](#docker-swarm)
- [Podman](#podman)
- [Kubernetes](#kubernetes)
- [Proxmox LXC](#proxmox-lxc)
- [Usage with Reverse Proxies](#usage-with-reverse-proxies)
- [Apache APISIX](#apache-apisix)
- [Caddy](#caddy)
Expand Down Expand Up @@ -247,8 +248,8 @@ sablier --configFile=path/to/myconfigfile.yml

```yaml
provider:
# Provider to use to manage containers (docker, swarm, kubernetes)
name: docker
# Provider to use to manage containers (docker, swarm, kubernetes, podman, proxmox_lxc)
name: docker
server:
# The server port to use
port: 10000
Expand Down Expand Up @@ -390,6 +391,21 @@ Sablier provides native Kubernetes support for managing deployments, scaling wor

📚 **[Full Documentation](https://sablierapp.dev/#/providers/kubernetes)**

---

### Proxmox LXC

<img src="./docs/assets/img/proxmox.png" alt="Proxmox" width="100" align="right" />

Sablier supports Proxmox VE for managing LXC containers on demand via the Proxmox API.

**Features:**
- Connects to the Proxmox VE API with token authentication
- Starts/Stops LXC containers
- Discovers containers by `sablier` tag

📚 **[Full Documentation](https://sablierapp.dev/#/providers/proxmox_lxc)**

## Usage with Reverse Proxies

Sablier is an API server that manages workload lifecycle. To automatically wake up workloads when users access your services, you can integrate Sablier with reverse proxy plugins.
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This allows you to start your containers on demand and shut them down automatica
Throughout this documentation, we use these terms to remain provider-agnostic:

- **Session**: A session is a set of **instances**
- **Instance**: An instance is either a Docker container, Docker Swarm service, Kubernetes deployment, or Kubernetes StatefulSet
- **Instance**: An instance is either a Docker container, Docker Swarm service, Kubernetes deployment, Kubernetes StatefulSet, or Proxmox LXC container

## Credits

Expand Down
1 change: 1 addition & 0 deletions docs/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [<img src="assets/img/docker_swarm.png" height=24px width=24px />Docker Swarm](/providers/docker_swarm)
- [<img src="assets/img/kubernetes.png" height=24px width=24px />Kubernetes](/providers/kubernetes)
- [<img src="assets/img/podman.png" height=24px width=24px />Podman](/providers/podman)
- [<img src="assets/img/proxmox.png" height=24px width=24px />Proxmox LXC](/providers/proxmox_lxc)
- **Reverse Proxy Plugins**
- [Overview](/plugins/overview)
- [<img src="assets/img/apacheapisix.png" height=24px width=24px />Apache APISIX](/plugins/apacheapisix)
Expand Down
Binary file added docs/assets/img/proxmox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ sablier --configFile=path/to/myconfigfile.yml

```yaml
provider:
# Provider to use to manage containers (docker, swarm, kubernetes)
# Provider to use to manage containers (docker, swarm, kubernetes, podman, proxmox_lxc)
name: docker
docker:
# Strategy to use for stopping Docker containers: stop or pause (default: stop)
Expand Down Expand Up @@ -117,7 +117,7 @@ sablier start --strategy.dynamic.custom-themes-path /my/path
```
-h, --help help for start
--provider.docker.strategy string Strategy to use to stop docker containers (stop or pause) (default "stop")
--provider.name string Provider to use to manage containers [docker swarm kubernetes] (default "docker")
--provider.name string Provider to use to manage containers [docker swarm kubernetes podman proxmox_lxc] (default "docker")
--server.base-path string The base path for the API (default "/")
--server.port int The server port to use (default 10000)
--sessions.default-duration duration The default session duration (default 5m0s)
Expand Down
1 change: 1 addition & 0 deletions docs/providers/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ A Provider typically has the following capabilities:
| [Docker Swarm](docker_swarm) | `docker_swarm` or `swarm` | Scale down to zero and up **services** on demand |
| [Kubernetes](kubernetes) | `kubernetes` | Scale down and up **deployments** and **statefulsets** on demand |
| [Podman](podman) | `podman` | Stop and start **containers** on demand |
| [Proxmox LXC](proxmox_lxc) | `proxmox_lxc` | Stop and start **LXC containers** on demand via Proxmox VE API |

*Your Provider is not on the list? [Open an issue to request the missing provider here!](https://github.com/sablierapp/sablier/issues/new?assignees=&labels=enhancement%2C+provider&projects=&template=instance-provider-request.md&title=Add+%60%5BPROVIDER%5D%60+provider)*

Expand Down
123 changes: 123 additions & 0 deletions docs/providers/proxmox_lxc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# Proxmox LXC

The Proxmox LXC provider communicates with the Proxmox VE API to start and stop LXC containers on demand.

## Use the Proxmox LXC provider

In order to use the Proxmox LXC provider you can configure the [provider.name](../configuration) property.

<!-- tabs:start -->

#### **File (YAML)**

```yaml
provider:
name: proxmox_lxc
proxmox-lxc:
url: "https://proxmox.local:8006/api2/json"
token-id: "root@pam!sablier"
token-secret: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
tls-insecure: false
```

#### **CLI**

```bash
sablier start \
--provider.name=proxmox_lxc \
--provider.proxmox-lxc.url=https://proxmox.local:8006/api2/json \
--provider.proxmox-lxc.token-id=root@pam!sablier \
--provider.proxmox-lxc.token-secret=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
```

#### **Environment Variable**

```bash
SABLIER_PROVIDER_NAME=proxmox_lxc
SABLIER_PROVIDER_PROXMOX_LXC_URL=https://proxmox.local:8006/api2/json
SABLIER_PROVIDER_PROXMOX_LXC_TOKEN_ID=root@pam!sablier
SABLIER_PROVIDER_PROXMOX_LXC_TOKEN_SECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
SABLIER_PROVIDER_PROXMOX_LXC_TLS_INSECURE=false
```

<!-- tabs:end -->

## Configuration

| Property | CLI Flag | Environment Variable | Default | Description |
|---|---|---|---|---|
| `url` | `--provider.proxmox-lxc.url` | `SABLIER_PROVIDER_PROXMOX_LXC_URL` | *(required)* | Proxmox VE API URL |
| `token-id` | `--provider.proxmox-lxc.token-id` | `SABLIER_PROVIDER_PROXMOX_LXC_TOKEN_ID` | *(required)* | API token ID (e.g. `root@pam!sablier`) |
| `token-secret` | `--provider.proxmox-lxc.token-secret` | `SABLIER_PROVIDER_PROXMOX_LXC_TOKEN_SECRET` | *(required)* | API token secret |
| `tls-insecure` | `--provider.proxmox-lxc.tls-insecure` | `SABLIER_PROVIDER_PROXMOX_LXC_TLS_INSECURE` | `false` | Skip TLS certificate verification (for self-signed certs) |

## Create a Proxmox API Token

1. In the Proxmox web UI, go to **Datacenter > Permissions > API Tokens**
2. Click **Add** and create a token for a user (e.g. `root@pam`)
3. Uncheck **Privilege Separation** so the token inherits the user's permissions
4. Note the **Token ID** (e.g. `root@pam!sablier`) and **Secret**

The token needs the following permissions on the LXC containers:
- `VM.PowerMgmt` — to start and stop containers
- `VM.Audit` — to read container status and configuration

## Register containers

For Sablier to work, it needs to know which LXC containers to start and stop.

You have to register your containers by opting-in with **Proxmox tags**.

```yaml
arch: amd64
cores: 2
hostname: whoami
memory: 4096
net0: name=eth0,bridge=vmbr0,hwaddr=BC:24:11:81:7C:C4,ip=dhcp,type=veth
ostype: debian
rootfs: local-lvm:vm-100-disk-0,size=8G
swap: 512
tags: sablier;sablier-group-mygroup
unprivileged: 1
```

### Add tags via the CLI

```bash
pct set 100 -tags "sablier;sablier-group-mygroup"
```

### Add tags via the Web UI

In the Proxmox web UI, select a container and click the **pencil icon** next to the tags in the toolbar (next to the container name) to edit tags.

### Tags reference

| Tag | Description |
|---|---|
| `sablier` | **Required.** Marks the container as managed by Sablier. |
| `sablier-group-<name>` | Optional. Assigns the container to a group. Defaults to `default` if not specified. |

## Instance naming

Sablier uses the LXC container **hostname** as the instance name. You can also reference containers by their **VMID** (e.g. `100`) or by **node/VMID** format (e.g. `pve1/100`).

!> Hostnames must be unique among Sablier-managed containers. If duplicate hostnames are detected, Sablier will return an error.

## Multi-node support

The Proxmox LXC provider automatically discovers all nodes in the cluster and scans for tagged containers across all of them. No additional configuration is required for multi-node setups.

## How does Sablier know when a container is ready?

Sablier checks the LXC container status reported by Proxmox. Additionally, for `running` containers, Sablier verifies that at least one non-loopback network interface has an IP address assigned before reporting the container as ready.

| Proxmox Status | Sablier Status |
|---|---|
| `running` (with IP) | Ready |
| `running` (no IP yet) | Not Ready |
| `stopped` | Not Ready |
| `stopped` (after failed start) | Unrecoverable |
| Other | Unrecoverable |

?> When a start task fails (e.g. `startup for container '100' failed`), Sablier marks the instance as **Unrecoverable** instead of retrying indefinitely. The failure is cleared automatically when the session expires, allowing a new start attempt on the next request.
Comment thread
mzyy94 marked this conversation as resolved.
Outdated
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ require (
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/buger/goterm v1.0.4 // indirect
github.com/bytedance/sonic v1.14.0 // indirect
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
Expand All @@ -58,7 +59,9 @@ require (
github.com/cyphar/filepath-securejoin v0.5.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/disiqueira/gotree/v3 v3.0.2 // indirect
github.com/diskfs/go-diskfs v1.7.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/djherbis/times v1.6.0 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.4 // indirect
github.com/docker/go-connections v0.6.0 // indirect
Expand Down Expand Up @@ -91,6 +94,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/mux v1.8.1 // indirect
github.com/gorilla/schema v1.4.1 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -105,6 +109,8 @@ require (
github.com/leodido/go-urn v1.4.0 // indirect
github.com/letsencrypt/boulder v0.0.0-20240620165639-de9c06129bec // indirect
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
github.com/luthermonson/go-proxmox v0.4.0 // indirect
Comment thread
mzyy94 marked this conversation as resolved.
Outdated
github.com/magefile/mage v1.14.0 // indirect
github.com/magiconair/properties v1.8.10 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
Expand Down
14 changes: 14 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
github.com/buger/goterm v1.0.4 h1:Z9YvGmOih81P0FbVtEYTFF6YsSgxSUKEhf/f9bTMXbY=
github.com/buger/goterm v1.0.4/go.mod h1:HiFWV3xnkolgrBV3mY8m0X0Pumt4zg4QhbdOzQtB8tE=
github.com/bytedance/sonic v1.14.0 h1:/OfKt8HFw0kh2rj8N0F6C/qPGRESq0BbaNZgcNXXzQQ=
github.com/bytedance/sonic v1.14.0/go.mod h1:WoEbx8WTcFJfzCe0hbmyTGrfjt8PzNEBdxlNUO24NhA=
github.com/bytedance/sonic/loader v0.3.0 h1:dskwH8edlzNMctoruo8FPTJDF3vLtDT0sXZwvZJyqeA=
Expand Down Expand Up @@ -75,8 +77,12 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/disiqueira/gotree/v3 v3.0.2 h1:ik5iuLQQoufZBNPY518dXhiO5056hyNBIK9lWhkNRq8=
github.com/disiqueira/gotree/v3 v3.0.2/go.mod h1:ZuyjE4+mUQZlbpkI24AmruZKhg3VHEgPLDY8Qk+uUu8=
github.com/diskfs/go-diskfs v1.7.0 h1:vonWmt5CMowXwUc79jWyGrf2DIMeoOjkLlMnQYGVOs8=
github.com/diskfs/go-diskfs v1.7.0/go.mod h1:LhQyXqOugWFRahYUSw47NyZJPezFzB9UELwhpszLP/k=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
github.com/docker/cli v28.5.1+incompatible h1:ESutzBALAD6qyCLqbQSEf1a/U8Ybms5agw59yGVc+yY=
github.com/docker/cli v28.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
Expand Down Expand Up @@ -183,6 +189,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E=
github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM=
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5THxAzdVpqr6/geYxZytqFMBCOtn/ujyeo=
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674/go.mod h1:r4w70xmWCQKmi1ONH4KIaBptdivuRPyosB9RmPlGEwA=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -226,6 +234,10 @@ github.com/lmittmann/tint v1.1.3 h1:Hv4EaHWXQr+GTFnOU4VKf8UvAtZgn0VuKT+G0wFlO3I=
github.com/lmittmann/tint v1.1.3/go.mod h1:HIS3gSy7qNwGCj+5oRjAutErFBl4BzdQP6cJZ0NfMwE=
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMDtTVdcGu0B1GmmC7QJKiCCjyTAWQy0=
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
github.com/luthermonson/go-proxmox v0.4.0 h1:LKXpG9d64zTaQF79wV0kfOnnSwIcdG39m7sc4ga+XZs=
github.com/luthermonson/go-proxmox v0.4.0/go.mod h1:U6dAkJ+iiwaeb1g/LMWpWuWN4nmvWeXhmoMuYJMumS4=
github.com/magefile/mage v1.14.0 h1:6QDX3g6z1YvJ4olPhT1wksUcSa/V0a1B+pJb73fBjyo=
github.com/magefile/mage v1.14.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE=
github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
Expand Down Expand Up @@ -529,10 +541,12 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
37 changes: 35 additions & 2 deletions pkg/config/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
// Provider holds the provider configurations
type Provider struct {
// The provider name to use
// It can be either docker, swarm or kubernetes. Defaults to "docker"
// It can be either docker, swarm, kubernetes, podman or proxmox_lxc. Defaults to "docker"
Name string `mapstructure:"NAME" yaml:"name,omitempty" default:"docker"`
AutoStopOnStartup bool `yaml:"auto-stop-on-startup,omitempty" default:"true"`
Kubernetes Kubernetes
Podman Podman
Docker Docker
ProxmoxLXC ProxmoxLXC `mapstructure:"PROXMOX_LXC" yaml:"proxmox-lxc,omitempty"`
}

type Kubernetes struct {
Expand All @@ -39,7 +40,19 @@
Strategy string `mapstructure:"STRATEGY" yaml:"strategy,omitempty" default:"stop"`
}

var providers = []string{"docker", "docker_swarm", "swarm", "kubernetes", "podman"}
// ProxmoxLXC holds the Proxmox VE LXC provider configuration
type ProxmoxLXC struct {
// URL is the Proxmox VE API endpoint (e.g. "https://proxmox:8006/api2/json")
URL string `mapstructure:"URL" yaml:"url,omitempty"`
// TokenID is the API token identifier (e.g. "root@pam!sablier")
TokenID string `mapstructure:"TOKEN_ID" yaml:"token-id,omitempty"`
// TokenSecret is the API token secret UUID
TokenSecret string `mapstructure:"TOKEN_SECRET" yaml:"token-secret,omitempty"`
// TLSInsecure skips TLS certificate verification (useful for self-signed certificates)
TLSInsecure bool `mapstructure:"TLS_INSECURE" yaml:"tls-insecure,omitempty" default:"false"`
}

var providers = []string{"docker", "docker_swarm", "swarm", "kubernetes", "podman", "proxmox_lxc"}
var dockerStrategies = []string{"stop", "pause"}

func NewProviderConfig() Provider {
Expand All @@ -57,10 +70,11 @@
Docker: Docker{
Strategy: "stop",
},
ProxmoxLXC: ProxmoxLXC{},
}
}

func (provider Provider) IsValid() error {

Check failure on line 77 in pkg/config/provider.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=sablierapp_sablier&issues=AZ2WdRX5k1BJ_1KSNa-p&open=AZ2WdRX5k1BJ_1KSNa-p&pullRequest=868
for _, p := range providers {
if p == provider.Name {
// Validate Docker-specific settings when using Docker provider
Expand All @@ -69,6 +83,12 @@
return err
}
}
// Validate Proxmox LXC-specific settings
if p == "proxmox_lxc" {
if err := provider.ProxmoxLXC.IsValid(); err != nil {
return err
}
}
return nil
}
}
Expand All @@ -84,6 +104,19 @@
return fmt.Errorf("unrecognized docker strategy %s. strategies available: %v", docker.Strategy, dockerStrategies)
}

func (p ProxmoxLXC) IsValid() error {
if p.URL == "" {
return fmt.Errorf("proxmox_lxc provider requires a URL")
}
if p.TokenID == "" {
return fmt.Errorf("proxmox_lxc provider requires a token ID")
}
if p.TokenSecret == "" {
return fmt.Errorf("proxmox_lxc provider requires a token secret")
}
return nil
}

func GetProviders() []string {
return providers
}
Loading
Loading