cli

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 37 Imported by: 0

Documentation

Overview

Package cli implements cadish's command-line subcommands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Adapt

func Adapt(args []string) int

Adapt converts a Varnish VCL file into a best-effort Cadishfile skeleton. It writes the Cadishfile to stdout (or -o FILE) and a mapped-vs-review summary to stderr. It is intentionally lenient: the output is a starting point a human finishes, not a runnable config — every uncertain construct becomes a `# TODO(adapt): …` comment.

func Check

func Check(args []string) int

func Edge

func Edge(args []string) int

Edge dispatches the `cadish edge …` subcommands. It is the management plane for Cadish Edge; this first slice ships only `build` (IR + coverage report).

func EdgeBuild

func EdgeBuild(args []string) int

EdgeBuild compiles a Cadishfile, projects each site to an EdgeIR, writes the IR JSON, and prints a coverage report. With -strict it exits non-zero when anything is delegated (the edge equivalent of `cadish check -strict`).

func EdgeDeploy

func EdgeDeploy(args []string) int

EdgeDeploy builds each site's worker bundle and uploads it (script + bindings, no routes) to Cloudflare. Auth: CF_API_TOKEN; origin: -origin or CADISH_EDGE_ORIGIN. -allow-public-values acknowledges that the VALUE-EXPOSURE warnings have been reviewed and none of the listed literals is a secret; the ForcedPass correctness gate is not bypassed by this flag.

func EdgeManageRoutes

func EdgeManageRoutes(args []string, action string) int

EdgeManageRoutes attaches (enable) or detaches (disable) the worker routes.

func Fmt

func Fmt(args []string) int

Fmt formats Cadishfiles. With -w it rewrites each file in place; otherwise it prints the formatted result to stdout. With no file arguments it reads from stdin and writes to stdout (-w is ignored for stdin). On a parse error it prints a "file:line:col: message" diagnostic to stderr and returns a non-zero exit code; other files are still processed.

func Gateway

func Gateway(args []string) int

Gateway runs cadish in-cluster as a Kubernetes Gateway API controller: it serves traffic from routing translated out of GatewayClass / Gateway / HTTPRoute objects (the cluster is the source of truth), while the base Cadishfile supplies only globals (admin/ACME/ access-log). It watches those resources and hot-swaps the live routing through Server.ApplyConfig — the SAME atomic swap `cadish ingress` uses. It runs as a SEPARATE process from `cadish ingress` (a separate Deployment / GatewayClass controllerName), so the two controllers do not contend for the same objects. Serves until SIGINT/SIGTERM; SIGHUP re-reads the base Cadishfile and re-reconciles.

Scope (slices 1+2): GatewayClass acceptance; Gateway HTTP + HTTPS (TLS Terminate) listeners with certificateRefs (BYO Secret termination, the SAME Server.SetDynamicCerts path the Ingress controller uses); HTTPRoute host + path (Exact / PathPrefix) routing with advanced matchers (headers / queryParams / method); cross-namespace refs gated by a ReferenceGrant; weighted multi-backend pools; and status conditions. See docs/gateway-api.md.

func Ingress

func Ingress(args []string) int

Ingress runs cadish in-cluster as an Ingress controller: it serves traffic from routing translated out of Kubernetes Ingress objects (the cluster is the source of truth), while the base Cadishfile supplies only globals (admin/ACME/access-log). It watches Ingress/IngressClass/Secret/ConfigMap and hot-swaps the live routing through Server.ApplyConfig. Serves until SIGINT/SIGTERM; SIGHUP re-reads the base Cadishfile and re-reconciles.

func Logs

func Logs(args []string) int

Logs implements `cadish logs` — the NCSA-style access-log tail.

Source (D44): by default `cadish logs` dials the running server's access-log unix socket (`-log-socket`, default ${TMPDIR}/cadish-access.sock) and streams the LIVE access log — the server keeps it in memory and fans it out only while a consumer is attached (no disk writes). It renders each request line with host/path/status/ cache filters in a text|ncsa|json format. Redirect/pipe to persist: `cadish logs > access.log`.

A FILE argument (or stdin) reads a previously-saved NDJSON log instead of the socket; `-f` then follows the file (tail -f) until interrupted. See docs/logs.md.

Usage:

cadish logs [-format text|ncsa|json] [filters]            # live (socket)
cadish logs > access.log                                  # persist live stream
cadish logs [-f] [-format …] [filters] FILE              # saved-file tail
cat access.json | cadish logs -format ncsa                # piped/stdin

Filters: -host SUB, -path SUB (case-insensitive substring), -cache TOKEN (HIT/MISS/…), -status CODE (exact), -status-class N (1..5 for Nxx), -min-status CODE (>=).

func Reload

func Reload(args []string) int

Reload signals a running `cadish run` process to hot-reload its Cadishfile (SIGHUP). It locates the process either by -pidfile FILE (the path passed to `cadish run -pidfile`) or by an explicit -pid N. The reload is zero-downtime and fail-safe in the server: a bad new config is rejected there and the old one keeps serving; this command only delivers the signal.

Flags: -pidfile PATH (read the PID from this file) or -pid N (signal this PID). Exit code: 0 on a delivered signal, non-zero on a missing pidfile / bad PID / signal error.

func Run

func Run(args []string) int

Run loads the Cadishfile, builds the caching reverse proxy, listens on the configured address (plain HTTP this milestone), and serves until SIGINT/SIGTERM, at which point it drains in-flight requests gracefully.

Flags: -config PATH (the Cadishfile), -addr ADDR (listen address, default ":80").

func Usage

func Usage(w io.Writer)

Usage writes the top-level help text to w.

func Version

func Version() int

Version prints version information and returns the process exit code.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL