Skip to content

Commit b6bb6b3

Browse files
committed
修复 compose override yaml 不能清空
1 parent de176a1 commit b6bb6b3

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ jobs:
268268
- name: Build
269269
run: |
270270
VERSION_TAG=${GITHUB_REF_NAME#v}
271-
make -C app/pro/tests/xk_open clean libxkopen.so
271+
make -C app/pro/tests/xk_open clean libxksssopen.so
272272
make clean-source
273273
make build PROJECT_NAME=dpanel-xk-amd64 FAMILY=xk CGO_ENABLED=1 VERSION=${VERSION_TAG}
274274
- name: upload artifact

app/application/http/controller/compose.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
http2 "net/http"
2626
"os"
2727
"path/filepath"
28+
"slices"
2829
"sort"
2930
"strings"
3031
"time"
@@ -120,13 +121,15 @@ func (self Compose) Create(http *gin.Context) {
120121
}
121122
}
122123

124+
overrideYamlFileName := "dpanel-override.yaml"
125+
if yamlRow.Setting.Type == accessor.ComposeTypeOutPath {
126+
// 外部 compose 的覆盖文件采用同名
127+
overrideYamlFileName = fmt.Sprintf("dpanel-%s-override.yaml", yamlRow.Name)
128+
}
129+
overrideYamlFilePath := filepath.Join(filepath.Dir(yamlRow.Setting.GetUriFilePath()), overrideYamlFileName)
130+
overrideRelPath, _ := filepath.Rel(yamlRow.Setting.GetWorkingDir(), overrideYamlFilePath)
131+
123132
if params.YamlOverride != "" {
124-
overrideYamlFileName := "dpanel-override.yaml"
125-
if yamlRow.Setting.Type == accessor.ComposeTypeOutPath {
126-
// 外部 compose 的覆盖文件采用同名
127-
overrideYamlFileName = fmt.Sprintf("dpanel-%s-override.yaml", yamlRow.Name)
128-
}
129-
overrideYamlFilePath := filepath.Join(filepath.Dir(yamlRow.Setting.GetUriFilePath()), overrideYamlFileName)
130133
err := os.MkdirAll(filepath.Dir(overrideYamlFilePath), os.ModePerm)
131134
if err != nil {
132135
self.JsonResponseWithError(http, err, 500)
@@ -137,11 +140,18 @@ func (self Compose) Create(http *gin.Context) {
137140
self.JsonResponseWithError(http, err, 500)
138141
return
139142
}
140-
141-
rel, _ := filepath.Rel(yamlRow.Setting.GetWorkingDir(), overrideYamlFilePath)
142-
if !function.InArray(yamlRow.Setting.Uri, rel) {
143-
yamlRow.Setting.Uri = append(yamlRow.Setting.Uri, rel)
143+
if !function.InArray(yamlRow.Setting.Uri, overrideRelPath) {
144+
yamlRow.Setting.Uri = append(yamlRow.Setting.Uri, overrideRelPath)
144145
}
146+
} else {
147+
err = os.Remove(overrideYamlFilePath)
148+
if err != nil {
149+
self.JsonResponseWithError(http, err, 500)
150+
return
151+
}
152+
yamlRow.Setting.Uri = slices.DeleteFunc(yamlRow.Setting.Uri, func(s string) bool {
153+
return s == overrideRelPath
154+
})
145155
}
146156

147157
if !function.IsEmptyArray(params.Environment) {

0 commit comments

Comments
 (0)