This commit is contained in:
@@ -26,7 +26,7 @@ type Config struct {
|
||||
Addr string
|
||||
TemplatesDir string
|
||||
StaticDir string
|
||||
DatabasePath string // Path to SQLite database (empty = in-memory mode)
|
||||
DatabaseConn string // Database connection string (SQLite path or PostgreSQL connection string, empty = in-memory mode)
|
||||
}
|
||||
|
||||
type App struct {
|
||||
@@ -103,8 +103,8 @@ func New(cfg Config) (*App, error) {
|
||||
|
||||
// Initialize database (optional)
|
||||
var database *db.DB
|
||||
if cfg.DatabasePath != "" {
|
||||
dbConn, err := db.New(cfg.DatabasePath)
|
||||
if cfg.DatabaseConn != "" {
|
||||
dbConn, err := db.New(cfg.DatabaseConn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init database: %w", err)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (a *App) handleCreateBackup(w http.ResponseWriter, r *http.Request) {
|
||||
ISCSITargets: a.iscsiStore.List(),
|
||||
Policies: a.snapshotPolicy.List(),
|
||||
Config: map[string]interface{}{
|
||||
"database_path": a.cfg.DatabasePath,
|
||||
"database_conn": a.cfg.DatabaseConn,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ func (a *App) handleSystemInfo(w http.ResponseWriter, r *http.Request) {
|
||||
if a.database != nil {
|
||||
info.Database = DatabaseInfo{
|
||||
Connected: true,
|
||||
Path: a.cfg.DatabasePath,
|
||||
Path: a.cfg.DatabaseConn,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ func (a *App) handleEnableMaintenance(w http.ResponseWriter, r *http.Request) {
|
||||
ISCSITargets: a.iscsiStore.List(),
|
||||
Policies: a.snapshotPolicy.List(),
|
||||
Config: map[string]interface{}{
|
||||
"database_path": a.cfg.DatabasePath,
|
||||
"database_conn": a.cfg.DatabaseConn,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user