feat: add environment variable support for deploy command flags
Allows setting --nats-url, --nkey-file, --branch, --action, and --timeout via HOMELAB_DEPLOY_* environment variables. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
14
README.md
14
README.md
@@ -102,13 +102,13 @@ homelab-deploy deploy deploy.prod.role.dns \
|
|||||||
|
|
||||||
#### Deploy Flags
|
#### Deploy Flags
|
||||||
|
|
||||||
| Flag | Required | Description |
|
| Flag | Required | Env Var | Description |
|
||||||
|------|----------|-------------|
|
|------|----------|---------|-------------|
|
||||||
| `--nats-url` | Yes | NATS server URL |
|
| `--nats-url` | Yes | `HOMELAB_DEPLOY_NATS_URL` | NATS server URL |
|
||||||
| `--nkey-file` | Yes | Path to NKey seed file |
|
| `--nkey-file` | Yes | `HOMELAB_DEPLOY_NKEY_FILE` | Path to NKey seed file |
|
||||||
| `--branch` | No | Git branch or commit (default: `master`) |
|
| `--branch` | No | `HOMELAB_DEPLOY_BRANCH` | Git branch or commit (default: `master`) |
|
||||||
| `--action` | No | nixos-rebuild action (default: `switch`) |
|
| `--action` | No | `HOMELAB_DEPLOY_ACTION` | nixos-rebuild action (default: `switch`) |
|
||||||
| `--timeout` | No | Response timeout in seconds (default: 900) |
|
| `--timeout` | No | `HOMELAB_DEPLOY_TIMEOUT` | Response timeout in seconds (default: 900) |
|
||||||
|
|
||||||
#### Subject Aliases
|
#### Subject Aliases
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import (
|
|||||||
"github.com/urfave/cli/v3"
|
"github.com/urfave/cli/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const version = "0.1.1"
|
const version = "0.1.2"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := &cli.Command{
|
app := &cli.Command{
|
||||||
@@ -189,26 +189,31 @@ func deployCommand() *cli.Command {
|
|||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "nats-url",
|
Name: "nats-url",
|
||||||
Usage: "NATS server URL",
|
Usage: "NATS server URL",
|
||||||
|
Sources: cli.EnvVars("HOMELAB_DEPLOY_NATS_URL"),
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "nkey-file",
|
Name: "nkey-file",
|
||||||
Usage: "Path to NKey seed file for NATS authentication",
|
Usage: "Path to NKey seed file for NATS authentication",
|
||||||
|
Sources: cli.EnvVars("HOMELAB_DEPLOY_NKEY_FILE"),
|
||||||
Required: true,
|
Required: true,
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "branch",
|
Name: "branch",
|
||||||
Usage: "Git branch or commit to deploy",
|
Usage: "Git branch or commit to deploy",
|
||||||
|
Sources: cli.EnvVars("HOMELAB_DEPLOY_BRANCH"),
|
||||||
Value: "master",
|
Value: "master",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "action",
|
Name: "action",
|
||||||
Usage: "nixos-rebuild action (switch, boot, test, dry-activate)",
|
Usage: "nixos-rebuild action (switch, boot, test, dry-activate)",
|
||||||
|
Sources: cli.EnvVars("HOMELAB_DEPLOY_ACTION"),
|
||||||
Value: "switch",
|
Value: "switch",
|
||||||
},
|
},
|
||||||
&cli.IntFlag{
|
&cli.IntFlag{
|
||||||
Name: "timeout",
|
Name: "timeout",
|
||||||
Usage: "Timeout in seconds for collecting responses",
|
Usage: "Timeout in seconds for collecting responses",
|
||||||
|
Sources: cli.EnvVars("HOMELAB_DEPLOY_TIMEOUT"),
|
||||||
Value: 900,
|
Value: 900,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user