From c44cb5af5be660b996baa90c0028100266d6f446 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Wed, 21 Jan 2026 18:58:23 +0000 Subject: [PATCH] fix: use pure Go SQLite driver for arm64 compatibility Switch from mattn/go-sqlite3 (CGO) to modernc.org/sqlite (pure Go) for auth, audit, and notification queue storage. This enables SQLite functionality on arm64 Docker images which are built with CGO_ENABLED=0. Related to #1140 --- go.mod | 5 ++--- go.sum | 2 -- internal/notifications/queue.go | 4 ++-- pkg/audit/sqlite_logger.go | 4 ++-- pkg/auth/sqlite_manager.go | 4 ++-- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 8fc100d1b..916f59045 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,6 @@ require ( github.com/google/uuid v1.6.0 github.com/gorilla/websocket v1.5.3 github.com/joho/godotenv v1.5.1 - github.com/mattn/go-sqlite3 v1.14.32 github.com/oklog/ulid/v2 v2.1.1 github.com/opencontainers/image-spec v1.1.1 github.com/prometheus/client_golang v1.23.2 @@ -29,8 +28,6 @@ require ( golang.org/x/sync v0.18.0 golang.org/x/sys v0.38.0 golang.org/x/term v0.37.0 - golang.org/x/time v0.14.0 - gopkg.in/yaml.v3 v3.0.1 k8s.io/api v0.32.0 k8s.io/apimachinery v0.32.0 k8s.io/client-go v0.32.0 @@ -111,10 +108,12 @@ require ( golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b // indirect golang.org/x/net v0.47.0 // indirect golang.org/x/text v0.31.0 // indirect + golang.org/x/time v0.14.0 // indirect google.golang.org/grpc v1.75.1 // indirect google.golang.org/protobuf v1.36.10 // indirect gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.2 // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect diff --git a/go.sum b/go.sum index 95cbf6645..6003c25cc 100644 --- a/go.sum +++ b/go.sum @@ -133,8 +133,6 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= -github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/sys/atomicwriter v0.1.0 h1:kw5D/EqkBwsBFi0ss9v1VG3wIkVhzGvLklJ+w3A14Sw= diff --git a/internal/notifications/queue.go b/internal/notifications/queue.go index 9197a8d42..ca5f1502f 100644 --- a/internal/notifications/queue.go +++ b/internal/notifications/queue.go @@ -9,10 +9,10 @@ import ( "sync" "time" - _ "github.com/mattn/go-sqlite3" "github.com/rcourtman/pulse-go-rewrite/internal/alerts" "github.com/rcourtman/pulse-go-rewrite/internal/utils" "github.com/rs/zerolog/log" + _ "modernc.org/sqlite" ) // NotificationQueueStatus represents the status of a queued notification @@ -72,7 +72,7 @@ func NewNotificationQueue(dataDir string) (*NotificationQueue, error) { dbPath := filepath.Join(dataDir, "notification_queue.db") - db, err := sql.Open("sqlite3", dbPath) + db, err := sql.Open("sqlite", dbPath) if err != nil { return nil, fmt.Errorf("failed to open notification queue database: %w", err) } diff --git a/pkg/audit/sqlite_logger.go b/pkg/audit/sqlite_logger.go index ac6e6b2b8..382f44a20 100644 --- a/pkg/audit/sqlite_logger.go +++ b/pkg/audit/sqlite_logger.go @@ -9,8 +9,8 @@ import ( "sync" "time" - _ "github.com/mattn/go-sqlite3" "github.com/rs/zerolog/log" + _ "modernc.org/sqlite" ) // SQLiteLoggerConfig configures the SQLite audit logger. @@ -46,7 +46,7 @@ func NewSQLiteLogger(cfg SQLiteLoggerConfig) (*SQLiteLogger, error) { dbPath := filepath.Join(auditDir, "audit.db") - db, err := sql.Open("sqlite3", dbPath) + db, err := sql.Open("sqlite", dbPath) if err != nil { return nil, fmt.Errorf("failed to open audit database: %w", err) } diff --git a/pkg/auth/sqlite_manager.go b/pkg/auth/sqlite_manager.go index 35a4b96a9..b2b90f336 100644 --- a/pkg/auth/sqlite_manager.go +++ b/pkg/auth/sqlite_manager.go @@ -10,8 +10,8 @@ import ( "time" "github.com/google/uuid" - _ "github.com/mattn/go-sqlite3" "github.com/rs/zerolog/log" + _ "modernc.org/sqlite" ) // SQLiteManagerConfig configures the SQLite RBAC manager. @@ -43,7 +43,7 @@ func NewSQLiteManager(cfg SQLiteManagerConfig) (*SQLiteManager, error) { dbPath := filepath.Join(rbacDir, "rbac.db") - db, err := sql.Open("sqlite3", dbPath) + db, err := sql.Open("sqlite", dbPath) if err != nil { return nil, fmt.Errorf("failed to open rbac database: %w", err) }