Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions agent/app/service/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@
return exposedPorts
}

func searchWithFilter(req dto.PageContainer, containers []container.Summary) []dto.ContainerInfo {

Check failure on line 1702 in agent/app/service/container.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this method to reduce its Cognitive Complexity from 49 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=1Panel-dev_1Panel&issues=AZrZ5B3N2cCavPHEwgRC&open=AZrZ5B3N2cCavPHEwgRC&pullRequest=11144
var (
records []dto.ContainerInfo
list []container.Summary
Expand Down Expand Up @@ -1786,9 +1786,9 @@
}
records = append(records, info)
}
dscriptions, _ := settingRepo.GetDescriptionList(repo.WithByType("container"))
descriptions, _ := settingRepo.GetDescriptionList(repo.WithByType("container"))

Check failure on line 1789 in agent/app/service/container.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Handle this error explicitly or document why it can be safely ignored.

See more on https://sonarcloud.io/project/issues?id=1Panel-dev_1Panel&issues=AZrZ5B3N2cCavPHEwgRD&open=AZrZ5B3N2cCavPHEwgRD&pullRequest=11144
for i := 0; i < len(records); i++ {
for _, desc := range dscriptions {
for _, desc := range descriptions {
if desc.ID == records[i].ContainerID {
records[i].Description = desc.Description
records[i].IsPinned = desc.IsPinned
Expand Down
16 changes: 1 addition & 15 deletions agent/app/service/container_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"sort"
"strings"
"time"
"unicode"

"github.com/1Panel-dev/1Panel/agent/app/dto"
"github.com/1Panel-dev/1Panel/agent/buserr"
Expand Down Expand Up @@ -57,7 +56,7 @@ func (u *ContainerService) PageVolume(req dto.SearchWithPage) (int64, interface{
var volume dto.Volume
volume.Driver = item.Driver
volume.Mountpoint = item.Mountpoint
volume.Name = simplifyVolumeName(item.Name)
volume.Name = item.Name
for key, val := range item.Labels {
volume.Labels = append(volume.Labels, dto.VolumeOption{Key: key, Value: val})
}
Expand Down Expand Up @@ -143,16 +142,3 @@ func (u *ContainerService) CreateVolume(req dto.VolumeCreate) error {
}
return nil
}

func simplifyVolumeName(name string) string {
if len(name) != 64 {
return name
}

for _, char := range name {
if !unicode.Is(unicode.ASCII_Hex_Digit, char) {
return name
}
}
return name[:12]
}
13 changes: 6 additions & 7 deletions agent/app/service/cronjob_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"io"
"net/http"
"os"
"path"
pathUtils "path"
"path/filepath"
"strings"
Expand Down Expand Up @@ -147,7 +146,7 @@
if len(cronjob.ContainerName) != 0 {
scriptItem := cronjob.Script
if cronjob.ScriptMode == "select" {
scriptItem = path.Join("/tmp", path.Base(cronjob.Script))
scriptItem = pathUtils.Join("/tmp", pathUtils.Base(cronjob.Script))
if err := cmdMgr.Run("docker", "cp", cronjob.Script, cronjob.ContainerName+":"+scriptItem); err != nil {
return err
}
Expand Down Expand Up @@ -252,11 +251,11 @@
if appInstall.ID > 0 {
curStr := i18n.GetWithName("CleanLogByName", "OpenResty")
t.LogStart(curStr)
accessLogPath := path.Join(appInstall.GetPath(), "log", "access.log")
accessLogPath := pathUtils.Join(appInstall.GetPath(), "log", "access.log")

Check failure on line 254 in agent/app/service/cronjob_helper.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "access.log" 6 times.

See more on https://sonarcloud.io/project/issues?id=1Panel-dev_1Panel&issues=AZrZ5B8o2cCavPHEwgRF&open=AZrZ5B8o2cCavPHEwgRF&pullRequest=11144
if err := os.Truncate(accessLogPath, 0); err != nil {
t.LogFailedWithErr(curStr, err)
}
errLogPath := path.Join(appInstall.GetPath(), "log", "error.log")
errLogPath := pathUtils.Join(appInstall.GetPath(), "log", "error.log")

Check failure on line 258 in agent/app/service/cronjob_helper.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "error.log" 6 times.

See more on https://sonarcloud.io/project/issues?id=1Panel-dev_1Panel&issues=AZrZ5B8o2cCavPHEwgRE&open=AZrZ5B8o2cCavPHEwgRE&pullRequest=11144
if err := os.Truncate(errLogPath, 0); err != nil {
t.LogFailedWithErr(curStr, err)
}
Expand All @@ -274,8 +273,8 @@
if err != nil {
return err
}
ipGroupDir := path.Join(appInstall.GetPath(), "1pwaf", "data", "rules", "ip_group")
urlDir := path.Join(ipGroupDir, "ip_group_url")
ipGroupDir := pathUtils.Join(appInstall.GetPath(), "1pwaf", "data", "rules", "ip_group")
urlDir := pathUtils.Join(ipGroupDir, "ip_group_url")

urlsFiles, err := os.ReadDir(urlDir)
if err != nil {
Expand Down Expand Up @@ -471,7 +470,7 @@
}
_ = cronjobRepo.DeleteRecord(repo.WithByID(records[i].ID))
_ = taskRepo.Delete(taskRepo.WithByID(records[i].TaskID))
_ = os.Remove(path.Join(global.CONF.Base.InstallDir, "1panel/log/task/Cronjob", records[i].TaskID+".log"))
_ = os.Remove(pathUtils.Join(global.CONF.Base.InstallDir, "1panel/log/task/Cronjob", records[i].TaskID+".log"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/codemirror-pro/drawer.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<DrawerPro v-model="codeVisible" :header="header" size="large" @close="handleClose">
<CodemirrorPro v-model="detailInfo" :height-diff="160" :disabled="true" :mode="mode"></CodemirrorPro>
<CodemirrorPro v-model="detailInfo" :height-diff="160" :readonly="true" :mode="mode"></CodemirrorPro>
<template #footer>
<span class="dialog-footer">
<el-button @click="codeVisible = false">{{ $t('commons.button.cancel') }}</el-button>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/container/container/inspect/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
{{ $t('commons.button.copy') }}
</el-button>
</div>
<CodemirrorPro v-model="rawJson" :height-diff="240" :readonly="true" mode="json" />
<CodemirrorPro v-model="rawJson" :height-diff="270" :readonly="true" mode="json" />
</el-tab-pane>
</el-tabs>

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/container/network/detail/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
{{ $t('commons.button.copy') }}
</el-button>
</div>
<CodemirrorPro v-model="rawJson" :height-diff="240" :readonly="true" mode="json" />
<CodemirrorPro v-model="rawJson" :height-diff="270" :readonly="true" mode="json" />
</el-tab-pane>
</el-tabs>

Expand Down
Loading