mirror of https://github.com/1Panel-dev/1Panel
fix: 处理代码警告 (#2756)
parent
0b67c8dfc9
commit
00cad5b586
|
@ -19,6 +19,7 @@ import (
|
|||
"github.com/1Panel-dev/1Panel/backend/global"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/docker"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/registry"
|
||||
"github.com/docker/docker/pkg/archive"
|
||||
)
|
||||
|
||||
|
@ -239,7 +240,7 @@ func (u *ImageService) ImagePull(req dto.ImagePull) (string, error) {
|
|||
}
|
||||
options := types.ImagePullOptions{}
|
||||
if repo.Auth {
|
||||
authConfig := types.AuthConfig{
|
||||
authConfig := registry.AuthConfig{
|
||||
Username: repo.Username,
|
||||
Password: repo.Password,
|
||||
}
|
||||
|
@ -336,7 +337,7 @@ func (u *ImageService) ImagePush(req dto.ImagePush) (string, error) {
|
|||
}
|
||||
options := types.ImagePushOptions{}
|
||||
if repo.Auth {
|
||||
authConfig := types.AuthConfig{
|
||||
authConfig := registry.AuthConfig{
|
||||
Username: repo.Username,
|
||||
Password: repo.Password,
|
||||
}
|
||||
|
|
|
@ -98,11 +98,12 @@ func RandStr(n int) string {
|
|||
}
|
||||
|
||||
func RandStrAndNum(n int) string {
|
||||
mathRand.Seed(time.Now().UnixNano())
|
||||
source := mathRand.NewSource(time.Now().UnixNano())
|
||||
randGen := mathRand.New(source)
|
||||
const charset = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||
b := make([]byte, 10)
|
||||
b := make([]byte, n)
|
||||
for i := range b {
|
||||
b[i] = charset[mathRand.Int63()%int64(len(charset))]
|
||||
b[i] = charset[randGen.Intn(len(charset)-1)]
|
||||
}
|
||||
return (string(b))
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@ package ps
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/shirou/gopsutil/v3/host"
|
||||
"github.com/shirou/gopsutil/v3/process"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/shirou/gopsutil/v3/host"
|
||||
"github.com/shirou/gopsutil/v3/process"
|
||||
)
|
||||
|
||||
func TestPs(t *testing.T) {
|
||||
|
@ -67,8 +68,8 @@ func TestPs(t *testing.T) {
|
|||
fmt.Println(ss)
|
||||
}
|
||||
|
||||
fmt.Println(fmt.Sprintf("Name: %s PId: %v ParentID: %v Username: %v status:%s startTime: %s numThreads: %v numConnections:%v cpuPercent:%v rss:%s MB IORead: %s IOWrite: %s",
|
||||
name, pro.Pid, parentID, userName, status, startTime, numThreads, numConnections, cpuPercent, rss, ioRead, ioWrite))
|
||||
fmt.Printf("Name: %s PId: %v ParentID: %v Username: %v status:%s startTime: %s numThreads: %v numConnections:%v cpuPercent:%v rss:%s MB IORead: %s IOWrite: %s \n",
|
||||
name, pro.Pid, parentID, userName, status, startTime, numThreads, numConnections, cpuPercent, rss, ioRead, ioWrite)
|
||||
}
|
||||
users, err := host.Users()
|
||||
if err == nil {
|
||||
|
|
|
@ -8,13 +8,14 @@ import (
|
|||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||
"gopkg.in/yaml.v3"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/backend/utils/files"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/go-acme/lego/v4/acme/api"
|
||||
"github.com/go-acme/lego/v4/certcrypto"
|
||||
"github.com/go-acme/lego/v4/certificate"
|
||||
|
@ -105,7 +106,9 @@ func TestAppToV2(t *testing.T) {
|
|||
oldAppDir := oldDir + "/" + appDefine.Key
|
||||
newAppDir := newDir + "/" + appDefine.Key
|
||||
if !fileOp.Stat(newAppDir) {
|
||||
fileOp.CreateDir(newAppDir, 0755)
|
||||
if err := fileOp.CreateDir(newAppDir, 0755); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
// logo
|
||||
oldLogoPath := oldAppDir + "/metadata/logo.png"
|
||||
|
|
Loading…
Reference in New Issue