@@ -12,6 +12,7 @@ import (
1212 "github.com/docker/mcp-gateway/pkg/db"
1313 "github.com/docker/mcp-gateway/pkg/docker"
1414 "github.com/docker/mcp-gateway/pkg/log"
15+ "github.com/docker/mcp-gateway/pkg/migrate"
1516 "github.com/docker/mcp-gateway/pkg/oci"
1617 "github.com/docker/mcp-gateway/pkg/workingset"
1718)
@@ -31,7 +32,15 @@ func NewWorkingSetConfiguration(workingSet string, ociService oci.Service, docke
3132}
3233
3334func (c * WorkingSetConfiguration ) Read (ctx context.Context ) (Configuration , chan Configuration , func () error , error ) {
34- configuration , err := c .readOnce (ctx )
35+ dao , err := db .New ()
36+ if err != nil {
37+ return Configuration {}, nil , nil , fmt .Errorf ("failed to create database client: %w" , err )
38+ }
39+
40+ // Do migration from legacy files
41+ migrate .MigrateConfig (ctx , c .docker , dao )
42+
43+ configuration , err := c .readOnce (ctx , dao )
3544 if err != nil {
3645 return Configuration {}, nil , nil , err
3746 }
@@ -42,15 +51,10 @@ func (c *WorkingSetConfiguration) Read(ctx context.Context) (Configuration, chan
4251 return configuration , updates , func () error { return nil }, nil
4352}
4453
45- func (c * WorkingSetConfiguration ) readOnce (ctx context.Context ) (Configuration , error ) {
54+ func (c * WorkingSetConfiguration ) readOnce (ctx context.Context , dao db. DAO ) (Configuration , error ) {
4655 start := time .Now ()
4756 log .Log ("- Reading profile configuration..." )
4857
49- dao , err := db .New ()
50- if err != nil {
51- return Configuration {}, fmt .Errorf ("failed to create database client: %w" , err )
52- }
53-
5458 dbWorkingSet , err := dao .GetWorkingSet (ctx , c .WorkingSet )
5559 if err != nil {
5660 if errors .Is (err , sql .ErrNoRows ) {
0 commit comments