From f1615637d9dbbd6da520aefc14306c1bf94fe69f Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Fri, 24 Apr 2026 12:44:43 +0700 Subject: [PATCH] Migrate to checker-sdk-go v1.3.0 with standalone build tag The SDK split the HTTP server scaffolding into the new checker-sdk-go/checker/server subpackage. Update main.go to import server and call server.New, and isolate the interactive form code behind the standalone build tag so plugin/builtin builds skip net/http and html/template entirely. --- .codex | 0 Dockerfile | 2 +- Makefile | 4 ++-- checker/definition.go | 2 +- checker/interactive.go | 2 ++ go.mod | 6 ++++-- go.sum | 5 ++++- main.go | 6 +++--- 8 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 .codex diff --git a/.codex b/.codex new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile index a41c0b5..fe2bf8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN go generate ./... && CGO_ENABLED=0 go build -ldflags "-X main.Version=${CHECKER_VERSION}" -o /checker-caa . +RUN go generate ./... && CGO_ENABLED=0 go build -tags standalone -ldflags "-X main.Version=${CHECKER_VERSION}" -o /checker-caa . FROM scratch COPY --from=builder /checker-caa /checker-caa diff --git a/Makefile b/Makefile index 974b61a..77df544 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ GO_LDFLAGS := -X main.Version=$(CHECKER_VERSION) all: $(CHECKER_NAME) $(CHECKER_NAME): $(CHECKER_SOURCES) - go build -ldflags "$(GO_LDFLAGS)" -o $@ . + go build -tags standalone -ldflags "$(GO_LDFLAGS)" -o $@ . plugin: $(CHECKER_NAME).so @@ -22,7 +22,7 @@ docker: docker build --build-arg CHECKER_VERSION=$(CHECKER_VERSION) -t $(CHECKER_IMAGE) . test: - go test ./... + go test -tags standalone ./... clean: rm -f $(CHECKER_NAME) $(CHECKER_NAME).so diff --git a/checker/definition.go b/checker/definition.go index 6e966b3..a879ee9 100644 --- a/checker/definition.go +++ b/checker/definition.go @@ -11,7 +11,7 @@ import ( var Version = "built-in" // Definition is the package-level helper expected by the plugin -// entrypoint and by sdk.NewServer via CheckerDefinitionProvider. +// entrypoint and by server.New via CheckerDefinitionProvider. func Definition() *sdk.CheckerDefinition { return (&caaProvider{}).Definition() } diff --git a/checker/interactive.go b/checker/interactive.go index 3d92759..d6a520e 100644 --- a/checker/interactive.go +++ b/checker/interactive.go @@ -1,3 +1,5 @@ +//go:build standalone + package checker import ( diff --git a/go.mod b/go.mod index b207bda..89e6e88 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,12 @@ module git.happydns.org/checker-caa go 1.25.0 -require git.happydns.org/checker-sdk-go v1.1.0 +require ( + git.happydns.org/checker-sdk-go v1.3.0 + github.com/miekg/dns v1.1.72 +) require ( - github.com/miekg/dns v1.1.72 // indirect golang.org/x/mod v0.31.0 // indirect golang.org/x/net v0.48.0 // indirect golang.org/x/sync v0.19.0 // indirect diff --git a/go.sum b/go.sum index 17bb426..092728a 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,7 @@ -git.happydns.org/checker-sdk-go v1.1.0/go.mod h1:aNAcfYFfbhvH9kJhE0Njp5GX0dQbxdRB0rJ0KvSC5nI= +git.happydns.org/checker-sdk-go v1.3.0 h1:FG2kIhlJCzI0m35EhxSgn4UWc9M4ha6aZTeoChu4l7A= +git.happydns.org/checker-sdk-go v1.3.0/go.mod h1:aNAcfYFfbhvH9kJhE0Njp5GX0dQbxdRB0rJ0KvSC5nI= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/miekg/dns v1.1.72 h1:vhmr+TF2A3tuoGNkLDFK9zi36F2LS+hKTRW0Uf8kbzI= github.com/miekg/dns v1.1.72/go.mod h1:+EuEPhdHOsfk6Wk5TT2CzssZdqkmFhf8r+aVyDEToIs= golang.org/x/mod v0.31.0 h1:HaW9xtz0+kOcWKwli0ZXy79Ix+UW/vOfmWI5QVd2tgI= diff --git a/main.go b/main.go index 5f54133..3562b7c 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "log" caa "git.happydns.org/checker-caa/checker" - sdk "git.happydns.org/checker-sdk-go/checker" + "git.happydns.org/checker-sdk-go/checker/server" ) var Version = "custom-build" @@ -16,8 +16,8 @@ func main() { flag.Parse() caa.Version = Version - server := sdk.NewServer(caa.Provider()) - if err := server.ListenAndServe(*listenAddr); err != nil { + srv := server.New(caa.Provider()) + if err := srv.ListenAndServe(*listenAddr); err != nil { log.Fatalf("server error: %v", err) } }