From 899cd84583ea92d1b3ecec2f6d1ec6ec62371a5c Mon Sep 17 00:00:00 2001 From: xescugc Date: Thu, 2 Jul 2026 13:32:45 +0200 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20add=20test-proxy=20endpoint=20for?= =?UTF-8?q?=20plugin=E2=86=92PM=20integration=20testing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds GET /_cy/test-proxy that calls the plugin manager's internal proxy using PROXY_URL and PLUGIN_SECRET env vars and forwards the response. Used in e2e tests to verify plugin→PM communication. --- main.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/main.go b/main.go index d3225c0..82aeeee 100644 --- a/main.go +++ b/main.go @@ -5,8 +5,10 @@ import ( _ "embed" "encoding/json" "fmt" + "io" "log" "net/http" + "net/url" "os" "github.com/cycloidio/cy-go-plugin/sentry" @@ -43,6 +45,7 @@ func main() { mux := http.NewServeMux() mux.HandleFunc("GET /_cy/ping", ping) + mux.HandleFunc("GET /_cy/test-proxy", testProxy) mux.HandleFunc("POST /_cy/events", events) mux.HandleFunc("DELETE /_cy/plugin", func(w http.ResponseWriter, r *http.Request) { if err := sentry.Clear(db); err != nil { @@ -78,6 +81,39 @@ func ping(w http.ResponseWriter, _ *http.Request) { respond(w, "ping") } +// testProxy calls the plugin manager's internal proxy endpoint using the injected +// PROXY_URL and PLUGIN_SECRET env vars, and forwards the response back to the caller. +func testProxy(w http.ResponseWriter, r *http.Request) { + proxyURL := os.Getenv("PROXY_URL") + if proxyURL == "" { + http.Error(w, "PROXY_URL not set", http.StatusServiceUnavailable) + return + } + + targetURL := proxyURL + if secret := os.Getenv("PLUGIN_SECRET"); secret != "" { + targetURL += "?secret=" + url.QueryEscape(secret) + } + + req, err := http.NewRequestWithContext(r.Context(), http.MethodGet, targetURL, nil) + if err != nil { + http.Error(w, fmt.Sprintf("build request: %v", err), http.StatusInternalServerError) + return + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + http.Error(w, fmt.Sprintf("proxy call failed: %v", err), http.StatusBadGateway) + return + } + defer resp.Body.Close() + + body, _ := io.ReadAll(resp.Body) + w.Header().Set("Content-Type", resp.Header.Get("Content-Type")) + w.WriteHeader(resp.StatusCode) + w.Write(body) +} + func events(w http.ResponseWriter, _ *http.Request) { respond(w, "events") } From 1016556b2ac42874f637bdd59ed743b3e53794d1 Mon Sep 17 00:00:00 2001 From: xescugc Date: Mon, 6 Jul 2026 13:52:04 +0200 Subject: [PATCH 2/2] feat: add setup with can_replicate to manifest and bump to 0.0.7 Add setup section declaring the plugin as stateless (can_replicate: true) with readiness probe and default resource requests/limits. Fix Dockerfile COPY glob needing trailing slash for multiple source files. --- Dockerfile | 4 ++-- Makefile | 2 +- manifest.yaml | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6aefb5a..bd16a36 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ RUN CGO_ENABLED=0 go build -o /my_app FROM alpine:3.21 WORKDIR /plugin COPY --from=builder /my_app /my_app -COPY --from=builder /plugin/*.yaml . -COPY --from=builder /plugin/*.sql . +COPY --from=builder /plugin/*.yaml ./ +COPY --from=builder /plugin/*.sql ./ EXPOSE 8080 CMD ["/my_app"] diff --git a/Makefile b/Makefile index f05d2a3..28ffaca 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -VERSION=0.0.2 +VERSION=0.0.7 LOCAL_REGISTRY=localhost:5000 .PHONY: docker-release diff --git a/manifest.yaml b/manifest.yaml index 4d3737b..e58af35 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -8,6 +8,13 @@ images: scope: - organization:project:* - organization:credential:* +setup: + can_replicate: true + readiness_path: /_cy/ping + min_cpu: "50m" + min_memory: "64Mi" + max_cpu: "200m" + max_memory: "256Mi" configuration: - name: "Message" description: "Message to display in the job"