Plugins: drop the plugins.json migration, and the volume it needed
The project has no public installs, so there is nothing to migrate from. MigrateLegacyFile, the file-backed Store it read through, PLUGINS_FILE and the legacy path threaded through the Server all go. What is left is one store, PocketBase, and a plugins package that touches no filesystem at all. That was the last thing keeping api_data alive, so the volume goes too. All four compose files now declare exactly one volume, pb_data, and the standalone API Server compose declares none - it talks to an external PocketBase and has nothing of its own to keep. Backing up the stack is backing up one path again. Both images get simpler for it. The API Server image loses VOLUME /data and the su-exec entrypoint that existed only to fix a mounted volume's ownership, so it goes back to a plain USER app; its working directory is now /app and holds nothing. The AIO image loses its second volume and chowns only /pb/pb_data. One consequence worth stating plainly, because it is a small regression rather than a no-op. The panel's Settings -> PocketBase and Settings -> Web App screens write .env in the working directory, which is now ephemeral. In the multi-container stack that changes nothing: compose sets all five of those keys as container environment, and loadDotEnv only applies a key that is not already set, so the file could never win a restart there anyway. In the AIO image it did win for POCKETBASE_ADMIN_EMAIL/_PASSWORD, which are not in that container's environment - so a service account fixed from the panel now lasts only until the container is recreated. Both READMEs say so. Moving those two screens into the app_settings singleton would close it properly; the PocketBase URL and credentials cannot follow, since they are how the database is reached in the first place. go build, go vet and go test ./... pass; the compose files parse and each resolves to a single pb_data volume. Not verified: no Docker CLI here, so neither image was built. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
660af5736a
commit
ee4ac441be
@@ -159,12 +159,10 @@ type Server struct {
|
||||
pb *pb.Client
|
||||
plugins *plugins.Manager
|
||||
|
||||
// pluginStore is the Manager's backing store, kept here so the one-time
|
||||
// import of a legacy plugins.json can address it directly. legacyPlugins is
|
||||
// the path that import reads; pluginsStop ends the background load retry.
|
||||
pluginStore plugins.Store
|
||||
legacyPlugins string
|
||||
pluginsStop context.CancelFunc
|
||||
// pluginStore is the Manager's backing store; pluginsStop ends the
|
||||
// background load retry started by StartPlugins.
|
||||
pluginStore plugins.Store
|
||||
pluginsStop context.CancelFunc
|
||||
|
||||
// ocpp is the OCPP 1.6J Central System that Anker Solix chargers connect to
|
||||
// when their owner picks a control mode of own/proxy (see internal/ocpp and
|
||||
@@ -181,14 +179,13 @@ func New(cfg config.Config, client *pb.Client) *Server {
|
||||
// and user (L3) layers, rather than in a file beside the binary.
|
||||
store := plugins.NewPocketBaseStore(client, colAppSettings)
|
||||
return &Server{
|
||||
cfg: cfg,
|
||||
pb: client,
|
||||
pluginStore: store,
|
||||
legacyPlugins: cfg.PluginsFile,
|
||||
plugins: plugins.NewManager(store),
|
||||
ocpp: ocpp.NewCSMS(func(f string, a ...any) { log.Printf("ocpp: "+f, a...) }),
|
||||
control: newControlIndex(),
|
||||
ctlRL: newRateLimiter(30, time.Minute), // 30 control commands / min / charger
|
||||
cfg: cfg,
|
||||
pb: client,
|
||||
pluginStore: store,
|
||||
plugins: plugins.NewManager(store),
|
||||
ocpp: ocpp.NewCSMS(func(f string, a ...any) { log.Printf("ocpp: "+f, a...) }),
|
||||
control: newControlIndex(),
|
||||
ctlRL: newRateLimiter(30, time.Minute), // 30 control commands / min / charger
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +231,7 @@ func (s *Server) StartPlugins() error {
|
||||
// create just that one collection — not a full schema reconcile, which an
|
||||
// operator who turned the bootstrap off has not asked for — and read again.
|
||||
func (s *Server) loadPlugins(ctx context.Context) error {
|
||||
err := s.readPlugins(ctx)
|
||||
err := s.plugins.Load(ctx)
|
||||
if err == nil || !plugins.IsMissingCollection(err) {
|
||||
return err
|
||||
}
|
||||
@@ -245,20 +242,6 @@ func (s *Server) loadPlugins(ctx context.Context) error {
|
||||
return err // report the original problem, not the repair's
|
||||
}
|
||||
log.Printf("plugins: created %s", colAppSettings)
|
||||
return s.readPlugins(ctx)
|
||||
}
|
||||
|
||||
// readPlugins imports a pre-PocketBase plugins.json if one is still lying around
|
||||
// and the database holds no settings yet, then reads the settings.
|
||||
func (s *Server) readPlugins(ctx context.Context) error {
|
||||
switch migrated, err := plugins.MigrateLegacyFile(ctx, s.pluginStore, s.legacyPlugins); {
|
||||
case err != nil:
|
||||
// Not fatal: the read below reports the real problem if there is one.
|
||||
log.Printf("plugins: legacy import skipped: %v", err)
|
||||
case migrated:
|
||||
log.Printf("plugins: imported %s into PocketBase; renamed it to %s.migrated",
|
||||
s.legacyPlugins, s.legacyPlugins)
|
||||
}
|
||||
return s.plugins.Load(ctx)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user