Merge pull request #9799 from wy65701436/fix-sort-immu-rule

Fix immutable rule sequence to list API
This commit is contained in:
Wang Yan 2019-11-08 14:19:29 +08:00 committed by GitHub
commit 9929780904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import (
"github.com/goharbor/harbor/src/pkg/immutabletag/dao"
dao_model "github.com/goharbor/harbor/src/pkg/immutabletag/dao/model"
"github.com/goharbor/harbor/src/pkg/immutabletag/model"
"sort"
)
var (
@ -84,6 +85,9 @@ func (drm *defaultRuleManager) QueryImmutableRuleByProjectID(projectID int64) ([
rule.Disabled = daoRule.Disabled
rules = append(rules, rule)
}
sort.Slice(rules, func(i, j int) bool {
return rules[i].ID < rules[j].ID
})
return rules, nil
}