mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 06:16:58 +00:00
dedup & fix
This commit is contained in:
parent
3c0ee7e8a3
commit
a656335a22
7 changed files with 189 additions and 213 deletions
51
cmd/certs.go
51
cmd/certs.go
|
@ -31,32 +31,14 @@ var Certs = &cli.Command{
|
|||
Action: migrateCerts,
|
||||
},
|
||||
},
|
||||
Flags: []cli.Flag{
|
||||
// Cert Storage
|
||||
// TODO: remove in next version
|
||||
&cli.StringFlag{
|
||||
// DEPRICATED
|
||||
Name: "db-pogreb",
|
||||
Value: "key-database.pogreb",
|
||||
EnvVars: []string{"DB_POGREB"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "db-type",
|
||||
Value: "", // TODO: "sqlite3" in next version
|
||||
EnvVars: []string{"DB_TYPE"},
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "db-conn",
|
||||
Value: "certs.sqlite",
|
||||
EnvVars: []string{"DB_CONN"},
|
||||
},
|
||||
Flags: append(CertStorageFlags, []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "verbose",
|
||||
Usage: "print trace info",
|
||||
EnvVars: []string{"VERBOSE"},
|
||||
Value: false,
|
||||
},
|
||||
},
|
||||
}...),
|
||||
}
|
||||
|
||||
func migrateCerts(ctx *cli.Context) error {
|
||||
|
@ -148,32 +130,3 @@ func removeCert(ctx *cli.Context) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func openCertDB(ctx *cli.Context) (certDB database.CertDB, err error) {
|
||||
if ctx.String("db-type") != "" {
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
// TODO: remove in next version
|
||||
fmt.Println(`
|
||||
######################
|
||||
## W A R N I N G !!! #
|
||||
######################
|
||||
|
||||
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.
|
||||
|
||||
`)
|
||||
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 certDB, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue