go-version-watcher

command module
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: BSD-2-Clause Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-version-watcher

Polls https://go.dev/dl/?mode=json on an interval, computes the maximum stable:true Go version, and publishes one deduplicated CreateTaskCommand to Kafka per new version so a downstream task system can act on it. Alongside the task it publishes one NotificationPublishCommand (type go-release) to the generic notification core, so a new stable Go release lands in Discord without the vault-task backstop.

The emitted task title and body are plain, deployment-agnostic defaults out of the box; set TASK_TITLE_TEMPLATE / TASK_BODY_TEMPLATE (Go text/template) to inject deployment-specific content — e.g. a link to your own update runbook.

The watcher is the producer (Layer 1 detection) half of the pipeline. It never modifies any repo. It emits one global "new Go released" signal; deciding which repos need a bump is a future Layer 2 fan-out service.

How It Works

On each poll cycle:

  1. Load cursor (/data/cursor.json) — a single last_seen_version string.
  2. Query go.dev — parse the JSON release list, keep stable:true entries, and compute the max version by parsed (major, minor, patch) integers (go1.26.10 > go1.26.9). On query/parse failure the cursor is held and the cycle records go_dev_error.
  3. Cold start (empty cursor): seed the cursor to the current max and emit nothing — avoids a spurious "update" task on first run.
  4. New version (max > cursor): classify release_kind (minor if the major/minor differs, else patch), publish one CreateTaskCommand plus one NotificationPublishCommand (type go-release), and advance the cursor on task-publish success. The notification publish is best-effort — a transient failure is recorded via the notification_error metric and the task remains the deduplicated backstop.
  5. Unchanged (max <= cursor): record version_unchanged, emit nothing.

Deterministic UUID5("go-version:" + version) gives controller dedup — re-polling an already-seen version is a no-op.

Task Contract

Every emitted CreateTaskCommand carries this frontmatter shape:

task_type: go-version-update
assignee: human
phase: planning
status: in_progress
stage: dev|prod
task_identifier: <UUID5("go-version:" + new_version)>
title: Update Go to <X.Y.Z>
new_version: go1.27.0
previous_version: go1.26.5
release_kind: minor        # minor | patch
release_notes_url: https://go.dev/doc/devel/release#go1.27.0

Body is an operator-readable header only (title + release-notes URL + downloads URL). The built-in default is deployment-agnostic; override it per deployment with TASK_BODY_TEMPLATE to add e.g. a runbook link.

Notification Contract

Every emitted NotificationPublishCommand carries this shape:

type: go-release
message: Go <X.Y.Z> released (<minor|patch>) - https://go.dev/doc/devel/release#go<X.Y.Z>
metadata:
  source: go-version-watcher
  version: go1.27.0
  previous_version: go1.26.5
  release_kind: minor
  release_notes_url: https://go.dev/doc/devel/release#go1.27.0

It is sent to the {branch}-core-notification-v1-request topic (CDB, NotificationV1SchemaID); the notification core's controller routes go-release to Discord. The message never carries a target — per the notification-targets principle, the message does not know where it ends.

Environment Variables

Variable Required Default Description
STAGE yes — Deployment stage (dev or prod)
KAFKA_BROKERS yes — Comma-separated Kafka broker list
LISTEN no :9090 HTTP listen address (/healthz, /readiness, /metrics)
POLL_INTERVAL no 24h Poll interval (Go duration string)
CURSOR_PATH no /data/cursor.json Cursor persistence path (PVC mount)
TOPIC_PREFIX no — Kafka topic prefix for CQRS topic construction
SENTRY_DSN no — Sentry DSN for error tracking
SENTRY_PROXY no — HTTP proxy URL for Sentry transport

HTTP Endpoints

Path Method Purpose
/healthz GET Liveness probe (always 200 OK)
/readiness GET Readiness probe (always 200 OK)
/metrics GET Prometheus metrics

Metrics

Metric Cardinality Purpose
go_version_watcher_poll_cycle_total{result} result=success|go_dev_error Poll health
go_version_watcher_published_total{status} status=create|notification|notification_error|error Task + notification emission
go_version_watcher_filter_skipped_total{reason} reason=version_unchanged Filter visibility

Development

make test          # run unit tests
make generate      # regenerate counterfeiter mocks
make precommit     # format + lint + test + security checks

Build

The image is built either on the local Docker daemon or inside a Kubernetes cluster, selected by BUILD_TARGET.

Local (the default) builds and tags on this machine:

make build VERSION=<tag>

Cluster builds render and run a Job in the named cluster alias (sun, nukedev, nukeprod) or kubectl context. The Job clones REF, builds the image and pushes it:

make build BUILD_TARGET=<cluster> REF=<full-sha> VERSION=<tag>

The cluster push credential is Docker Hub only, so that arm pushes docker.io/bborbe/go-version-watcher:<tag>. nuke's MIRROR_IMAGES step is what copies that image into the private registry; the build does not push there directly.

upload, clean and buca remain local-only — they assume a Docker daemon on the invoking host, so they are refused for a cluster BUILD_TARGET.

⚠️ On the cluster arm VERSION must be a scratch tag. A tag that already names a released image is overwritten irreversibly by the push.

Smoke Test (cmd/run-once)

Single Poll cycle against real dev Kafka, then exits.

cd cmd/run-once
make run-once KAFKA_BROKERS=<brokers>

License

BSD 2-Clause License. See LICENSE.

Documentation

Overview

Command go-version-watcher polls https://go.dev/dl/?mode=json on an interval, computes the max stable Go version, and publishes one CreateTaskCommand to Kafka per new version so the Go update runbook can be run.

See [[Go Version Watcher]] for scope + DoD; [[Watcher Writing Guide]] for the producer-side contract; [[Agent Task File Contract]] for the frontmatter/body shape this watcher emits.

Directories

Path Synopsis
cmd
run-once command
Command go-version-watcher-run-once runs a single go.dev poll cycle then exits.
Command go-version-watcher-run-once runs a single go.dev poll cycle then exits.
Code generated by counterfeiter.
Code generated by counterfeiter.
pkg
Package pkg provides the core domain types and logic for the go-version-watcher service:
Package pkg provides the core domain types and logic for the go-version-watcher service:
factory
Package factory wires concrete dependencies for the go-version-watcher binary.
Package factory wires concrete dependencies for the go-version-watcher binary.
tasktemplate
Package tasktemplate holds the built-in default title/body templates for the emitted go-version task, authored as embedded markdown files.
Package tasktemplate holds the built-in default title/body templates for the emitted go-version task, authored as embedded markdown files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL