Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Each command directory has its own `CLAUDE.md` (domain knowledge) and `README.md
| `cmd/settings/` | CLAUDE.md, README.md | CLI settings management |
| `cmd/objectstorage/` | CLAUDE.md, README.md | S3-style object storage: configure, mb/rb, cp/mv/sync/ls/rm, uploads, presign |
| `cmd/network/` | CLAUDE.md, README.md | Private networks (beta): list, create, delete; subnet list, create, delete |
| `cmd/serverless/` | CLAUDE.md, README.md | Serverless containers (beta: create, list, describe, scale, replicas, pause/resume/restart, purge-queue, delete) and batch jobs (hidden, gated by `VERDA_BATCHJOB_ENABLED`) |
| `cmd/serverless/` | CLAUDE.md, README.md | Serverless containers (`verda container`: create, update, list, describe, scale, replicas, pause/resume/restart, purge-queue, delete, env, secret, file-secret, registry-creds) and batch jobs (`verda batchjob`: create, update, list, describe, delete, pause/resume, purge-queue) |
| `cmd/doctor/` | — | Environment diagnostics |
| `cmd/availability/` | — | Instance availability by location |
| `cmd/cost/` | — | Balance, running costs, estimates |
Expand Down
21 changes: 5 additions & 16 deletions internal/verda-cli/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package cmd
import (
"errors"
"fmt"
"os"
"runtime/debug"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -160,14 +159,13 @@ func NewRootCommand(ioStreams cmdutil.IOStreams) (*cobra.Command, *clioptions.Op
},
},
}
serverlessCmds := []*cobra.Command{serverless.NewCmdContainer(f, ioStreams)}
if batchjobEnabled() {
serverlessCmds = append(serverlessCmds, serverless.NewCmdBatchjob(f, ioStreams))
}
groups = append(groups,
cmdutil.CommandGroup{
Message: "Serverless Commands:",
Commands: serverlessCmds,
Message: "Serverless Commands:",
Commands: []*cobra.Command{
serverless.NewCmdContainer(f, ioStreams),
serverless.NewCmdBatchjob(f, ioStreams),
},
},
cmdutil.CommandGroup{
Message: "Resource Commands:",
Expand Down Expand Up @@ -205,15 +203,6 @@ func NewRootCommand(ioStreams cmdutil.IOStreams) (*cobra.Command, *clioptions.Op
return cmd, opts
}

// batchjobEnabled gates the pre-release batchjob subtree behind
// VERDA_BATCHJOB_ENABLED=1/true. Without it `verda batchjob` returns "unknown
// command". The parent command also sets Hidden so it stays out of
// `verda --help` even when a tester flips the env var on.
func batchjobEnabled() bool {
v := os.Getenv("VERDA_BATCHJOB_ENABLED")
return v == "1" || v == "true"
}

// skipCredentialResolution returns true for commands that should work
// without valid credentials (diagnostics, profile switching, etc.).
func skipCredentialResolution(cmd *cobra.Command) bool {
Expand Down
37 changes: 12 additions & 25 deletions internal/verda-cli/cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,31 +69,18 @@ func TestShouldCheckVersion(t *testing.T) {
}
}

// container is always registered (beta); batchjob only with VERDA_BATCHJOB_ENABLED.
// Both serverless trees are GA: registered unconditionally and visible in `verda --help`.
func TestServerlessCommandRegistration(t *testing.T) {
for _, tc := range []struct {
env string
batchjob bool
}{
{"", false},
{"1", true},
{"true", true},
{"0", false},
} {
t.Run("VERDA_BATCHJOB_ENABLED="+tc.env, func(t *testing.T) {
t.Setenv("VERDA_HOME", t.TempDir())
t.Setenv("VERDA_BATCHJOB_ENABLED", tc.env)
root, _ := NewRootCommand(cmdutil.IOStreams{In: &bytes.Buffer{}, Out: &bytes.Buffer{}, ErrOut: &bytes.Buffer{}})
found := map[string]*cobra.Command{}
for _, c := range root.Commands() {
found[c.Name()] = c
}
if c := found["container"]; c == nil || c.Hidden {
t.Errorf("container: registered=%v, want registered and not hidden", c != nil)
}
if _, ok := found["batchjob"]; ok != tc.batchjob {
t.Errorf("batchjob registered = %v, want %v", ok, tc.batchjob)
}
})
t.Setenv("VERDA_HOME", t.TempDir())
root, _ := NewRootCommand(cmdutil.IOStreams{In: &bytes.Buffer{}, Out: &bytes.Buffer{}, ErrOut: &bytes.Buffer{}})
found := map[string]*cobra.Command{}
for _, c := range root.Commands() {
found[c.Name()] = c
}
for _, name := range []string{"container", "batchjob"} {
c := found[name]
if c == nil || c.Hidden {
t.Errorf("%s: registered=%v, want registered and not hidden", name, c != nil)
}
}
}
2 changes: 1 addition & 1 deletion internal/verda-cli/cmd/serverless/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This rule applies equally to Claude, Codex, Cursor, or a human editing the packa
- There is **no** `verda serverless` parent command — the two trees were promoted to root for shorter invocations. They still share this Go package because they share wizard step factories, validators, and the API cache.
- Verbs (both trees): `create`, `update`, `list` (alias `ls`), `describe` (aliases `get`, `show`), `delete` (aliases `rm`, `del`), `pause`, `resume`, `purge-queue`. Container also has `restart`, `scale` and `replicas`.
- Files:
- `container.go`, `batchjob.go` — Top-level command builders. `NewCmdContainer` and `NewCmdBatchjob` are exported and called directly from `cmd/cmd.go`. **`container` is beta:** always registered, `cmdutil.TagAnnotation: "beta"`. **`batchjob` is two-layer gated:** registered only when `VERDA_BATCHJOB_ENABLED=1` (`batchjobEnabled()` in `cmd/cmd.go`), and `Hidden: true`. Drop both gates when batchjob ships. `gate_test.go` and `cmd/cmd_test.go` guard this.
- `container.go`, `batchjob.go` — Top-level command builders. `NewCmdContainer` and `NewCmdBatchjob` are exported and called directly from `cmd/cmd.go`. Both are GA: registered unconditionally, visible, no `cmdutil.TagAnnotation`. `visibility_test.go` and `cmd/cmd_test.go` guard this (the former `VERDA_BATCHJOB_ENABLED` gate and `(beta)` tag are gone).
- `container_create.go` — `containerCreateOptions`, flags, `request()`, validate(), wizard entry point.
- `container_update.go` — `containerUpdateOptions`, fetch-merge-PATCH flow. Fetches current deployment + scaling (separate call), overlays only Changed() flags, sends single PATCH. Splits summary rendering and scaling merge into helpers for gocyclo compliance.
- `container_list.go` — `GetDeployments` + tabwriter + structured output.
Expand Down
2 changes: 0 additions & 2 deletions internal/verda-cli/cmd/serverless/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ verda container # → /container-deployments (continuous; supports spot)
verda batchjob # → /job-deployments (one-shot; deadline-based; no spot)
```

`verda container` is a beta: it shows in `verda --help` as `(beta)`. `verda batchjob` is pre-release: it is registered only with `VERDA_BATCHJOB_ENABLED=1` and stays hidden from `verda --help`.

Both command trees live in the `serverless` Go package (they share wizard step factories, validators, and the API cache), but are registered as top-level commands so users type `verda container ...` rather than `verda serverless container ...`.

## Container deployments
Expand Down
4 changes: 0 additions & 4 deletions internal/verda-cli/cmd/serverless/batchjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ func NewCmdBatchjob(f cmdutil.Factory, ioStreams cmdutil.IOStreams) *cobra.Comma
cmd := &cobra.Command{
Use: "batchjob",
Short: "Manage serverless batch-job deployments (one-shot runs)",
// Pre-release: cmd/cmd.go (batchjobEnabled) registers it only with
// VERDA_BATCHJOB_ENABLED; Hidden keeps it out of `verda --help` even
// then. Drop both when batchjob ships.
Hidden: true,
Long: cmdutil.LongDesc(`
Create and manage one-shot batch-job deployments. Jobs accept queued
requests, run each to completion within a deadline, and scale the
Expand Down
5 changes: 2 additions & 3 deletions internal/verda-cli/cmd/serverless/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ import (
// NewCmdContainer creates the top-level `verda container` command tree.
func NewCmdContainer(f cmdutil.Factory, ioStreams cmdutil.IOStreams) *cobra.Command {
cmd := &cobra.Command{
Use: "container",
Short: "Manage serverless container deployments (always-on endpoints)",
Annotations: map[string]string{cmdutil.TagAnnotation: "beta"},
Use: "container",
Short: "Manage serverless container deployments (always-on endpoints)",
Long: cmdutil.LongDesc(`
Create and manage always-on serverless container deployments. Each
deployment exposes an HTTPS endpoint that auto-scales based on queue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,26 @@ import (
"bytes"
"testing"

"github.com/spf13/cobra"

cmdutil "github.com/verda-cloud/verda-cli/internal/verda-cli/cmd/util"
)

// container is a visible beta; batchjob stays Hidden (and env-gated in
// cmd/cmd.go) until it ships.
func TestServerlessGate(t *testing.T) {
// Both trees are GA: visible, untagged. A reintroduced Hidden or "beta" tag
// would silently drop them from `verda --help` and the generated docs.
func TestServerlessCommandsVisible(t *testing.T) {
f := cmdutil.NewTestFactory(nil)
streams := cmdutil.IOStreams{Out: &bytes.Buffer{}, ErrOut: &bytes.Buffer{}}

c := NewCmdContainer(f, streams)
if c.Hidden {
t.Errorf("container command should be visible")
}
if got := c.Annotations[cmdutil.TagAnnotation]; got != "beta" {
t.Errorf("container tag = %q, want beta", got)
}
if c := NewCmdBatchjob(f, streams); !c.Hidden {
t.Errorf("batchjob command should stay Hidden")
for name, c := range map[string]*cobra.Command{
"container": NewCmdContainer(f, streams),
"batchjob": NewCmdBatchjob(f, streams),
} {
if c.Hidden {
t.Errorf("%s command should be visible", name)
}
if tag := c.Annotations[cmdutil.TagAnnotation]; tag != "" {
t.Errorf("%s tag = %q, want none", name, tag)
}
}
}
Loading
Loading