diff --git a/cmd/beemo/Dockerfile b/cmd/beemo/Dockerfile index 2c7568f1e..653a0e3df 100644 --- a/cmd/beemo/Dockerfile +++ b/cmd/beemo/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /dockerbuild # timezone data for alpine builds ENV GOEXPERIMENT=loopvar RUN GIT_VERSION=$(git describe --tags --long --always) && \ - go build -tags timetzdata -ldflags="-X github.com/bluesky-social/indigo/version.Version=$GIT_VERSION" -o /beemo ./cmd/beemo + go build -tags timetzdata -o /beemo ./cmd/beemo ### Run stage FROM alpine:3.18 diff --git a/cmd/beemo/main.go b/cmd/beemo/main.go index ae04f78f4..3d659be4b 100644 --- a/cmd/beemo/main.go +++ b/cmd/beemo/main.go @@ -15,12 +15,12 @@ import ( comatproto "github.com/bluesky-social/indigo/api/atproto" "github.com/bluesky-social/indigo/util" - "github.com/bluesky-social/indigo/util/version" "github.com/bluesky-social/indigo/xrpc" _ "github.com/joho/godotenv/autoload" _ "go.uber.org/automaxprocs" + "github.com/carlmjohnson/versioninfo" logging "github.com/ipfs/go-log" "github.com/urfave/cli/v2" ) @@ -38,7 +38,7 @@ func run(args []string) error { app := cli.App{ Name: "beemo", Usage: "bluesky moderation reporting bot", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/bigsky/Dockerfile b/cmd/bigsky/Dockerfile index c54855504..970360be4 100644 --- a/cmd/bigsky/Dockerfile +++ b/cmd/bigsky/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /dockerbuild # timezone data for alpine builds ENV GOEXPERIMENT=loopvar RUN GIT_VERSION=$(git describe --tags --long --always) && \ - go build -tags timetzdata -ldflags="-X github.com/bluesky-social/indigo/version.Version=$GIT_VERSION" -o /bigsky ./cmd/bigsky + go build -tags timetzdata -o /bigsky ./cmd/bigsky ### Build Frontend stage FROM node:18-alpine as web-builder diff --git a/cmd/bigsky/main.go b/cmd/bigsky/main.go index 6415e0891..e547e6b98 100644 --- a/cmd/bigsky/main.go +++ b/cmd/bigsky/main.go @@ -22,7 +22,6 @@ import ( "github.com/bluesky-social/indigo/repomgr" "github.com/bluesky-social/indigo/util" "github.com/bluesky-social/indigo/util/cliutil" - "github.com/bluesky-social/indigo/util/version" "github.com/bluesky-social/indigo/xrpc" _ "go.uber.org/automaxprocs" @@ -31,6 +30,7 @@ import ( _ "github.com/joho/godotenv/autoload" + "github.com/carlmjohnson/versioninfo" logging "github.com/ipfs/go-log" "github.com/urfave/cli/v2" "go.opentelemetry.io/otel" @@ -58,7 +58,7 @@ func run(args []string) { app := cli.App{ Name: "bigsky", Usage: "atproto BGS/firehose daemon", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/fakermaker/main.go b/cmd/fakermaker/main.go index cc33a0731..ecdd505b0 100644 --- a/cmd/fakermaker/main.go +++ b/cmd/fakermaker/main.go @@ -14,11 +14,11 @@ import ( comatproto "github.com/bluesky-social/indigo/api/atproto" "github.com/bluesky-social/indigo/fakedata" "github.com/bluesky-social/indigo/util/cliutil" - "github.com/bluesky-social/indigo/util/version" _ "github.com/joho/godotenv/autoload" _ "go.uber.org/automaxprocs" + "github.com/carlmjohnson/versioninfo" "github.com/urfave/cli/v2" "golang.org/x/sync/errgroup" ) @@ -32,7 +32,7 @@ func run(args []string) { app := cli.App{ Name: "fakermaker", Usage: "bluesky fake account/content generator", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/gosky/main.go b/cmd/gosky/main.go index 168413bf2..b7ca90a7b 100644 --- a/cmd/gosky/main.go +++ b/cmd/gosky/main.go @@ -24,7 +24,6 @@ import ( "github.com/bluesky-social/indigo/repo" "github.com/bluesky-social/indigo/util" "github.com/bluesky-social/indigo/util/cliutil" - "github.com/bluesky-social/indigo/util/version" "github.com/bluesky-social/indigo/xrpc" "github.com/gorilla/websocket" @@ -37,6 +36,7 @@ import ( _ "github.com/joho/godotenv/autoload" _ "go.uber.org/automaxprocs" + "github.com/carlmjohnson/versioninfo" logging "github.com/ipfs/go-log" "github.com/polydawn/refmt/cbor" rejson "github.com/polydawn/refmt/json" @@ -55,7 +55,7 @@ func run(args []string) { app := cli.App{ Name: "gosky", Usage: "client CLI for atproto and bluesky", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/labelmaker/Dockerfile b/cmd/labelmaker/Dockerfile index b4fb7b9ee..8749b2a36 100644 --- a/cmd/labelmaker/Dockerfile +++ b/cmd/labelmaker/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /dockerbuild # timezone data for alpine builds ENV GOEXPERIMENT=loopvar RUN GIT_VERSION=$(git describe --tags --long --always) && \ - go build -tags timetzdata -ldflags="-X github.com/bluesky-social/indigo/version.Version=$GIT_VERSION" -o /labelmaker ./cmd/labelmaker + go build -tags timetzdata -o /labelmaker ./cmd/labelmaker ### Run stage FROM alpine:3.18 diff --git a/cmd/labelmaker/main.go b/cmd/labelmaker/main.go index fa82f61f1..f9e36c5bf 100644 --- a/cmd/labelmaker/main.go +++ b/cmd/labelmaker/main.go @@ -8,12 +8,12 @@ import ( "github.com/bluesky-social/indigo/carstore" "github.com/bluesky-social/indigo/labeler" "github.com/bluesky-social/indigo/util/cliutil" - "github.com/bluesky-social/indigo/util/version" "github.com/urfave/cli/v2" _ "github.com/joho/godotenv/autoload" _ "go.uber.org/automaxprocs" + "github.com/carlmjohnson/versioninfo" logging "github.com/ipfs/go-log" "github.com/whyrusleeping/go-did" "gorm.io/plugin/opentelemetry/tracing" @@ -32,7 +32,7 @@ func run(args []string) error { app := cli.App{ Name: "labelmaker", Usage: "atproto content labeling daemon", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/laputa/main.go b/cmd/laputa/main.go index 6555ccd6e..2cedb393a 100644 --- a/cmd/laputa/main.go +++ b/cmd/laputa/main.go @@ -9,11 +9,11 @@ import ( "github.com/bluesky-social/indigo/pds" "github.com/bluesky-social/indigo/plc" "github.com/bluesky-social/indigo/util/cliutil" - "github.com/bluesky-social/indigo/util/version" _ "github.com/joho/godotenv/autoload" _ "go.uber.org/automaxprocs" + "github.com/carlmjohnson/versioninfo" logging "github.com/ipfs/go-log" "github.com/urfave/cli/v2" "go.opentelemetry.io/otel" @@ -36,7 +36,7 @@ func run(args []string) { app := cli.App{ Name: "laputa", Usage: "bluesky PDS in golang", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/netsync/main.go b/cmd/netsync/main.go index d316f5b16..609df6921 100644 --- a/cmd/netsync/main.go +++ b/cmd/netsync/main.go @@ -22,7 +22,7 @@ import ( "golang.org/x/time/rate" - "github.com/bluesky-social/indigo/util/version" + "github.com/carlmjohnson/versioninfo" "github.com/urfave/cli/v2" ) @@ -32,7 +32,7 @@ func main() { app := cli.App{ Name: "netsync", Usage: "atproto network cloning tool", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/palomar/Dockerfile b/cmd/palomar/Dockerfile index a3803355e..701f085fb 100644 --- a/cmd/palomar/Dockerfile +++ b/cmd/palomar/Dockerfile @@ -12,7 +12,7 @@ WORKDIR /dockerbuild # timezone data for alpine builds ENV GOEXPERIMENT=loopvar RUN GIT_VERSION=$(git describe --tags --long --always) && \ - go build -tags timetzdata -ldflags="-X github.com/bluesky-social/indigo/version.Version=$GIT_VERSION" -o /palomar ./cmd/palomar + go build -tags timetzdata -o /palomar ./cmd/palomar ### Run stage FROM alpine:3.18 diff --git a/cmd/palomar/main.go b/cmd/palomar/main.go index 3d88edc00..c581a0804 100644 --- a/cmd/palomar/main.go +++ b/cmd/palomar/main.go @@ -25,7 +25,7 @@ import ( "github.com/bluesky-social/indigo/search" "github.com/bluesky-social/indigo/util/cliutil" - "github.com/bluesky-social/indigo/util/version" + "github.com/carlmjohnson/versioninfo" es "github.com/opensearch-project/opensearch-go/v2" cli "github.com/urfave/cli/v2" ) @@ -42,7 +42,7 @@ func run(args []string) error { app := cli.App{ Name: "palomar", Usage: "search indexing and query service (using ES or OS)", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/querycheck/main.go b/cmd/querycheck/main.go index 50ebea227..3ae8a9a99 100644 --- a/cmd/querycheck/main.go +++ b/cmd/querycheck/main.go @@ -23,6 +23,7 @@ import ( "go.opentelemetry.io/otel/trace" "go.uber.org/zap" + "github.com/carlmjohnson/versioninfo" "github.com/urfave/cli/v2" ) @@ -30,7 +31,7 @@ func main() { app := cli.App{ Name: "querycheck", Usage: "a postgresql query plan checker", - Version: "0.0.1", + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/sonar/main.go b/cmd/sonar/main.go index a92bb0c4c..eaf16fac8 100644 --- a/cmd/sonar/main.go +++ b/cmd/sonar/main.go @@ -15,12 +15,12 @@ import ( "github.com/bluesky-social/indigo/events" "github.com/bluesky-social/indigo/events/schedulers/autoscaling" "github.com/bluesky-social/indigo/sonar" - "github.com/bluesky-social/indigo/util/version" "github.com/gorilla/websocket" "github.com/prometheus/client_golang/prometheus/promhttp" _ "go.uber.org/automaxprocs" "go.uber.org/zap" + "github.com/carlmjohnson/versioninfo" "github.com/urfave/cli/v2" ) @@ -28,7 +28,7 @@ func main() { app := cli.App{ Name: "sonar", Usage: "atproto firehose monitoring tool", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/cmd/stress/main.go b/cmd/stress/main.go index 61b1a8fd9..eebfdb478 100644 --- a/cmd/stress/main.go +++ b/cmd/stress/main.go @@ -16,7 +16,6 @@ import ( "github.com/bluesky-social/indigo/repo" "github.com/bluesky-social/indigo/testing" "github.com/bluesky-social/indigo/util/cliutil" - "github.com/bluesky-social/indigo/util/version" "github.com/bluesky-social/indigo/xrpc" "github.com/ipfs/go-cid" @@ -26,6 +25,7 @@ import ( _ "github.com/joho/godotenv/autoload" + "github.com/carlmjohnson/versioninfo" logging "github.com/ipfs/go-log" "github.com/ipld/go-car" cli "github.com/urfave/cli/v2" @@ -41,7 +41,7 @@ func run(args []string) { app := cli.App{ Name: "stress", Usage: "load generation tool for PDS instances", - Version: version.Version, + Version: versioninfo.Short(), } app.Commands = []*cli.Command{ diff --git a/cmd/supercollider/main.go b/cmd/supercollider/main.go index 9b1d25055..3f8253d1d 100644 --- a/cmd/supercollider/main.go +++ b/cmd/supercollider/main.go @@ -26,7 +26,6 @@ import ( "github.com/bluesky-social/indigo/indexer" "github.com/bluesky-social/indigo/models" "github.com/bluesky-social/indigo/plc" - "github.com/bluesky-social/indigo/util/version" petname "github.com/dustinkirkland/golang-petname" "github.com/icrowley/fake" "github.com/labstack/echo-contrib/pprof" @@ -48,8 +47,8 @@ import ( "gorm.io/driver/sqlite" "gorm.io/gorm" + "github.com/carlmjohnson/versioninfo" cbg "github.com/whyrusleeping/cbor-gen" - "go.uber.org/zap" ) @@ -88,7 +87,7 @@ func main() { app := cli.App{ Name: "supercollider", Usage: "atproto event noise-maker for BGS load testing", - Version: version.Version, + Version: versioninfo.Short(), } app.Flags = []cli.Flag{ diff --git a/fakedata/accounts.go b/fakedata/accounts.go index c8b9892e2..71c35165c 100644 --- a/fakedata/accounts.go +++ b/fakedata/accounts.go @@ -8,8 +8,9 @@ import ( comatproto "github.com/bluesky-social/indigo/api/atproto" "github.com/bluesky-social/indigo/util" - "github.com/bluesky-social/indigo/util/version" "github.com/bluesky-social/indigo/xrpc" + + "github.com/carlmjohnson/versioninfo" ) type AccountCatalog struct { @@ -77,7 +78,7 @@ func ReadAccountCatalog(path string) (*AccountCatalog, error) { func AccountXrpcClient(pdsHost string, ac *AccountContext) (*xrpc.Client, error) { httpClient := util.RobustHTTPClient() - ua := "IndigoFakerMaker/" + version.Version + ua := "IndigoFakerMaker/" + versioninfo.Short() xrpcc := &xrpc.Client{ Client: httpClient, Host: pdsHost, diff --git a/labeler/hiveai.go b/labeler/hiveai.go index 0e8da740a..ed180b71c 100644 --- a/labeler/hiveai.go +++ b/labeler/hiveai.go @@ -11,7 +11,8 @@ import ( lexutil "github.com/bluesky-social/indigo/lex/util" "github.com/bluesky-social/indigo/util" - "github.com/bluesky-social/indigo/util/version" + + "github.com/carlmjohnson/versioninfo" ) type HiveAILabeler struct { @@ -117,7 +118,7 @@ func (hal *HiveAILabeler) LabelBlob(ctx context.Context, blob lexutil.LexBlob, b req.Header.Set("Authorization", fmt.Sprintf("Token %s", hal.ApiToken)) req.Header.Add("Content-Type", writer.FormDataContentType()) req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", "labelmaker/"+version.Version) + req.Header.Set("User-Agent", "labelmaker/"+versioninfo.Short()) res, err := hal.Client.Do(req) if err != nil { diff --git a/labeler/micro_nsfw_img.go b/labeler/micro_nsfw_img.go index f64a38545..beea8ab57 100644 --- a/labeler/micro_nsfw_img.go +++ b/labeler/micro_nsfw_img.go @@ -11,7 +11,8 @@ import ( lexutil "github.com/bluesky-social/indigo/lex/util" util "github.com/bluesky-social/indigo/util" - "github.com/bluesky-social/indigo/util/version" + + "github.com/carlmjohnson/versioninfo" ) type MicroNSFWImgLabeler struct { @@ -75,7 +76,7 @@ func (mnil *MicroNSFWImgLabeler) LabelBlob(ctx context.Context, blob lexutil.Lex return nil, err } req.Header.Add("Content-Type", writer.FormDataContentType()) - req.Header.Set("User-Agent", "labelmaker/"+version.Version) + req.Header.Set("User-Agent", "labelmaker/"+versioninfo.Short()) res, err := mnil.Client.Do(req) if err != nil { diff --git a/labeler/sqrl.go b/labeler/sqrl.go index ea50b9534..464e60856 100644 --- a/labeler/sqrl.go +++ b/labeler/sqrl.go @@ -10,7 +10,8 @@ import ( appbsky "github.com/bluesky-social/indigo/api/bsky" "github.com/bluesky-social/indigo/util" - "github.com/bluesky-social/indigo/util/version" + + "github.com/carlmjohnson/versioninfo" ) type SQRLLabeler struct { @@ -66,7 +67,7 @@ func (sl *SQRLLabeler) submitEvent(sqlrReq SQRLRequest) (*SQRLResponse, error) { req.Header.Add("Content-Type", "application/json") req.Header.Set("Accept", "application/json") - req.Header.Set("User-Agent", "labelmaker/"+version.Version) + req.Header.Set("User-Agent", "labelmaker/"+versioninfo.Short()) res, err := sl.Client.Do(req) if err != nil { diff --git a/labeler/xrpc_endpoints.go b/labeler/xrpc_endpoints.go index 6c05f87c1..76340025d 100644 --- a/labeler/xrpc_endpoints.go +++ b/labeler/xrpc_endpoints.go @@ -6,8 +6,8 @@ import ( atproto "github.com/bluesky-social/indigo/api/atproto" label "github.com/bluesky-social/indigo/api/label" - "github.com/bluesky-social/indigo/util/version" + "github.com/carlmjohnson/versioninfo" "github.com/labstack/echo/v4" "go.opentelemetry.io/otel" ) @@ -271,8 +271,8 @@ type HealthStatus struct { func (s *Server) HandleHealthCheck(c echo.Context) error { if err := s.db.Exec("SELECT 1").Error; err != nil { log.Errorf("healthcheck can't connect to database: %v", err) - return c.JSON(500, HealthStatus{Status: "error", Version: version.Version, Message: "can't connect to database"}) + return c.JSON(500, HealthStatus{Status: "error", Version: versioninfo.Short(), Message: "can't connect to database"}) } else { - return c.JSON(200, HealthStatus{Status: "ok", Version: version.Version}) + return c.JSON(200, HealthStatus{Status: "ok", Version: versioninfo.Short()}) } } diff --git a/search/firehose.go b/search/firehose.go index 63eb7beed..dca859bde 100644 --- a/search/firehose.go +++ b/search/firehose.go @@ -18,8 +18,8 @@ import ( lexutil "github.com/bluesky-social/indigo/lex/util" "github.com/bluesky-social/indigo/repo" "github.com/bluesky-social/indigo/repomgr" - "github.com/bluesky-social/indigo/util/version" + "github.com/carlmjohnson/versioninfo" "github.com/gorilla/websocket" "github.com/ipfs/go-cid" typegen "github.com/whyrusleeping/cbor-gen" @@ -65,7 +65,7 @@ func (s *Server) RunIndexer(ctx context.Context) error { u.RawQuery = fmt.Sprintf("cursor=%d", cur) } con, _, err := d.Dial(u.String(), http.Header{ - "User-Agent": []string{fmt.Sprintf("palomar/%s", version.Version)}, + "User-Agent": []string{fmt.Sprintf("palomar/%s", versioninfo.Short())}, }) if err != nil { return fmt.Errorf("events dial failed: %w", err) diff --git a/search/server.go b/search/server.go index 4dba01d84..41eaf179f 100644 --- a/search/server.go +++ b/search/server.go @@ -12,15 +12,15 @@ import ( "github.com/bluesky-social/indigo/atproto/identity" "github.com/bluesky-social/indigo/backfill" - "github.com/bluesky-social/indigo/util/version" "github.com/bluesky-social/indigo/xrpc" - "github.com/prometheus/client_golang/prometheus/promhttp" - "go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho" + "github.com/carlmjohnson/versioninfo" "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" es "github.com/opensearch-project/opensearch-go/v2" + "github.com/prometheus/client_golang/prometheus/promhttp" slogecho "github.com/samber/slog-echo" + "go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho" gorm "gorm.io/gorm" ) @@ -172,9 +172,9 @@ type HealthStatus struct { func (s *Server) handleHealthCheck(c echo.Context) error { if err := s.db.Exec("SELECT 1").Error; err != nil { s.logger.Error("healthcheck can't connect to database", "err", err) - return c.JSON(500, HealthStatus{Status: "error", Version: version.Version, Message: "can't connect to database"}) + return c.JSON(500, HealthStatus{Status: "error", Version: versioninfo.Short(), Message: "can't connect to database"}) } - return c.JSON(200, HealthStatus{Status: "ok", Version: version.Version}) + return c.JSON(200, HealthStatus{Status: "ok", Version: versioninfo.Short()}) } func (s *Server) RunAPI(listen string) error { diff --git a/util/version/version.go b/util/version/version.go deleted file mode 100644 index b998fd7bf..000000000 --- a/util/version/version.go +++ /dev/null @@ -1,27 +0,0 @@ -package version - -import ( - "runtime/debug" -) - -// Version holds the version number. -var Version string - -func init() { - if Version == "" { - Version = "dev-" + revision() - } -} - -func revision() string { - info, ok := debug.ReadBuildInfo() - if ok { - for _, setting := range info.Settings { - switch setting.Key { - case "vcs.revision": - return setting.Value[:7] - } - } - } - return "" -} diff --git a/xrpc/xrpc.go b/xrpc/xrpc.go index 50e95aacf..5e45433a4 100644 --- a/xrpc/xrpc.go +++ b/xrpc/xrpc.go @@ -12,7 +12,7 @@ import ( "strings" "github.com/bluesky-social/indigo/util" - "github.com/bluesky-social/indigo/util/version" + "github.com/carlmjohnson/versioninfo" ) type Client struct { @@ -111,7 +111,7 @@ func (c *Client) Do(ctx context.Context, kind XRPCRequestType, inpenc string, me if c.UserAgent != nil { req.Header.Set("User-Agent", *c.UserAgent) } else { - req.Header.Set("User-Agent", "indigo/"+version.Version) + req.Header.Set("User-Agent", "indigo/"+versioninfo.Short()) } if c.Headers != nil {