mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-22 18:25:56 +01:00
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:
parent
af3a638980
commit
d7327d8d8e
@ -3877,6 +3877,8 @@ definitions:
|
||||
used:
|
||||
$ref: "#/definitions/ResourceList"
|
||||
description: The used status of the quota
|
||||
registry:
|
||||
$ref: "#/definitions/Registry"
|
||||
User:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/goharbor/harbor/src/pkg/quota/types"
|
||||
"github.com/goharbor/harbor/src/replication/model"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -212,4 +213,5 @@ type ProjectSummary struct {
|
||||
LimitedGuestCount int64 `json:"limited_guest_count"`
|
||||
|
||||
Quota *QuotaSummary `json:"quota,omitempty"`
|
||||
Registry *model.Registry `json:"registry"`
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
total, policies, err := replication.PolicyCtl.List(query)
|
||||
|
@ -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,11 +105,9 @@ 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,
|
||||
},
|
||||
},
|
||||
}...)
|
||||
if tt.wantErr {
|
||||
require.NotNil(t, err, "wantErr: %s", err)
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user