diff --git a/pkg/libstack/compose/composeplugin.go b/pkg/libstack/compose/composeplugin.go index 437513b2b..f5d2addc8 100644 --- a/pkg/libstack/compose/composeplugin.go +++ b/pkg/libstack/compose/composeplugin.go @@ -14,6 +14,7 @@ import ( "github.com/distribution/reference" portainer "github.com/portainer/portainer/api" + "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/api/logs" "github.com/portainer/portainer/pkg/libstack" retry "github.com/portainer/portainer/pkg/retry" @@ -476,7 +477,7 @@ func createProject(ctx context.Context, configFilepaths []string, options libsta for i, service := range project.Services { for j, envFile := range service.EnvFiles { if !filepath.IsAbs(envFile.Path) { - project.Services[i].EnvFiles[j].Path = filepath.Join(workingDir, envFile.Path) + project.Services[i].EnvFiles[j].Path = filesystem.JoinPaths(workingDir, envFile.Path) } } } diff --git a/pkg/libstack/swarm/swarm_integration_test.go b/pkg/libstack/swarm/swarm_integration_test.go index ed1460736..a241707c4 100644 --- a/pkg/libstack/swarm/swarm_integration_test.go +++ b/pkg/libstack/swarm/swarm_integration_test.go @@ -3,13 +3,13 @@ package swarm import ( "context" "os" - "path/filepath" "testing" "time" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" "github.com/docker/docker/client" + "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/pkg/libstack" "github.com/stretchr/testify/require" ) @@ -69,7 +69,7 @@ func serviceExists(t *testing.T, apiClient client.APIClient, stackName, serviceN func createComposeFile(t *testing.T, dir, name, content string) string { t.Helper() - path := filepath.Join(dir, name) + path := filesystem.JoinPaths(dir, name) require.NoError(t, os.WriteFile(path, []byte(content), 0o644)) return path diff --git a/pkg/libstack/swarm/swarm_status_test.go b/pkg/libstack/swarm/swarm_status_test.go index 5595fbd37..0a6bdf2bf 100644 --- a/pkg/libstack/swarm/swarm_status_test.go +++ b/pkg/libstack/swarm/swarm_status_test.go @@ -4,10 +4,10 @@ import ( "context" "fmt" "os" - "path/filepath" "testing" "time" + "github.com/portainer/portainer/api/filesystem" libstack "github.com/portainer/portainer/pkg/libstack" "github.com/stretchr/testify/require" ) @@ -59,7 +59,7 @@ services: projectName := testCase.TestName composeFileName := fmt.Sprintf("docker-compose-%s.yml", projectName) - composeFilePath := filepath.Join(dir, composeFileName) + composeFilePath := filesystem.JoinPaths(dir, composeFileName) f, err := os.Create(composeFilePath) require.NoError(t, err, "failed to create compose file") diff --git a/pkg/libstack/swarm/swarm_unit_test.go b/pkg/libstack/swarm/swarm_unit_test.go index d0f0cf75d..7f7bd830a 100644 --- a/pkg/libstack/swarm/swarm_unit_test.go +++ b/pkg/libstack/swarm/swarm_unit_test.go @@ -2,7 +2,6 @@ package swarm import ( "os" - "path/filepath" "slices" "testing" @@ -10,6 +9,7 @@ import ( configtypes "github.com/docker/cli/cli/config/types" "github.com/docker/docker/api/types/swarm" dockerregistry "github.com/docker/docker/registry" + "github.com/portainer/portainer/api/filesystem" "github.com/portainer/portainer/pkg/libstack" "github.com/stretchr/testify/require" ) @@ -215,7 +215,7 @@ func Test_getConfig(t *testing.T) { dir := t.TempDir() writeFile := func(name, content string) string { - path := filepath.Join(dir, name) + path := filesystem.JoinPaths(dir, name) require.NoError(t, os.WriteFile(path, []byte(content), 0o644)) return path }