mirror of
https://github.com/qdm12/gluetun.git
synced 2026-05-07 04:20:12 +02:00
25f67cd170
- new directory structure containing manifest.json and one json file per provider, by default. - the manifest.json file can specify a filepath for each vpn provider - each vpn provider json data file can contain the `"preferred": true` field to enforce it is used even if outdated, unless there is a version mismatch - `STORAGE_SERVERS_DIRECTORY_PATH` replaces `STORAGE_FILEPATH` (which is now a migration source only). It sets the directory where server manifest and per-provider JSON files are stored (default: `/gluetun/servers/`). - First-run migration: On startup, gluetun checks for the old /gluetun/servers.json file; if found and no new manifest exists, it automatically migrates all data to /gluetun/servers/ directory structure - Silent fallback: If legacy file isn't found, uses the new directory path normally - Legacy cleanup: After successful migration, attempts to remove the old fat JSON file (logs warning only if removal fails, e.g., read-only bind mounts) Co-authored-by: Copilot <copilot@github.com>
40 lines
1.0 KiB
Go
40 lines
1.0 KiB
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/qdm12/gluetun/internal/configuration/settings"
|
|
"github.com/qdm12/gluetun/internal/configuration/sources/files"
|
|
"github.com/qdm12/gluetun/internal/configuration/sources/secrets"
|
|
"github.com/qdm12/gluetun/internal/storage"
|
|
"github.com/qdm12/gosettings/reader"
|
|
"github.com/qdm12/gosettings/reader/sources/env"
|
|
)
|
|
|
|
type storageSetupLogger interface {
|
|
storage.Logger
|
|
files.Warner
|
|
}
|
|
|
|
func setupStorage(logger storageSetupLogger) (s *storage.Storage, err error) {
|
|
settingsReader := reader.New(reader.Settings{
|
|
Sources: []reader.Source{
|
|
secrets.New(logger),
|
|
files.New(logger),
|
|
env.New(env.Settings{}),
|
|
},
|
|
})
|
|
var settings settings.Storage
|
|
err = settings.Read(settingsReader)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("reading storage settings: %w", err)
|
|
}
|
|
settings.SetDefaults()
|
|
storage, err := storage.New(logger, *settings.ServersPath,
|
|
*settings.LegacyServersFilepath)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("creating storage: %w", err)
|
|
}
|
|
return storage, nil
|
|
}
|