Skip to content

Commit 1ca54cf

Browse files
committed
修复 标准版申请证书时使用 Nginx 方式不成功
修复 标准版申请证书或是上传证书列表不显示 修复 多个服务端共享 Compose 目录数据没有显示 修复 查看镜像内的文件列表数据错误及没有显示目录 修复 拉取镜像时选择仓库无效
1 parent 980af3c commit 1ca54cf

38 files changed

+155
-65
lines changed

.github/workflows/download_docker_cli.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ jobs:
1515
1616
URL=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | jq -r '.assets[] | select(.name == "docker-compose-windows-x86_64.exe") | .browser_download_url')
1717
wget "$URL"
18+
19+
curl -L -o fnpack https://static2.fnnas.com/fnpack/fnpack-1.0.1-linux-amd64
1820
- name: Create Release
1921
if: always()
2022
uses: softprops/action-gh-release@v2
@@ -25,6 +27,7 @@ jobs:
2527
files: |
2628
docker-windows-x86_64.exe
2729
docker-compose-windows-x86_64.exe
30+
fnpack
2831
draft: false
2932
prerelease: false
3033
make_latest: false

app/application/http/controller/image-tag.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/donknap/dpanel/app/application/logic"
1313
"github.com/donknap/dpanel/common/function"
1414
"github.com/donknap/dpanel/common/service/docker"
15-
"github.com/donknap/dpanel/common/service/notice"
1615
"github.com/donknap/dpanel/common/service/registry"
1716
"github.com/donknap/dpanel/common/service/ws"
1817
"github.com/donknap/dpanel/common/types/define"
@@ -89,10 +88,6 @@ func (self Image) TagSync(http *gin.Context) {
8988
return
9089
}
9190

92-
if params.Type == "pull" {
93-
_ = notice.Message{}.Info(".imagePull", "name", imageNameDetail.Uri())
94-
}
95-
9691
err = logic.DockerTask{}.ImageRemote(wsBuffer, out)
9792
if err != nil {
9893
self.JsonResponseWithError(http, err, 500)

app/application/logic/compose.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,7 @@ func (self Compose) LsItem(name string) *compose.ProjectResult {
218218
}
219219

220220
// FindPathTask 查询 docker 环境下 compose 目录下的所有任务
221-
func (self Compose) FindPathTask(dockerEnvName string) map[string]*entity.Compose {
222-
var rootDir string
223-
if dockerEnvName == docker.DefaultClientName {
224-
rootDir = storage.Local{}.GetComposePath("")
225-
} else {
226-
rootDir = storage.Local{}.GetComposePath(dockerEnvName)
227-
}
228-
221+
func (self Compose) FindPathTask(rootDir string) map[string]*entity.Compose {
229222
if _, err := os.Stat(rootDir); err != nil {
230223
slog.Error("compose sync path not found", "error", err)
231224
return make(map[string]*entity.Compose)
@@ -265,7 +258,7 @@ func (self Compose) FindPathTask(dockerEnvName string) map[string]*entity.Compos
265258
Uri: []string{
266259
relYamlFilePath,
267260
},
268-
DockerEnvName: dockerEnvName,
261+
DockerEnvName: docker.Sdk.Name,
269262
},
270263
}
271264
findComposeList[name] = findRow
@@ -278,7 +271,17 @@ func (self Compose) FindPathTask(dockerEnvName string) map[string]*entity.Compos
278271

279272
// Sync 同步当前挂载目录中的 compose
280273
func (self Compose) Sync(dockerEnvName string) error {
281-
findComposeList := self.FindPathTask(dockerEnvName)
274+
dockerEnv, err := logic.DockerEnv{}.GetEnvByName(dockerEnvName)
275+
if err != nil {
276+
return err
277+
}
278+
var rootDir string
279+
if dockerEnv.EnableComposePath {
280+
rootDir = storage.Local{}.GetComposePath(dockerEnvName)
281+
} else {
282+
rootDir = storage.Local{}.GetComposePath("")
283+
}
284+
findComposeList := self.FindPathTask(rootDir)
282285

283286
// 循环任务,添加,清理任务
284287
composeList, _ := dao.Compose.Find()

app/application/logic/docker-image-task.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ func (self DockerTask) ImageBuild(messageId string, task accessor.ImageSettingOp
9292
}
9393

9494
func (self DockerTask) ImageRemote(w *ws.ProgressPip, r io.ReadCloser) error {
95+
if r == nil {
96+
return function.ErrorMessage(define.ErrorMessageImagePullRegistryBad)
97+
}
9598
lastSendTime := time.Now()
9699
pg := make(map[string]*docker.PullProgress)
97100

app/common/http/controller/home.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ type Home struct {
5959

6060
func (self Home) Index(http *gin.Context) {
6161
uri := http.Request.URL.String()
62-
slog.Debug("http route not found", "uri", uri)
62+
slog.Debug("http route not found", "ip", http.ClientIP(), "user-agent", http.Request.Header.Get("User-Agent"), "uri", uri)
6363
var asset embed.FS
6464
if v, ok := http.Get("asset"); !ok {
6565
self.JsonResponseWithError(http, errors.New("fatal error, resource file not found, please recompile"), 500)

app/common/http/controller/store.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,20 @@ func (self Store) Sync(http *gin.Context) {
207207
return
208208
}
209209
} else if params.Type == accessor.StoreTypePortainer {
210-
err = logic.Store{}.SyncByJson(storeRootPath, params.Url)
210+
jsonPath := filepath.Join(storeRootPath, "template.json")
211+
err = logic.Store{}.SyncByJson(jsonPath, params.Url)
212+
if err != nil {
213+
self.JsonResponseWithError(http, err, 500)
214+
return
215+
}
216+
} else if params.Type == accessor.StoreTypeBaota {
217+
jsonPath := filepath.Join(storeRootPath, "apps.json")
218+
err = logic.Store{}.SyncByJson(jsonPath, params.Url)
219+
if err != nil {
220+
self.JsonResponseWithError(http, err, 500)
221+
return
222+
}
223+
appList, err = logic.Store{}.GetAppByBaoTa(params.Name)
211224
if err != nil {
212225
self.JsonResponseWithError(http, err, 500)
213226
return

app/common/logic/store-baota.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package logic
2+
3+
import (
4+
"encoding/json"
5+
"os"
6+
"path/filepath"
7+
8+
"github.com/donknap/dpanel/common/accessor"
9+
"github.com/donknap/dpanel/common/function"
10+
"github.com/donknap/dpanel/common/service/storage"
11+
"gopkg.in/yaml.v3"
12+
)
13+
14+
func (self Store) GetAppByBaoTa(storePath string) ([]accessor.StoreAppItem, error) {
15+
if !filepath.IsAbs(storePath) {
16+
storePath = filepath.Join(storage.Local{}.GetStorePath(), storePath)
17+
}
18+
content, err := os.ReadFile(filepath.Join(storePath, "apps.json"))
19+
if err != nil {
20+
return nil, err
21+
}
22+
var jsonData []interface{}
23+
err = json.Unmarshal(content, &jsonData)
24+
if err != nil {
25+
return nil, err
26+
}
27+
result := make([]accessor.StoreAppItem, 0)
28+
for _, item := range jsonData {
29+
itemData, err := yaml.Marshal(item)
30+
if err != nil {
31+
continue
32+
}
33+
config := new(function.ConfigMap)
34+
err = yaml.Unmarshal(itemData, &config)
35+
if err != nil {
36+
continue
37+
}
38+
storeItem := accessor.StoreAppItem{
39+
Name: config.GetString("appname"),
40+
Title: config.GetString("apptitle"),
41+
}
42+
result = append(result, storeItem)
43+
}
44+
return result, nil
45+
}

app/common/logic/store.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,9 @@ func (self Store) SyncByZip(path, zipUrl string, root string) error {
139139
return nil
140140
}
141141

142-
func (self Store) SyncByJson(path, jsonUrl string) error {
143-
file, err := os.OpenFile(filepath.Join(path, "template.json"), os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0666)
142+
func (self Store) SyncByJson(jsonPath, jsonUrl string) error {
143+
_ = os.MkdirAll(filepath.Dir(jsonPath), os.ModePerm)
144+
file, err := os.OpenFile(jsonPath, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0666)
144145
defer func() {
145146
_ = file.Close()
146147
}()

app/pro

Submodule pro updated from 18b13bb to 702ed81
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)