Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: add podman-compose file support (#1728)
Bastien Grignon51a1b050ad46
diff --git a/backend/internal/utils/fs/fs_writer.go b/backend/internal/utils/fs/fs_writer.goindex 93041de9b..30d72edfd 100644--- a/backend/internal/utils/fs/fs_writer.go+++ b/backend/internal/utils/fs/fs_writer.go@@ -13,6 +13,8 @@ var composeFileCandidates = []string{"compose.yml","docker-compose.yaml","docker-compose.yml",+ "podman-compose.yaml",+ "podman-compose.yml",}// detectExistingComposeFile finds an existing compose file in the directorydiff --git a/backend/internal/utils/fs/fs_writer_test.go b/backend/internal/utils/fs/fs_writer_test.goindex f42c9f317..51bc0675d 100644--- a/backend/internal/utils/fs/fs_writer_test.go+++ b/backend/internal/utils/fs/fs_writer_test.go@@ -101,3 +101,38 @@ func TestWriteProjectFiles(t *testing.T) {assert.Equal(t, newContent, string(content))})}++func TestWriteComposeFile_PreservesExistingPodmanComposeNames(t *testing.T) {+ testCases := []struct {+ name string+ fileName string+ }{+ {name: "podman-compose.yaml", fileName: "podman-compose.yaml"},+ {name: "podman-compose.yml", fileName: "podman-compose.yml"},+ }++ for _, tc := range testCases {+ t.Run(tc.name, func(t *testing.T) {+ t.Parallel()++ tmpDir := t.TempDir()+ projectsRoot := tmpDir+ projectDir := filepath.Join(tmpDir, "test-project")+ require.NoError(t, os.MkdirAll(projectDir, 0o755))++ existingComposePath := filepath.Join(projectDir, tc.fileName)+ require.NoError(t, os.WriteFile(existingComposePath, []byte("services: {}"), 0o600))++ expectedContent := "services:\n app:\n image: nginx:alpine\n"+ err := WriteComposeFile(projectsRoot, projectDir, expectedContent)+ require.NoError(t, err)++ actualContent, err := os.ReadFile(existingComposePath)+ require.NoError(t, err)+ assert.Equal(t, expectedContent, string(actualContent))++ _, err = os.Stat(filepath.Join(projectDir, "compose.yaml"))+ assert.True(t, os.IsNotExist(err), "compose.yaml should not be created when existing podman-compose file is present")+ })+ }+}diff --git a/backend/internal/utils/fs/watcher.go b/backend/internal/utils/fs/watcher.goindex 22e5e743f..9c8f4c96a 100644--- a/backend/internal/utils/fs/watcher.go+++ b/backend/internal/utils/fs/watcher.go@@ -217,6 +217,8 @@ func IsProjectFile(filename string) bool {"compose.yml","docker-compose.yaml","docker-compose.yml",+ "podman-compose.yaml",+ "podman-compose.yml",".env",}diff --git a/backend/pkg/projects/load.go b/backend/pkg/projects/load.goindex dd45cf1fc..ffbb7511e 100644--- a/backend/pkg/projects/load.go+++ b/backend/pkg/projects/load.go@@ -18,6 +18,8 @@ var ComposeFileCandidates = []string{"compose.yml","docker-compose.yaml","docker-compose.yml",+ "podman-compose.yaml",+ "podman-compose.yml",}func locateComposeFile(dir string) string {diff --git a/backend/pkg/projects/load_test.go b/backend/pkg/projects/load_test.gonew file mode 100644index 000000000..043f80650--- /dev/null+++ b/backend/pkg/projects/load_test.go@@ -0,0 +1,76 @@+package projects++import (+ "context"+ "os"+ "path/filepath"+ "testing"++ "github.com/stretchr/testify/assert"+ "github.com/stretchr/testify/require"+)++func TestDetectComposeFile_SupportsPodmanComposeNames(t *testing.T) {+ t.Parallel()++ composeContent := "services:\n app:\n image: nginx:alpine\n"++ testCases := []struct {+ name string+ fileName string+ }{+ {name: "podman-compose.yaml", fileName: "podman-compose.yaml"},+ {name: "podman-compose.yml", fileName: "podman-compose.yml"},+ }++ for _, tc := range testCases {+ t.Run(tc.name, func(t *testing.T) {+ t.Parallel()++ dir := t.TempDir()+ expectedPath := filepath.Join(dir, tc.fileName)+ require.NoError(t, os.WriteFile(expectedPath, []byte(composeContent), 0o600))++ composePath, err := DetectComposeFile(dir)+ require.NoError(t, err)+ assert.Equal(t, expectedPath, composePath)+ })+ }+}++func TestLoadComposeProjectFromDir_SupportsPodmanComposeNames(t *testing.T) {+ composeContent := "services:\n app:\n image: nginx:alpine\n"++ testCases := []struct {+ name string+ fileName string+ }{+ {name: "podman-compose.yaml", fileName: "podman-compose.yaml"},+ {name: "podman-compose.yml", fileName: "podman-compose.yml"},+ }++ for _, tc := range testCases {+ t.Run(tc.name, func(t *testing.T) {+ t.Parallel()++ dir := t.TempDir()+ expectedPath := filepath.Join(dir, tc.fileName)+ require.NoError(t, os.WriteFile(expectedPath, []byte(composeContent), 0o600))++ project, composePath, err := LoadComposeProjectFromDir(+ context.Background(),+ dir,+ "podman-project",+ filepath.Dir(dir),+ false,+ nil,+ )+ require.NoError(t, err)+ require.NotNil(t, project)++ assert.Equal(t, expectedPath, composePath)+ assert.Equal(t, []string{expectedPath}, project.ComposeFiles)+ assert.NotEmpty(t, project.Services)+ })+ }+}