diff --git a/backend/app/api/v1/docker.go b/backend/app/api/v1/docker.go index 8160f4b3c..87a575ae9 100644 --- a/backend/app/api/v1/docker.go +++ b/backend/app/api/v1/docker.go @@ -1,7 +1,6 @@ package v1 import ( - "io/ioutil" "os" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" @@ -35,7 +34,7 @@ func (b *BaseApi) LoadDaemonJsonFile(c *gin.Context) { helper.SuccessWithData(c, "daemon.json is not find in path") return } - content, err := ioutil.ReadFile(constant.DaemonJsonPath) + content, err := os.ReadFile(constant.DaemonJsonPath) if err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) return diff --git a/backend/app/api/v1/file.go b/backend/app/api/v1/file.go index 3bfcb3662..2a6276372 100644 --- a/backend/app/api/v1/file.go +++ b/backend/app/api/v1/file.go @@ -3,7 +3,7 @@ package v1 import ( "errors" "fmt" - "io/ioutil" + "io" "net/http" "os" "path" @@ -510,7 +510,7 @@ func (b *BaseApi) LoadFromFile(c *gin.Context) { return } - content, err := ioutil.ReadFile(req.Path) + content, err := os.ReadFile(req.Path) if err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) return @@ -533,7 +533,7 @@ func mergeChunks(fileName string, fileDir string, dstDir string, chunkCount int) for i := 0; i < chunkCount; i++ { chunkPath := filepath.Join(fileDir, fmt.Sprintf("%s.%d", fileName, i)) - chunkData, err := ioutil.ReadFile(chunkPath) + chunkData, err := os.ReadFile(chunkPath) if err != nil { return err } @@ -599,14 +599,14 @@ func (b *BaseApi) UploadChunkFiles(c *gin.Context) { } defer emptyFile.Close() - chunkData, err := ioutil.ReadAll(uploadFile) + chunkData, err := io.ReadAll(uploadFile) if err != nil { helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrFileUpload, err) return } chunkPath := filepath.Join(fileDir, fmt.Sprintf("%s.%d", filename, chunkIndex)) - err = ioutil.WriteFile(chunkPath, chunkData, 0644) + err = os.WriteFile(chunkPath, chunkData, 0644) if err != nil { helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrFileUpload, err) return diff --git a/backend/app/service/app.go b/backend/app/service/app.go index 9ea51e9c9..fe8d18163 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -5,14 +5,15 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/1Panel-dev/1Panel/backend/buserr" - "github.com/1Panel-dev/1Panel/backend/utils/docker" - "io/ioutil" + "io" "net/http" "os" "path" "strings" + "github.com/1Panel-dev/1Panel/backend/buserr" + "github.com/1Panel-dev/1Panel/backend/utils/docker" + "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/dto/request" "github.com/1Panel-dev/1Panel/backend/app/dto/response" @@ -321,7 +322,9 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) ( if appInstall.HttpsPort > 0 { ports = append(ports, appInstall.HttpsPort) } - go OperateFirewallPort(nil, ports) + go func() { + _ = OperateFirewallPort(nil, ports) + }() return &appInstall, nil } @@ -340,7 +343,7 @@ func (a AppService) GetAppUpdate() (*response.AppUpdateRes, error) { return nil, err } defer versionRes.Body.Close() - body, err := ioutil.ReadAll(versionRes.Body) + body, err := io.ReadAll(versionRes.Body) if err != nil { return nil, err } diff --git a/backend/app/service/app_install.go b/backend/app/service/app_install.go index 7d5ac1587..2eb3bc77a 100644 --- a/backend/app/service/app_install.go +++ b/backend/app/service/app_install.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "math" "os" "path" @@ -612,7 +611,7 @@ func updateInstallInfoInDB(appKey, appName, param string, isRestart bool, value return nil } envPath := fmt.Sprintf("%s/%s/%s/.env", constant.AppInstallDir, appKey, appInstall.Name) - lineBytes, err := ioutil.ReadFile(envPath) + lineBytes, err := os.ReadFile(envPath) if err != nil { return err } diff --git a/backend/app/service/backup_redis.go b/backend/app/service/backup_redis.go index e71f75540..93b63fbae 100644 --- a/backend/app/service/backup_redis.go +++ b/backend/app/service/backup_redis.go @@ -2,7 +2,6 @@ package service import ( "fmt" - "io/ioutil" "os" "path" "strings" @@ -176,11 +175,11 @@ func handleRedisRecover(redisInfo *repo.RootInfo, recoverFile string, isRollback if appendonly == "yes" && redisInfo.Version == "6.0.16" { itemName = "appendonly.aof" } - input, err := ioutil.ReadFile(recoverFile) + input, err := os.ReadFile(recoverFile) if err != nil { return err } - if err = ioutil.WriteFile(composeDir+"/data/"+itemName, input, 0640); err != nil { + if err = os.WriteFile(composeDir+"/data/"+itemName, input, 0640); err != nil { return err } } diff --git a/backend/app/service/container.go b/backend/app/service/container.go index c6d8b4c62..a800bf352 100644 --- a/backend/app/service/container.go +++ b/backend/app/service/container.go @@ -6,7 +6,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os/exec" "sort" "strconv" @@ -267,7 +266,7 @@ func (u *ContainerService) ContainerStats(id string) (*dto.ContainterStats, erro } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { return nil, err } @@ -339,7 +338,7 @@ func pullImages(ctx context.Context, client *client.Client, image string) error return err } defer out.Close() - _, err = io.Copy(ioutil.Discard, out) + _, err = io.Copy(io.Discard, out) if err != nil { return err } diff --git a/backend/app/service/container_volume.go b/backend/app/service/container_volume.go index 0dc42739b..fb8193482 100644 --- a/backend/app/service/container_volume.go +++ b/backend/app/service/container_volume.go @@ -10,7 +10,6 @@ import ( "github.com/1Panel-dev/1Panel/backend/buserr" "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/utils/docker" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/volume" ) @@ -37,14 +36,14 @@ func (u *ContainerService) PageVolume(req dto.SearchWithPage) (int64, interface{ } var ( data []dto.Volume - records []*types.Volume + records []*volume.Volume ) sort.Slice(list.Volumes, func(i, j int) bool { return list.Volumes[i].CreatedAt > list.Volumes[j].CreatedAt }) total, start, end := len(list.Volumes), (req.Page-1)*req.PageSize, req.Page*req.PageSize if start > total { - records = make([]*types.Volume, 0) + records = make([]*volume.Volume, 0) } else { if end >= total { end = total @@ -119,7 +118,7 @@ func (u *ContainerService) CreateVolume(req dto.VolumeCreat) error { } } } - options := volume.VolumeCreateBody{ + options := volume.CreateOptions{ Name: req.Name, Driver: req.Driver, DriverOpts: stringsToMap(req.Options), diff --git a/backend/app/service/cronjob_helper.go b/backend/app/service/cronjob_helper.go index a3549af6e..14b93ca4a 100644 --- a/backend/app/service/cronjob_helper.go +++ b/backend/app/service/cronjob_helper.go @@ -3,7 +3,6 @@ package service import ( "context" "fmt" - "io/ioutil" "os" "strings" "time" @@ -170,7 +169,7 @@ func (u *CronjobService) HandleRmExpired(backType, backupDir string, cronjob *mo } return } - files, err := ioutil.ReadDir(backupDir) + files, err := os.ReadDir(backupDir) if err != nil { global.LOG.Errorf("read dir %s failed, err: %v", backupDir, err) return diff --git a/backend/app/service/database_mysql.go b/backend/app/service/database_mysql.go index 37294dfad..c8174048d 100644 --- a/backend/app/service/database_mysql.go +++ b/backend/app/service/database_mysql.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "os/exec" "regexp" @@ -339,7 +338,7 @@ func (u *MysqlService) UpdateVariables(updatas []dto.MysqlVariablesUpdate) error var files []string path := fmt.Sprintf("%s/mysql/%s/conf/my.cnf", constant.AppInstallDir, app.Name) - lineBytes, err := ioutil.ReadFile(path) + lineBytes, err := os.ReadFile(path) if err != nil { return err } diff --git a/backend/app/service/database_redis.go b/backend/app/service/database_redis.go index f51abc660..18b13a9e5 100644 --- a/backend/app/service/database_redis.go +++ b/backend/app/service/database_redis.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "os" "os/exec" "path/filepath" @@ -215,7 +214,7 @@ type redisConfig struct { func confSet(redisName string, changeConf []redisConfig) error { path := fmt.Sprintf("%s/redis/%s/conf/redis.conf", constant.AppInstallDir, redisName) - lineBytes, err := ioutil.ReadFile(path) + lineBytes, err := os.ReadFile(path) if err != nil { return err } diff --git a/backend/app/service/docker.go b/backend/app/service/docker.go index 4fd1fd7c2..069efcd07 100644 --- a/backend/app/service/docker.go +++ b/backend/app/service/docker.go @@ -4,7 +4,6 @@ import ( "bufio" "context" "encoding/json" - "io/ioutil" "os" "path" "strings" @@ -66,7 +65,7 @@ func (u *DockerService) LoadDockerConf() *dto.DaemonJsonConf { if _, err := os.Stat(constant.DaemonJsonPath); err != nil { return &dto.DaemonJsonConf{Status: status, Version: version} } - file, err := ioutil.ReadFile(constant.DaemonJsonPath) + file, err := os.ReadFile(constant.DaemonJsonPath) if err != nil { return &dto.DaemonJsonConf{Status: status, Version: version} } @@ -109,7 +108,7 @@ func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error { _, _ = os.Create(constant.DaemonJsonPath) } - file, err := ioutil.ReadFile(constant.DaemonJsonPath) + file, err := os.ReadFile(constant.DaemonJsonPath) if err != nil { return err } @@ -151,7 +150,7 @@ func (u *DockerService) UpdateConf(req dto.DaemonJsonConf) error { if err != nil { return err } - if err := ioutil.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil { + if err := os.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil { return err } diff --git a/backend/app/service/image.go b/backend/app/service/image.go index 7e1096e67..58c5c198e 100644 --- a/backend/app/service/image.go +++ b/backend/app/service/image.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "os" "path" "strings" @@ -174,7 +173,7 @@ func (u *ImageService) ImageBuild(req dto.ImageBuild) (string, error) { return } defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { global.LOG.Errorf("build image %s failed, err: %v", req.Name, err) _, _ = file.WriteString(fmt.Sprintf("build image %s failed, err: %v", req.Name, err)) @@ -275,7 +274,7 @@ func (u *ImageService) ImageLoad(req dto.ImageLoad) error { if err != nil { return err } - content, err := ioutil.ReadAll(res.Body) + content, err := io.ReadAll(res.Body) if err != nil { return err } diff --git a/backend/app/service/image_repo.go b/backend/app/service/image_repo.go index 693c3fd3f..2714821c2 100644 --- a/backend/app/service/image_repo.go +++ b/backend/app/service/image_repo.go @@ -3,7 +3,6 @@ package service import ( "context" "encoding/json" - "io/ioutil" "os" "path" "strings" @@ -190,7 +189,7 @@ func (u *ImageRepoService) handleRegistries(newHost, delHost, handle string) err } deamonMap := make(map[string]interface{}) - file, err := ioutil.ReadFile(constant.DaemonJsonPath) + file, err := os.ReadFile(constant.DaemonJsonPath) if err != nil { return err } @@ -226,7 +225,7 @@ func (u *ImageRepoService) handleRegistries(newHost, delHost, handle string) err if err != nil { return err } - if err := ioutil.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil { + if err := os.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil { return err } return nil diff --git a/backend/app/service/nginx.go b/backend/app/service/nginx.go index abbec5c45..046c5a949 100644 --- a/backend/app/service/nginx.go +++ b/backend/app/service/nginx.go @@ -1,15 +1,16 @@ package service import ( - "github.com/1Panel-dev/1Panel/backend/app/dto/request" - "github.com/1Panel-dev/1Panel/backend/app/dto/response" - "io/ioutil" + "io" "net/http" "os" "path" "strings" "time" + "github.com/1Panel-dev/1Panel/backend/app/dto/request" + "github.com/1Panel-dev/1Panel/backend/app/dto/response" + "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/utils/files" @@ -67,7 +68,7 @@ func (n NginxService) GetStatus() (response.NginxStatus, error) { if err != nil { return response.NginxStatus{}, err } - content, err := ioutil.ReadAll(res.Body) + content, err := io.ReadAll(res.Body) if err != nil { return response.NginxStatus{}, err } diff --git a/backend/app/service/snapshot.go b/backend/app/service/snapshot.go index 5adeac4d9..436e6becb 100644 --- a/backend/app/service/snapshot.go +++ b/backend/app/service/snapshot.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" "os" "strings" "time" @@ -484,7 +483,7 @@ func (u *SnapshotService) SnapshotRollback(req dto.SnapshotRecover) error { func (u *SnapshotService) saveJson(snapJson SnapshotJson, path string) error { remarkInfo, _ := json.MarshalIndent(snapJson, "", "\t") - if err := ioutil.WriteFile(fmt.Sprintf("%s/snapshot.json", path), remarkInfo, 0640); err != nil { + if err := os.WriteFile(fmt.Sprintf("%s/snapshot.json", path), remarkInfo, 0640); err != nil { return err } return nil @@ -793,7 +792,7 @@ func (u *SnapshotService) updateLiveRestore(enabled bool) error { if _, err := os.Stat(constant.DaemonJsonPath); err != nil { return fmt.Errorf("load docker daemon.json conf failed, err: %v", err) } - file, err := ioutil.ReadFile(constant.DaemonJsonPath) + file, err := os.ReadFile(constant.DaemonJsonPath) if err != nil { return err } @@ -809,7 +808,7 @@ func (u *SnapshotService) updateLiveRestore(enabled bool) error { if err != nil { return err } - if err := ioutil.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil { + if err := os.WriteFile(constant.DaemonJsonPath, newJson, 0640); err != nil { return err } diff --git a/backend/app/service/upgrade.go b/backend/app/service/upgrade.go index 0a669f505..272ced804 100644 --- a/backend/app/service/upgrade.go +++ b/backend/app/service/upgrade.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "os" "runtime" @@ -203,7 +203,7 @@ func (u *UpgradeService) loadVersion(isLatest bool, currentVersion string) (stri return "", err } defer latestVersionRes.Body.Close() - version, err := ioutil.ReadAll(latestVersionRes.Body) + version, err := io.ReadAll(latestVersionRes.Body) if err != nil { return "", err } @@ -231,7 +231,7 @@ func (u *UpgradeService) loadReleaseNotes(path string) (string, error) { return "", err } defer releaseNotes.Body.Close() - release, err := ioutil.ReadAll(releaseNotes.Body) + release, err := io.ReadAll(releaseNotes.Body) if err != nil { return "", err } diff --git a/backend/log/writer.go b/backend/log/writer.go index 9d028b7a5..979c31d77 100644 --- a/backend/log/writer.go +++ b/backend/log/writer.go @@ -1,7 +1,6 @@ package log import ( - "io/ioutil" "log" "os" "path" @@ -108,7 +107,7 @@ func NewWriterFromConfig(c *Config) (RollingWriter, error) { } if c.MaxRemain > 0 { writer.rollingfilech = make(chan string, c.MaxRemain) - dir, err := ioutil.ReadDir(c.LogPath) + dir, err := os.ReadDir(c.LogPath) if err != nil { mng.Close() return nil, err diff --git a/backend/middleware/operation.go b/backend/middleware/operation.go index 3332f7f44..324988e8b 100644 --- a/backend/middleware/operation.go +++ b/backend/middleware/operation.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "strings" "time" @@ -77,9 +77,9 @@ func OperationLog() gin.HandlerFunc { formatMap := make(map[string]interface{}) if len(operationDic.BodyKeys) != 0 { - body, err := ioutil.ReadAll(c.Request.Body) + body, err := io.ReadAll(c.Request.Body) if err == nil { - c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(body)) + c.Request.Body = io.NopCloser(bytes.NewBuffer(body)) } bodyMap := make(map[string]interface{}) _ = json.Unmarshal(body, &bodyMap) diff --git a/backend/utils/cloud_storage/client/sftp.go b/backend/utils/cloud_storage/client/sftp.go index 4d40d34bf..7f8d999a9 100644 --- a/backend/utils/cloud_storage/client/sftp.go +++ b/backend/utils/cloud_storage/client/sftp.go @@ -2,7 +2,7 @@ package client import ( "fmt" - "io/ioutil" + "io" "net" "os" "path" @@ -75,7 +75,7 @@ func (s sftpClient) Upload(src, target string) (bool, error) { return false, err } defer dstFile.Close() - ff, err := ioutil.ReadAll(srcFile) + ff, err := io.ReadAll(srcFile) if err != nil { return false, err } diff --git a/backend/utils/firewall/client/ufw.go b/backend/utils/firewall/client/ufw.go index 113c48c0d..96ffed5a5 100644 --- a/backend/utils/firewall/client/ufw.go +++ b/backend/utils/firewall/client/ufw.go @@ -2,7 +2,6 @@ package client import ( "fmt" - "io/ioutil" "os" "strings" @@ -62,7 +61,7 @@ func (f *Ufw) PingStatus() (string, error) { } func (f *Ufw) UpdatePingStatus(enabel string) error { - lineBytes, err := ioutil.ReadFile(confPath) + lineBytes, err := os.ReadFile(confPath) if err != nil { return err } diff --git a/backend/utils/nginx/dumper.go b/backend/utils/nginx/dumper.go index 45455d518..757eef665 100644 --- a/backend/utils/nginx/dumper.go +++ b/backend/utils/nginx/dumper.go @@ -3,9 +3,10 @@ package nginx import ( "bytes" "fmt" - "github.com/1Panel-dev/1Panel/backend/utils/nginx/components" - "io/ioutil" + "os" "strings" + + "github.com/1Panel-dev/1Panel/backend/utils/nginx/components" ) var ( @@ -96,5 +97,5 @@ func DumpConfig(c *components.Config, style *Style) string { } func WriteConfig(c *components.Config, style *Style) error { - return ioutil.WriteFile(c.FilePath, []byte(DumpConfig(c, style)), 0644) + return os.WriteFile(c.FilePath, []byte(DumpConfig(c, style)), 0644) } diff --git a/backend/utils/ssl/acme_test.go b/backend/utils/ssl/acme_test.go index af9b05129..681f6eb8c 100644 --- a/backend/utils/ssl/acme_test.go +++ b/backend/utils/ssl/acme_test.go @@ -6,7 +6,6 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "io/ioutil" "os" "testing" "time" @@ -68,7 +67,7 @@ func TestSSL(t *testing.T) { // return //} - key, err := ioutil.ReadFile("private.key") + key, err := os.ReadFile("private.key") if err != nil { panic(err) } diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json index 94471caa4..b6c09ac24 100644 --- a/frontend/tsconfig.json +++ b/frontend/tsconfig.json @@ -31,6 +31,7 @@ }, // 跳过库检查,解决打包失败 "skipLibCheck": true, + "ignoreDeprecations": "5.0", "suppressImplicitAnyIndexErrors": true }, // "include": ["./src/views"],