mirror of
https://github.com/goharbor/harbor.git
synced 2024-10-04 00:07:47 +02:00
The default item list should be empty list,not null
This commit make sure that the "items" in response of project level CVE_whitelist is not null, even when it's null in the DB the API will return an empty list Signed-off-by: Daniel Jiang <jiangd@vmware.com>
This commit is contained in:
parent
250a53cad7
commit
76a79869df
@ -41,6 +41,7 @@ type defaultManager struct{}
|
|||||||
func (d *defaultManager) CreateEmpty(projectID int64) error {
|
func (d *defaultManager) CreateEmpty(projectID int64) error {
|
||||||
l := models.CVEWhitelist{
|
l := models.CVEWhitelist{
|
||||||
ProjectID: projectID,
|
ProjectID: projectID,
|
||||||
|
Items: []models.CVEWhitelistItem{},
|
||||||
}
|
}
|
||||||
_, err := dao.CreateCVEWhitelist(l)
|
_, err := dao.CreateCVEWhitelist(l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -66,6 +67,9 @@ func (d *defaultManager) Get(projectID int64) (*models.CVEWhitelist, error) {
|
|||||||
log.Debugf("No CVE whitelist found for project %d, returning empty list.", projectID)
|
log.Debugf("No CVE whitelist found for project %d, returning empty list.", projectID)
|
||||||
return &models.CVEWhitelist{ProjectID: projectID, Items: []models.CVEWhitelistItem{}}, nil
|
return &models.CVEWhitelist{ProjectID: projectID, Items: []models.CVEWhitelistItem{}}, nil
|
||||||
}
|
}
|
||||||
|
if wl.Items == nil {
|
||||||
|
wl.Items = []models.CVEWhitelistItem{}
|
||||||
|
}
|
||||||
return wl, err
|
return wl, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user