mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-24 13:56:57 +00:00
fix lint issues
This commit is contained in:
parent
a656335a22
commit
1c5561231b
4 changed files with 21 additions and 15 deletions
|
@ -85,10 +85,11 @@ func migrateCerts(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
func listCerts(ctx *cli.Context) error {
|
||||
certDB, err := openCertDB(ctx)
|
||||
certDB, close, err := openCertDB(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer close()
|
||||
|
||||
items, err := certDB.Items(0, 0)
|
||||
if err != nil {
|
||||
|
@ -114,10 +115,11 @@ func removeCert(ctx *cli.Context) error {
|
|||
|
||||
domains := ctx.Args().Slice()
|
||||
|
||||
certDB, err := openCertDB(ctx)
|
||||
certDB, close, err := openCertDB(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer close()
|
||||
|
||||
for _, domain := range domains {
|
||||
fmt.Printf("Removing domain %s from the database...\n", domain)
|
||||
|
@ -125,8 +127,5 @@ func removeCert(ctx *cli.Context) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if err := certDB.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -74,8 +74,11 @@ func Serve(ctx *cli.Context) error {
|
|||
}
|
||||
|
||||
// Init ssl cert database
|
||||
certDB, err := openCertDB(ctx)
|
||||
defer certDB.Close()
|
||||
certDB, close, err := openCertDB(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer close()
|
||||
|
||||
keyCache := cache.NewKeyValueCache()
|
||||
challengeCache := cache.NewKeyValueCache()
|
||||
|
|
19
cmd/setup.go
19
cmd/setup.go
|
@ -9,12 +9,12 @@ import (
|
|||
"codeberg.org/codeberg/pages/server/database"
|
||||
)
|
||||
|
||||
func openCertDB(ctx *cli.Context) (certDB database.CertDB, err error) {
|
||||
func openCertDB(ctx *cli.Context) (certDB database.CertDB, close func(), err error) {
|
||||
if ctx.String("db-type") != "" {
|
||||
log.Trace().Msg("use xorm mode")
|
||||
certDB, err = database.NewXormDB(ctx.String("db-type"), ctx.String("db-conn"))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not connect to database: %w", err)
|
||||
return nil, nil, fmt.Errorf("could not connect to database: %w", err)
|
||||
}
|
||||
} else {
|
||||
// TODO: remove in next version
|
||||
|
@ -26,15 +26,20 @@ func openCertDB(ctx *cli.Context) (certDB database.CertDB, err error) {
|
|||
You use "pogreb" witch is deprecated and will be removed in the next version.
|
||||
Please switch to sqlite, mysql or postgres !!!
|
||||
|
||||
The simplest way is, to use './pages certs migrate' and set environment var DB_TYPE to 'sqlite' on next start.
|
||||
|
||||
`)
|
||||
The simplest way is, to use './pages certs migrate' and set environment var DB_TYPE to 'sqlite' on next start.`)
|
||||
log.Error().Msg("depricated \"pogreb\" used\n")
|
||||
|
||||
certDB, err = database.NewPogreb(ctx.String("db-pogreb"))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not create database: %w", err)
|
||||
return nil, nil, fmt.Errorf("could not create database: %w", err)
|
||||
}
|
||||
}
|
||||
return certDB, nil
|
||||
|
||||
close = func() {
|
||||
if err := certDB.Close(); err != nil {
|
||||
log.Error().Err(err)
|
||||
}
|
||||
}
|
||||
|
||||
return certDB, close, nil
|
||||
}
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
package database
|
Loading…
Add table
Add a link
Reference in a new issue