Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] SQLite support #78

Open
lonix1 opened this issue Jun 3, 2022 · 5 comments
Open

[Feature Request] SQLite support #78

lonix1 opened this issue Jun 3, 2022 · 5 comments

Comments

@lonix1
Copy link

lonix1 commented Jun 3, 2022

I see postgres is supported.

Is sqlite supported? Or any others?

@stuartskelton
Copy link

Hi,

I was looking around myself it seems there is a keydb.NewSQLDB() where you can pass it a sqlite or mysql connection.

Looking at TestSQLite in server/keydb/keydb_test.go

Hope that helped

-S

@lonix1
Copy link
Author

lonix1 commented Jun 11, 2022

Unfortunately only go devs could do that :) Was hoping for something that doesn't require coding. But it is good to know that it's somehow possible. Thanks

@stuartskelton
Copy link

well yeah there is a little bit of coding, but updating the server_dev file to use keydb.NewSQLDB() instead of keydb.TempDB(), isn't much of a stretch.

If you want to test it out here is a little diff.

diff --git a/cmd/dev_server/main.go b/cmd/dev_server/main.go
index b4d11c7..e909434 100644
--- a/cmd/dev_server/main.go
+++ b/cmd/dev_server/main.go
@@ -7,6 +7,7 @@ import (
        "crypto/tls"
        "crypto/x509"
        "crypto/x509/pkix"
+       "database/sql"
        "encoding/pem"
        "expvar"
        "flag"
@@ -16,6 +17,8 @@ import (
        "os"
        "time"

+       _ "github.com/mattn/go-sqlite3"
+
        "github.com/pinterest/knox"
        "github.com/pinterest/knox/log"
        "github.com/pinterest/knox/server"
@@ -62,8 +65,14 @@ func main() {
                errLogger.Fatal("Failed to make TLS key or cert: ", err)
        }

-       db := keydb.NewTempDB()
-
+       d, err := sql.Open("sqlite3", "foo.db")
+       if err != nil {
+               errLogger.Fatal(err)
+       }
+       db, err := keydb.NewSQLDB(d)
+       if err != nil {
+               errLogger.Fatal(err)
+       }
        server.AddDefaultAccess(&knox.Access{
                Type:       knox.UserGroup,
                ID:         "security-team",

@lonix1
Copy link
Author

lonix1 commented Jun 11, 2022

Thanks @stuartskelton! From your code it indeed looks like a simple change.

@lonix1
Copy link
Author

lonix1 commented Jun 11, 2022

Mods: may I thus change this issue from a question to a feature request for SQLite support?

A small, simple and dockerised secrets tool - which uses sqlite - would be a gamechanger in this area.

Please consider it? Thanks!

@lonix1 lonix1 changed the title Backend databases [Feature Request] SQLite support Jun 11, 2022
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

No branches or pull requests

2 participants