Skip to content

Commit 5c2d0ec

Browse files
committed
Merge branch 'migrate/foundation-v2-cli-builder-v3-warp'
2 parents a90c7e7 + 5d402f7 commit 5c2d0ec

12 files changed

Lines changed: 676 additions & 464 deletions

File tree

docs/migration-foundation-v2.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Migration: go-cli-builder v3, go-foundation v2, go-warp
2+
3+
Branch: `migrate/foundation-v2-cli-builder-v3-warp` (commit `5b1a157`).
4+
5+
## What changed
6+
7+
### go-cli-builder v3 — `internal/cli/cli.go`
8+
9+
cobra was replaced by declarative struct-tag commands. Every command,
10+
flag, short name and exit code is preserved:
11+
12+
- `generate [domain]`, `gen-pass [password]`, `start`, `start-web`,
13+
`start-dns`, `validate`, `list`, `plugins`, `stop`, `restart`, `version`
14+
- global flags `--config/-c` and `--global-config` (parsed on the root,
15+
exposed to subcommands the same way cobra PersistentFlags did)
16+
- `--tui/-t` and `--bench/-b` on `start`
17+
- `--version` flag on the root plus the `version` subcommand
18+
- `Before()` on the root replaces cobra's `PersistentPreRun` (global config
19+
load before any subcommand)
20+
21+
### go-foundation v2 — `internal/logger/logger.go`
22+
23+
zerolog was removed from `go.mod`. The logger now runs on
24+
`go-foundation/v2/core/logger` with two custom sinks:
25+
26+
- `jsonWriterSink`: one JSON object per line on the date-partitioned
27+
rotating file writer (unchanged `YYYY/MM/DD*.log` layout)
28+
- `consoleSink`: colored human-readable lines on stdout (termenv kept)
29+
30+
The public API (`NewLogger`, `NewPluginLogger`, `NewSystemLogger`,
31+
`Info/Infof/Error/...`, `WithFields`, `SetOutput`, `Writer`) is unchanged,
32+
so the ~20 call sites in `internal/` and `plugins/` needed no edits.
33+
34+
`plugins/contracts.go` adds compile-time conformance of all 7 plugins to
35+
`plugin.Plugin` via `contracts.Assert`, so a broken plugin surface fails the
36+
build instead of registration.
37+
38+
### go-warp v1.2.2 — `internal/server/stat_cache.go`
39+
40+
The hand-rolled `sync.Map` + atomic swap stat cache was replaced by
41+
`go-warp/v1/cache.NewInMemory` with `WithMaxEntries(65536)` and a 1s TTL.
42+
TTL expiry, LRU eviction and the max-entries bound are now handled by the
43+
framework. `resetStatCache` (used by tests) recreates the cache.
44+
45+
## v2.3.2: configuration and vhost dispatch (second pass)
46+
47+
After `go-foundation` v2.3.2 added the missing capabilities, the remaining
48+
gaps closed:
49+
50+
### `internal/config` — configuration collections
51+
52+
- `LoadAllConfigs` discovers site files through
53+
`configuration/source/dir` (glob `*.json`, `conf.global.json` excluded by
54+
the provider) and decodes each with the existing strict `LoadConfig`, so
55+
unknown fields keep failing as before.
56+
- `ValidateAll` now expresses its two failure modes as Foundation collection
57+
rules: `SiteConfig.Validate` is the per-file `ItemValidator` (file name is
58+
the entry name) and duplicate-domain / SSL-port-conflict checks are
59+
`CrossValidator`s. `ValidateCollection` aggregates all problems in one
60+
pass. CLI output shape unchanged.
61+
62+
### `internal/server` — virtual host dispatch and SNI
63+
64+
- `startVirtualHostServer` dropped the hand-rolled radix tree for
65+
`httpx.VHostMux` (normalized host matching, configurable fallback). The
66+
first registered handler stays the fallback for unknown hosts, preserving
67+
previous behavior. `github.com/armon/go-radix` is gone from `go.mod`.
68+
- `setupTLS` loads static certificates into `httpx.CertResolver`, which
69+
selects per-SNI; ACME hosts still fall through to the autocert manager.
70+
Host normalization is shared between mux and resolver.
71+
72+
### Still not migrated
73+
74+
`app` / `app/web` (action-based HTTP): GoUp *is* the server (proxy, plugins,
75+
QUIC, TUI); the action model is for building applications, not servers.
76+
DNS indexes stay as-is: pre-compiled at startup, no TTL hot path.
77+
78+
## Verification
79+
80+
- `go build ./...` clean
81+
- `go vet ./...` clean
82+
- `go test ./...`: 9 packages ok
83+
- CLI smoke-tested: `--help`, `--version`, `version`, `validate`, `list`,
84+
`plugins`, `gen-pass`

go.mod

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ go 1.25.0
55
toolchain go1.26.5
66

77
require (
8-
github.com/armon/go-radix v1.0.0
98
github.com/gorilla/mux v1.8.1
109
github.com/miekg/dns v1.1.72
10+
github.com/mirkobrombin/go-cli-builder/v3 v3.0.1
11+
github.com/mirkobrombin/go-foundation/v2 v2.3.2
12+
github.com/mirkobrombin/go-warp v1.2.2
1113
github.com/muesli/termenv v0.16.0
1214
github.com/quic-go/quic-go v0.60.0
1315
github.com/rivo/tview v0.42.0
14-
github.com/rs/zerolog v1.35.1
1516
github.com/shirou/gopsutil v3.21.11+incompatible
16-
github.com/spf13/cobra v1.10.2
1717
github.com/yookoala/gofast v0.8.0
1818
golang.org/x/crypto v0.54.0
1919
golang.org/x/sys v0.47.0
@@ -22,23 +22,41 @@ require (
2222

2323
require (
2424
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
25+
github.com/beorn7/perks v1.0.1 // indirect
26+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
27+
github.com/dgraph-io/ristretto v0.1.1 // indirect
28+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
29+
github.com/dustin/go-humanize v1.0.0 // indirect
2530
github.com/gdamore/encoding v1.0.1 // indirect
2631
github.com/gdamore/tcell/v2 v2.13.10 // indirect
32+
github.com/go-logr/logr v1.4.3 // indirect
33+
github.com/go-logr/stdr v1.2.2 // indirect
2734
github.com/go-ole/go-ole v1.3.0 // indirect
28-
github.com/inconshreveable/mousetrap v1.1.0 // indirect
35+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect
36+
github.com/golang/protobuf v1.5.3 // indirect
2937
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
30-
github.com/mattn/go-colorable v0.1.15 // indirect
3138
github.com/mattn/go-isatty v0.0.22 // indirect
39+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
40+
github.com/pkg/errors v0.9.1 // indirect
41+
github.com/prometheus/client_golang v1.17.0 // indirect
42+
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
43+
github.com/prometheus/common v0.44.0 // indirect
44+
github.com/prometheus/procfs v0.11.1 // indirect
3245
github.com/quic-go/qpack v0.6.0 // indirect
46+
github.com/redis/go-redis/v9 v9.11.0 // indirect
3347
github.com/rivo/uniseg v0.4.7 // indirect
34-
github.com/spf13/pflag v1.0.10 // indirect
3548
github.com/tklauser/go-sysconf v0.4.0 // indirect
3649
github.com/tklauser/numcpus v0.12.0 // indirect
3750
github.com/yusufpapurcu/wmi v1.2.4 // indirect
51+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
52+
go.opentelemetry.io/otel v1.37.0 // indirect
53+
go.opentelemetry.io/otel/metric v1.37.0 // indirect
54+
go.opentelemetry.io/otel/trace v1.37.0 // indirect
3855
golang.org/x/mod v0.38.0 // indirect
3956
golang.org/x/net v0.57.0 // indirect
4057
golang.org/x/sync v0.22.0 // indirect
4158
golang.org/x/text v0.40.0 // indirect
4259
golang.org/x/tools v0.48.0 // indirect
4360
golang.org/x/tools/godoc v0.1.0-deprecated // indirect
61+
google.golang.org/protobuf v1.31.0 // indirect
4462
)

0 commit comments

Comments
 (0)