style(be):golangci-lint github action 增加timeout
This commit is contained in:
parent
5e7be397a5
commit
ea48bd3da2
3
.github/workflows/golangci-lint.yml
vendored
3
.github/workflows/golangci-lint.yml
vendored
@ -18,4 +18,5 @@ jobs:
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
|
||||
version: v1.29
|
||||
version: v1.29
|
||||
args: --timeout=10m
|
||||
|
2
main.go
2
main.go
@ -229,7 +229,7 @@ func Run() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if jobs == nil {
|
||||
if len(jobs) == 0 {
|
||||
job := model.Job{
|
||||
ID: utils.UUID(),
|
||||
Name: "资产状态检测",
|
||||
|
@ -35,7 +35,7 @@ func ReloadAccessSecurity() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if rules != nil {
|
||||
if len(rules) > 0 {
|
||||
var securities []*global.Security
|
||||
for i := 0; i < len(rules); i++ {
|
||||
rule := global.Security{
|
||||
|
@ -20,7 +20,7 @@ func RunTicker() {
|
||||
go func() {
|
||||
for range unUsedSessionTicker.C {
|
||||
sessions, _ := model.FindSessionByStatusIn([]string{constant.NoConnect, constant.Connecting})
|
||||
if sessions != nil {
|
||||
if len(sessions) > 0 {
|
||||
now := time.Now()
|
||||
for i := range sessions {
|
||||
if now.Sub(sessions[i].ConnectedTime.Time) > time.Hour*1 {
|
||||
@ -53,7 +53,7 @@ func RunTicker() {
|
||||
return
|
||||
}
|
||||
|
||||
if sessions != nil {
|
||||
if len(sessions) > 0 {
|
||||
var sessionIds []string
|
||||
for i := range sessions {
|
||||
sessionIds = append(sessionIds, sessions[i].ID)
|
||||
|
@ -95,7 +95,7 @@ func FindPageAsset(pageIndex, pageSize int, name, protocol, tags string, account
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
if userGroupIds != nil {
|
||||
if len(userGroupIds) > 0 {
|
||||
db = db.Or("resource_sharers.user_group_id in ?", userGroupIds)
|
||||
dbCounter = dbCounter.Or("resource_sharers.user_group_id in ?", userGroupIds)
|
||||
}
|
||||
@ -210,7 +210,7 @@ func CountAssetByUserId(userId string) (total int64, err error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if userGroupIds != nil {
|
||||
if len(userGroupIds) > 0 {
|
||||
db = db.Or("resource_sharers.user_group_id in ?", userGroupIds)
|
||||
}
|
||||
err = db.Find(&Asset{}).Count(&total).Error
|
||||
|
@ -123,7 +123,7 @@ func CountCredentialByUserId(userId string) (total int64, err error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
if userGroupIds != nil {
|
||||
if len(userGroupIds) > 0 {
|
||||
db = db.Or("resource_sharers.user_group_id in ?", userGroupIds)
|
||||
}
|
||||
err = db.Find(&Credential{}).Count(&total).Error
|
||||
|
@ -199,7 +199,7 @@ func (r CheckAssetStatusJob) Run() {
|
||||
assets, _ = FindAssetByIds(strings.Split(r.ResourceIds, ","))
|
||||
}
|
||||
|
||||
if assets == nil {
|
||||
if len(assets) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
@ -257,7 +257,7 @@ func (r ShellJob) Run() {
|
||||
assets, _ = FindAssetByProtocolAndIds("ssh", strings.Split(r.ResourceIds, ","))
|
||||
}
|
||||
|
||||
if assets == nil {
|
||||
if len(assets) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ func FindAssetIdsByUserId(userId string) (assetIds []string, err error) {
|
||||
}
|
||||
|
||||
db := global.DB.Table("resource_sharers").Select("resource_id").Where("user_id = ?", userId)
|
||||
if groupIds != nil {
|
||||
if len(groupIds) > 0 {
|
||||
db = db.Or("user_group_id in ?", groupIds)
|
||||
}
|
||||
err = db.Find(&sharerAssetIds).Error
|
||||
|
Loading…
Reference in New Issue
Block a user