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