Skip to content

[Feature]: Add virtwork validate subcommand for catalog entries #202

Description

@mrhillsman

Problem Statement

Catalog entry authors have no fast feedback loop to structurally validate their entries before deploying. virtwork run --from-catalog <entry> --dry-run renders full YAML specs without a cluster, but it doesn't surface parse errors, placeholder typos, or structural issues in isolation — it exercises the full orchestration path.

Proposed Solution

Add a virtwork validate CLI subcommand:

virtwork validate [entry-names...] [--catalog-dir path]
  • Positional args: entry names to validate. If none given, discover all subdirectories in catalog-dir.
  • --catalog-dir: override catalog directory (default ~/.virtwork/catalog)

Per-entry validation (all already exists in LoadCatalogEntry / validateManifest):

  • Entry directory exists and is a directory
  • At least one *.service file present
  • workload.yaml parses as valid YAML
  • Storage: names non-empty, non-reserved, non-duplicate; sizes parse as K8s quantities; serials ≤20 chars; mounts are absolute paths
  • Service: at least one port; ports 1–65535; protocol TCP or UDP
  • Multi-role: every declared role has a matching {role}.service file
  • Placeholder consistency via ValidatePlaceholders (see linked issue)

Output: pass/fail per entry with actionable error messages. Exit 0 if all pass, non-zero if any fail.

Alternatives Considered

  • Extend --dry-run with validation output — conflates "preview deployment" with "check structure"; different use cases
  • Makefile/script wrapper around LoadCatalogEntry — less discoverable, not part of the CLI's help output

Area

CLI / Configuration, Workloads

Architecture Layer

Layer 4 - Orchestration (cmd, cleanup)

Additional Context

Implementation plan: docs/plans/write-two-catalog-workloads-wiggly-lerdorf.md (section 2)

Depends on ValidatePlaceholders from the linked issue.

Files changed:

File Change
internal/config/config.go Add BindValidateFlags(cmd) binding --catalog-dir
cmd/virtwork/main.go Add newValidateCmd(), validateE(), wire into root command

Verification:

go run ./cmd/virtwork validate --catalog-dir ./catalog          # exits 0
go run ./cmd/virtwork validate --catalog-dir ./catalog sysbench # single entry
go run ./cmd/virtwork validate --catalog-dir /nonexistent       # exits non-zero
go test ./...

Metadata

Metadata

Assignees

Labels

kind/featureCategorizes issue or PR as related to a new feature.priority/backlogHigher priority than priority/awaiting-more-evidence.size/LDenotes a PR that changes 100-499 lines, ignoring generated files.tech-debtTechnical debt, code quality, or maintenance concerntriage/acceptedIndicates an issue or PR is ready to be actively worked on.

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions