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
18 changes: 0 additions & 18 deletions agent/app/api/v2/database_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,6 @@ func (b *BaseApi) SearchMysql(c *gin.Context) {
})
}

// @Tags Database Mysql
// @Summary List mysql database names
// @Accept json
// @Param request body dto.PageInfo true "request"
// @Success 200 {array} dto.MysqlOption
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/options [get]
func (b *BaseApi) ListDBName(c *gin.Context) {
list, err := mysqlService.ListDBOption()
if err != nil {
helper.InternalServer(c, err)
return
}

helper.SuccessWithData(c, list)
}

// @Tags Database Mysql
// @Summary List mysql database format collation options
// @Accept json
Expand Down
18 changes: 0 additions & 18 deletions agent/utils/cloud_storage/client/helper/webdav/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
return az
}

func NewEmptyAuth() Authorizer {
fmap := make([]authfactory, 0)
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
return az
}

func NewPreemptiveAuth(auth Authenticator) Authorizer {
return &preemptiveAuthorizer{auth: auth}
}

func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
var retryBuf io.Reader = body
if body != nil {
Expand Down Expand Up @@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
func (n *nullAuth) String() string {
return "NullAuth"
}

func (b *preemptiveAuthorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
return b.auth.Clone(), body
}

func (b *preemptiveAuthorizer) AddAuthenticator(key string, fn AuthFactory) {
panic("You're funny! A preemptive authorizer may only have a single authentication method")
}
8 changes: 0 additions & 8 deletions agent/utils/cloud_storage/client/helper/webdav/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package webdav

import (
"bytes"
"encoding/xml"
"io"
"net/url"
Expand Down Expand Up @@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
}

func String(r io.Reader) string {
buf := new(bytes.Buffer)
// TODO - make String return an error as well
_, _ = buf.ReadFrom(r)
return buf.String()
}

func parseInt64(s *string) int64 {
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
return n
Expand Down
9 changes: 0 additions & 9 deletions core/app/api/v2/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@ func (b *BaseApi) Captcha(c *gin.Context) {
helper.SuccessWithData(c, captcha)
}

func (b *BaseApi) GetResponsePage(c *gin.Context) {
pageCode, err := authService.GetResponsePage()
if err != nil {
helper.InternalServer(c, err)
return
}
helper.SuccessWithData(c, pageCode)
}

func (b *BaseApi) GetWelcomePage(c *gin.Context) {
count, _, _ := logService.PageLoginLog(c, dto.SearchLgLogWithPage{PageInfo: dto.PageInfo{Page: 1, PageSize: 10}})
if count != 1 {
Expand Down
22 changes: 0 additions & 22 deletions core/app/api/v2/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,3 @@ func (b *BaseApi) Upgrade(c *gin.Context) {
}
helper.Success(c)
}

// @Tags System Setting
// @Summary Upgrade
// @Accept json
// @Param request body dto.OperateByID true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /core/settings/rollback [post]
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"upgrade_logs","output_column":"old_version","output_value":"version"}],"formatZH":"回滚系统 => [version]","formatEN":"rollback system => [version]"}
func (b *BaseApi) Rollback(c *gin.Context) {
var req dto.OperateByID
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}

if err := upgradeService.Rollback(req); err != nil {
helper.InternalServer(c, err)
return
}
helper.Success(c)
}
5 changes: 0 additions & 5 deletions core/app/repo/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ func WithByNode(node string) global.DBOption {
return g.Where("node = ?", node)
}
}
func WithByGroupBelong(group string) global.DBOption {
return func(g *gorm.DB) *gorm.DB {
return g.Where("group_belong = ?", group)
}
}

func WithOrderBy(orderStr string) global.DBOption {
if orderStr == "createdAt" {
Expand Down
6 changes: 0 additions & 6 deletions core/app/repo/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type IHostRepo interface {
WithByInfo(info string) global.DBOption
WithByPort(port uint) global.DBOption
WithByUser(user string) global.DBOption
WithByAddr(addr string) global.DBOption
}

func NewIHostRepo() IHostRepo {
Expand Down Expand Up @@ -79,11 +78,6 @@ func (h *HostRepo) WithByUser(user string) global.DBOption {
return g.Where("user = ?", user)
}
}
func (h *HostRepo) WithByAddr(addr string) global.DBOption {
return func(g *gorm.DB) *gorm.DB {
return g.Where("addr = ?", addr)
}
}

func (h *HostRepo) Create(host *model.Host) error {
return global.DB.Create(host).Error
Expand Down
4 changes: 2 additions & 2 deletions core/app/service/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
req.PrivateKey = string(privateKey)
}
if len(req.Password) == 0 && len(req.PrivateKey) == 0 {
host, err := hostRepo.Get(hostRepo.WithByAddr(req.Addr), hostRepo.WithByPort(req.Port))
host, err := hostRepo.Get(repo.WithByAddr(req.Addr), hostRepo.WithByPort(req.Port))
if err != nil {
return false
}
Expand Down Expand Up @@ -235,7 +235,7 @@
}

func (u *HostService) Create(req dto.HostOperate) (*dto.HostInfo, error) {
hostItem, _ := hostRepo.Get(hostRepo.WithByAddr(req.Addr), hostRepo.WithByUser(req.User), hostRepo.WithByPort(req.Port))
hostItem, _ := hostRepo.Get(repo.WithByAddr(req.Addr), hostRepo.WithByUser(req.User), hostRepo.WithByPort(req.Port))

Check failure on line 238 in core/app/service/host.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=AZrEeJWHKQ2WkMd_ddTB&open=AZrEeJWHKQ2WkMd_ddTB&pullRequest=11105
if hostItem.ID != 0 {
return nil, buserr.New("ErrRecordExist")
}
Expand Down
18 changes: 0 additions & 18 deletions core/utils/cloud_storage/client/helper/webdav/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
return az
}

func NewEmptyAuth() Authorizer {
fmap := make([]authfactory, 0)
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
return az
}

func NewPreemptiveAuth(auth Authenticator) Authorizer {
return &preemptiveAuthorizer{auth: auth}
}

func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
var retryBuf io.Reader = body
if body != nil {
Expand Down Expand Up @@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
func (n *nullAuth) String() string {
return "NullAuth"
}

func (b *preemptiveAuthorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
return b.auth.Clone(), body
}

func (b *preemptiveAuthorizer) AddAuthenticator(key string, fn AuthFactory) {
panic("You're funny! A preemptive authorizer may only have a single authentication method")
}
8 changes: 0 additions & 8 deletions core/utils/cloud_storage/client/helper/webdav/utils.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package webdav

import (
"bytes"
"encoding/xml"
"io"
"net/url"
Expand Down Expand Up @@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
}

func String(r io.Reader) string {
buf := new(bytes.Buffer)
// TODO - make String return an error as well
_, _ = buf.ReadFrom(r)
return buf.String()
}

func parseInt64(s *string) int64 {
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
return n
Expand Down
19 changes: 0 additions & 19 deletions core/utils/common/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,6 @@ func LoadDBConnByPath(fullPath, dbName string) *gorm.DB {
return db
}

func LoadDBConnByPathWithErr(fullPath, dbName string) (*gorm.DB, error) {
if _, err := CreateDirWhenNotExist(true, path.Dir(fullPath)); err != nil {
return nil, fmt.Errorf("init db dir failed, err: %v", err)
}
if _, err := os.Stat(fullPath); err != nil {
f, err := os.Create(fullPath)
if err != nil {
return nil, fmt.Errorf("init %s db file failed, err: %v", dbName, err)
}
_ = f.Close()
}

db, err := GetDBWithPath(fullPath)
if err != nil {
return nil, fmt.Errorf("init %s db failed, err: %v", dbName, err)
}
return db, nil
}

func CloseDB(db *gorm.DB) {
sqlDB, err := db.DB()
if err != nil {
Expand Down
Loading