From 5f91d4bed5eef3469ff9e2fe0f5423cf54bcf758 Mon Sep 17 00:00:00 2001 From: Maksim Nabokikh Date: Mon, 11 Aug 2025 14:57:54 +0300 Subject: [PATCH] Allow compilation without CGO (#4266) `ent` driver gives a normal error if the binary is compiled without CGO, but with our custom SQL driver Dex just fails to compile. ``` # github.com/dexidp/dex/cmd/dex cmd/dex/config.go:273:26: undefined: sql.SQLite3 cmd/dex/config.go:315:43: undefined: sql.SQLite3 ``` Signed-off-by: Maksim Nabokikh Signed-off-by: Maksim Nabokikh Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- storage/sql/sqlite_no_cgo.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 storage/sql/sqlite_no_cgo.go diff --git a/storage/sql/sqlite_no_cgo.go b/storage/sql/sqlite_no_cgo.go new file mode 100644 index 00000000..80d14108 --- /dev/null +++ b/storage/sql/sqlite_no_cgo.go @@ -0,0 +1,19 @@ +//go:build !cgo +// +build !cgo + +// This is a stub for the no CGO compilation (CGO_ENABLED=0) + +package sql + +import ( + "fmt" + "log/slog" + + "github.com/dexidp/dex/storage" +) + +type SQLite3 struct{} + +func (s *SQLite3) Open(logger *slog.Logger) (storage.Storage, error) { + return nil, fmt.Errorf("SQLite storage is not available: binary compiled without CGO support. Recompile with CGO_ENABLED=1 or use a different storage backend.") +}