Skip to content

feat(httpx): inject deco-operator User-Agent on outbound HTTP#22

Open
igoramf wants to merge 3 commits into
mainfrom
decofile-update-user-agent
Open

feat(httpx): inject deco-operator User-Agent on outbound HTTP#22
igoramf wants to merge 3 commits into
mainfrom
decofile-update-user-agent

Conversation

@igoramf

@igoramf igoramf commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Adds internal/httpx.WithUserAgent, a http.RoundTripper wrapper that injects User-Agent: deco-operator on every outbound request while preserving any value the caller already set and honoring the no-mutation contract by cloning the request.
  • Wires the wrapper into all three places the operator makes HTTP calls today: the pod notifier (NewHTTPClient), the GitHub ZIP downloader, and the DecoRedirect DNS readiness probe — so requests no longer ship Go's default Go-http-client/1.1 UA.
  • Includes unit tests covering default injection, caller-set preservation, and original-request non-mutation.

Test plan

  • go build ./...
  • go vet ./...
  • go test ./internal/httpx/...
  • Deploy to a cluster and confirm downstream logs (nginx / app pods / codeload) record User-Agent: deco-operator

🤖 Generated with Claude Code


Summary by cubic

Sets a consistent RFC 7231-style User-Agent on all outbound HTTP from the operator, with the version sourced from the git tag in CI, to improve downstream observability. Applied to the notifier, GitHub ZIP downloads, and the DNS readiness probe without mutating caller requests.

  • New Features
    • Added internal/httpx.WithUserAgent transport that injects decofile-operator/<version> (+https://github.com/decocms/operator), preserves any caller-set header, and clones requests.
    • Integrated into notifier (NewHTTPClient), GitHub downloader, and DecoRedirect DNS probe. Version is set at build time via -ldflags -X github.com/deco-sites/decofile-operator/internal/httpx.version=${VERSION}; Dockerfile exposes ARG VERSION (default dev) and CI passes the git tag as VERSION in .github/workflows/build-and-push.yaml. Tests cover injection, preservation, and non-mutation.

Written for commit c43080a. Summary will update on new commits.

Review in cubic

igoramf and others added 3 commits June 9, 2026 16:24
Wraps the transport for the notifier, GitHub downloader, and DecoRedirect
DNS probe with a shared RoundTripper so every request the operator makes
identifies itself as deco-operator instead of Go's default User-Agent.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adopts the standard product/version (comment) format used by terraform,
curl, and kubectl. The version slot is overridden at build time via
-ldflags "-X .../httpx.version=v$VERSION" and forwarded through the
Dockerfile via a VERSION build arg. Local builds fall back to "dev".

Example: decofile-operator/v0.4.0-beta.3 (+https://github.com/decocms/operator)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Lets the release workflow forward github.ref_name (e.g. v0.4.0-beta.3)
into the Dockerfile VERSION build arg, which ldflags into the binary.
Removes the Makefile/local build-arg plumbing that diverged from the
single CI path; local builds keep the "dev" default.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants