simpler check and deps messages

This commit is contained in:
2026-09-17 15:01:48 -03:00
parent 1dc9d38c80
commit 565cecfb50
49 changed files with 1442 additions and 1426 deletions

View File

@@ -1,39 +1,13 @@
# Thin control Makefile — few targets, and the subcommand is an argument rather
# than a second target: `make cluster down`, not `make cluster-down`.
#
# make check is this machine ready? (never changes anything)
# make deps install the toolchain
# make cluster up cluster + registry + addons (ports derive by themselves)
# make tilt / docs work on it, read about it
#
# The logic lives in the scripts, never here: `make cluster up` -> ctrl/cluster.sh up.
#
# Config layers, weakest first: built-in defaults < ctrl/versions.env (pinned
# toolchain) < ctrl/env.d/<profile>.env (optional) < ctrl/.env (local,
# gitignored) < the environment. So `make cluster up PROFILE=<name>` beats them all.
#
# Thin control Makefile: the subcommand is an argument (`make cluster down`); logic lives in ctrl/ scripts.
# make check | deps | cluster up | tilt | docs (`make help` lists all)
# Start with: make check && make deps && make cluster up
# Notes: docs/notes/Makefile.md
# Identity follows the FOLDER NAME, so this directory can be copied elsewhere,
# renamed, and run as a separate environment with no edits. ctrl/.env overrides
# it when you want a name that differs from the directory.
#
# Asked once, of ctrl/ports.sh, which resolves it through lib/config.sh:
#
# Identity and ports, asked once of ctrl/ports.sh, read positionally (selftest pins the order):
# CLUSTER KUBECONTEXT HTTP HTTPS TILT REGISTRY MANIFESTS_DIR
#
# Read positionally, so the order is a contract — ctrl/selftest.sh pins it.
#
# This used to be sed over ctrl/.env plus a slug computed here, which is a
# SECOND derivation of values lib/config.sh already owns — and the two could
# disagree about the port after `ports.sh persist`, or about the name for any
# directory whose sanitised form differs from its raw one. One source now; the
# Tiltfile reads the same line.
FACTS := $(shell bash ctrl/ports.sh active 2>/dev/null)
SLUG := $(shell echo '$(notdir $(CURDIR))' | tr '[:upper:]' '[:lower:]' | tr -c 'a-z0-9-' '-' | sed 's/^-*//; s/-*$$//')
# The fallback matters: ports.sh sources config.sh, and if a profile or .env is
# broken it exits non-zero. Losing the cluster name would send --context to the
# wrong place, so fall back to the folder rather than to empty.
# Fall back to the folder name, not empty, if ports.sh fails on a broken config.
CLUSTER := $(or $(word 1,$(FACTS)),$(SLUG))
KCTX := --context $(or $(word 2,$(FACTS)),kind-$(SLUG))
TILT_PORT := $(word 5,$(FACTS))
@@ -44,11 +18,7 @@ DEPSIMG := $(SLUG)-deps
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
ifneq ($(ARGS),)
$(eval $(ARGS):;@:)
# ...and as PHONY, because some of those words name real directories. `cfg`,
# `ctrl`, `docs`, `gen` and `init` all exist at this level, and make considers a
# target that is an existing directory already built — so `make build ctrl` ran
# the build and then printed "make: 'ctrl' is up to date". The empty rule above
# is not enough on its own; only .PHONY stops make consulting the filesystem.
# ...and as PHONY, because some of those words name real directories (ctrl, docs, ...).
.PHONY: $(ARGS)
endif
@@ -63,7 +33,7 @@ help: ## list targets
# Everything that looks and never changes anything: host, docker, toolchain,
# config, memory, ports, registry, addons. `check mem` goes deeper on memory —
# how far it really climbs, and the WSL .wslconfig backup/restore.
check: ## is this machine ready? [mem [status|push|all|backup|restore]]
check: ## is this machine ready? [all] [mem [status|push|all|backup|restore]]
bash ctrl/check.sh $(ARGS)
# `deps image` is for a machine with nothing but Docker: the installer runs from
@@ -89,16 +59,7 @@ cluster: ## this env + the machine [up|down|reset|list|fr
docs: ## documentation [serve|graphs] (default serve)
bash ctrl/docs.sh $(or $(ARGS),serve)
# --port is only passed when TILT_PORT resolved. It normally does, since FACTS
# above asks ports.sh — but ports.sh can fail on a broken profile, and without
# the guard tilt receives a bare `--port` with no value and fails on the flag
# rather than on anything real. Tilt's own default is 10350, which is the number
# every project on this machine is trying not to collide on, so falling back to
# it silently is worse than not passing the flag.
#
# The Tiltfile asks ports.sh for the rest itself — cluster, registry and where
# the manifests are — so nothing needs passing here beyond what tilt's own flags
# require.
# --port only when TILT_PORT resolved; the Tiltfile asks ports.sh for the rest itself.
tilt: ## dev loop [up|down] (default up)
cd ctrl && tilt $(or $(ARGS),up) $(KCTX) $(if $(filter down,$(ARGS)),,$(if $(TILT_PORT),--port $(TILT_PORT)))
@@ -117,21 +78,8 @@ standalone: ## single-file kits [write|check|export DIR] (d
bash ctrl/standalone.sh $(or $(ARGS),write)
# ── the shape every other project uses ─────────────────────────────────────
# Aliases, not a second implementation: each one calls the same script the
# canonical target does.
#
# The header above argues for `make cluster down` over `make cluster-down`, and
# that still holds *within* this file. But rig is one repo among several on the
# same machine, and every other one answers to kind-up / tilt-up. Muscle memory
# spanning six projects beats internal tidiness in one, so both spellings work.
#
# `cluster list` and `cluster free` have no hyphenated twin on purpose — they
# are rig's own, with nothing to be consistent with.
#
# Nothing outside this file reads these names: the script is `ctrl/cluster.sh`
# and it takes the verb. So rename them, delete the ones you never type, or add
# the spelling your own projects use — an alias is two lines, and adding one
# costs nothing but a line in .PHONY above.
# Aliases matching other projects' kind-up / tilt-up; each calls the same script.
# Nothing else reads these names: rename, delete or add freely (and update .PHONY).
kind-up: ## alias for `cluster up`
bash ctrl/cluster.sh up