Skip to content

Commit 2ab8f49

Browse files
committed
Actually copy RuntimeConfig
Signed-off-by: David Gageot <david.gageot@docker.com>
1 parent bcdf6ea commit 2ab8f49

4 files changed

Lines changed: 45 additions & 8 deletions

File tree

e2e/proxy_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ func startRecordingAIProxy(t *testing.T) (*httptest.Server, *config.RuntimeConfi
7575
t.Cleanup(httpServer.Close)
7676

7777
return httpServer, &config.RuntimeConfig{
78-
ModelsGateway: httpServer.URL,
78+
Config: config.Config{
79+
ModelsGateway: httpServer.URL,
80+
},
7981
EnvProviderForTests: &testEnvProvider{
8082
environment.DockerDesktopTokenEnv: "DUMMY",
8183
},

pkg/config/runtime.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,24 @@ import (
88
)
99

1010
type RuntimeConfig struct {
11+
Config
12+
1113
EnvProviderForTests environment.Provider
12-
EnvFiles []string
13-
ModelsGateway string
14-
GlobalCodeMode bool
15-
WorkingDir string
14+
envProvider environment.Provider
15+
envProviderLock sync.Mutex
16+
}
1617

17-
envProvider environment.Provider
18-
envProviderLock sync.Mutex
18+
type Config struct {
19+
EnvFiles []string
20+
ModelsGateway string
21+
GlobalCodeMode bool
22+
WorkingDir string
23+
}
24+
25+
func (runConfig *RuntimeConfig) Clone() *RuntimeConfig {
26+
return &RuntimeConfig{
27+
Config: runConfig.Config,
28+
}
1929
}
2030

2131
func (runConfig *RuntimeConfig) EnvProvider() environment.Provider {

pkg/config/runtime_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package config
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestClone_ChangeWorkingDir(t *testing.T) {
10+
original := &RuntimeConfig{
11+
Config: Config{
12+
EnvFiles: []string{"file1.env", "file2.env"},
13+
ModelsGateway: "http://models.gateway",
14+
GlobalCodeMode: true,
15+
WorkingDir: "/app",
16+
},
17+
}
18+
19+
clone := original.Clone()
20+
original.WorkingDir = "/newapp"
21+
clone.WorkingDir = "/cloneapp"
22+
23+
assert.Equal(t, "/newapp", original.WorkingDir)
24+
assert.Equal(t, "/cloneapp", clone.WorkingDir)
25+
}

pkg/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,7 @@ func (s *Server) runAgent(c echo.Context) error {
11811181
p := addYamlExt(agentFilename)
11821182

11831183
// Copy runConfig and inject per-session working dir override
1184-
rc := s.runConfig
1184+
rc := s.runConfig.Clone()
11851185
rc.WorkingDir = sess.WorkingDir
11861186

11871187
// Load team - either reload from disk (local) or use in-memory team (OCI refs)

0 commit comments

Comments
 (0)