Include the registry info in the project summary API for proxy cache project

Include the registry info in the project summary API for proxy cache project

Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
Wenkai Yin 2020-07-17 16:12:40 +08:00
parent af3a638980
commit d7327d8d8e
6 changed files with 23 additions and 13 deletions

View File

@ -3877,6 +3877,8 @@ definitions:
used:
$ref: "#/definitions/ResourceList"
description: The used status of the quota
registry:
$ref: "#/definitions/Registry"
User:
type: object
properties:

View File

@ -19,6 +19,7 @@ import (
"time"
"github.com/goharbor/harbor/src/pkg/quota/types"
"github.com/goharbor/harbor/src/replication/model"
)
const (
@ -211,5 +212,6 @@ type ProjectSummary struct {
GuestCount int64 `json:"guest_count"`
LimitedGuestCount int64 `json:"limited_guest_count"`
Quota *QuotaSummary `json:"quota,omitempty"`
Quota *QuotaSummary `json:"quota,omitempty"`
Registry *model.Registry `json:"registry"`
}

View File

@ -571,6 +571,18 @@ func (p *ProjectAPI) Summary() {
}
wg.Wait()
if p.project.RegistryID > 0 {
registry, err := replication.RegistryMgr.Get(p.project.RegistryID)
if err != nil {
log.Warningf("failed to get registry %d: %v", p.project.RegistryID, err)
} else {
if registry != nil {
registry.Credential = nil
summary.Registry = registry
}
}
}
p.Data["json"] = summary
p.ServeJSON()
}

View File

@ -20,7 +20,6 @@ import (
"net/http"
"strconv"
common_model "github.com/goharbor/harbor/src/common/models"
"github.com/goharbor/harbor/src/replication"
"github.com/goharbor/harbor/src/replication/dao/models"
"github.com/goharbor/harbor/src/replication/event"
@ -58,10 +57,8 @@ func (r *ReplicationPolicyAPI) List() {
// TODO: support more query
query := &model.PolicyQuery{
Name: r.GetString("name"),
Pagination: common_model.Pagination{
Page: page,
Size: size,
},
Page: page,
Size: size,
}
total, policies, err := replication.PolicyCtl.List(query)

View File

@ -3,7 +3,6 @@ package dao
import (
"testing"
common_models "github.com/goharbor/harbor/src/common/models"
"github.com/goharbor/harbor/src/replication/dao/models"
"github.com/goharbor/harbor/src/replication/model"
"github.com/stretchr/testify/assert"
@ -106,10 +105,8 @@ func TestGetPolicies(t *testing.T) {
{
Name: tt.args.name,
Namespace: tt.args.namespace,
Pagination: common_models.Pagination{
Page: tt.args.page,
Size: tt.args.pageSize,
},
Page: tt.args.page,
Size: tt.args.pageSize,
},
}...)
if tt.wantErr {

View File

@ -17,7 +17,6 @@ package model
import (
"fmt"
"github.com/astaxie/beego/validation"
"github.com/goharbor/harbor/src/common/models"
"github.com/robfig/cron"
"time"
)
@ -168,5 +167,6 @@ type PolicyQuery struct {
Namespace string
SrcRegistry int64
DestRegistry int64
models.Pagination
Page int64
Size int64
}