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: used:
$ref: "#/definitions/ResourceList" $ref: "#/definitions/ResourceList"
description: The used status of the quota description: The used status of the quota
registry:
$ref: "#/definitions/Registry"
User: User:
type: object type: object
properties: properties:

View File

@ -19,6 +19,7 @@ import (
"time" "time"
"github.com/goharbor/harbor/src/pkg/quota/types" "github.com/goharbor/harbor/src/pkg/quota/types"
"github.com/goharbor/harbor/src/replication/model"
) )
const ( const (
@ -212,4 +213,5 @@ type ProjectSummary struct {
LimitedGuestCount int64 `json:"limited_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() 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.Data["json"] = summary
p.ServeJSON() p.ServeJSON()
} }

View File

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

View File

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

View File

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