mirror of
https://github.com/goharbor/harbor
synced 2025-04-12 18:23:43 +00:00
bump up swagger (#21396)
* bump up swagger Signed-off-by: wang yan <wangyan@vmware.com> * fix gc driver type Signed-off-by: wang yan <wangyan@vmware.com> --------- Signed-off-by: wang yan <wangyan@vmware.com>
This commit is contained in:
parent
15d17a3338
commit
b0545c05fd
2
Makefile
2
Makefile
|
@ -291,7 +291,7 @@ lint_apis:
|
|||
$(SPECTRAL) lint ./api/v2.0/swagger.yaml
|
||||
|
||||
SWAGGER_IMAGENAME=$(IMAGENAMESPACE)/swagger
|
||||
SWAGGER_VERSION=v0.25.0
|
||||
SWAGGER_VERSION=v0.31.0
|
||||
SWAGGER=$(RUNCONTAINER) ${SWAGGER_IMAGENAME}:${SWAGGER_VERSION}
|
||||
SWAGGER_GENERATE_SERVER=${SWAGGER} generate server --template-dir=$(TOOLSPATH)/swagger/templates --exclude-main --additional-initialism=CVE --additional-initialism=GC --additional-initialism=OIDC
|
||||
SWAGGER_IMAGE_BUILD_CMD=${DOCKERBUILD} -f ${TOOLSPATH}/swagger/Dockerfile --build-arg GOLANG=${GOBUILDIMAGE} --build-arg SWAGGER_VERSION=${SWAGGER_VERSION} -t ${SWAGGER_IMAGENAME}:$(SWAGGER_VERSION) .
|
||||
|
|
|
@ -62,7 +62,7 @@ func (d *driver) HardLimits(ctx context.Context) types.ResourceList {
|
|||
}
|
||||
}
|
||||
|
||||
func (d *driver) Load(ctx context.Context, key string) (dr.RefObject, error) {
|
||||
func (d *driver) Load(ctx context.Context, key string) (dr.QuotaRefObject, error) {
|
||||
thunk := d.loader.Load(ctx, dataloader.StringKey(key))
|
||||
|
||||
result, err := thunk()
|
||||
|
@ -75,7 +75,7 @@ func (d *driver) Load(ctx context.Context, key string) (dr.RefObject, error) {
|
|||
return nil, fmt.Errorf("bad result for project: %s", key)
|
||||
}
|
||||
|
||||
return dr.RefObject{
|
||||
return dr.QuotaRefObject{
|
||||
"id": project.ProjectID,
|
||||
"name": project.Name,
|
||||
"owner_name": project.OwnerName,
|
||||
|
|
|
@ -26,8 +26,8 @@ var (
|
|||
drivers = map[string]Driver{}
|
||||
)
|
||||
|
||||
// RefObject type for quota ref object
|
||||
type RefObject map[string]interface{}
|
||||
// QuotaRefObject type for quota ref object
|
||||
type QuotaRefObject map[string]interface{}
|
||||
|
||||
// Driver the driver for quota
|
||||
type Driver interface {
|
||||
|
@ -36,7 +36,7 @@ type Driver interface {
|
|||
// HardLimits returns default resource list
|
||||
HardLimits(ctx context.Context) types.ResourceList
|
||||
// Load returns quota ref object by key
|
||||
Load(ctx context.Context, key string) (RefObject, error)
|
||||
Load(ctx context.Context, key string) (QuotaRefObject, error)
|
||||
// Validate validate the hard limits
|
||||
Validate(hardLimits types.ResourceList) error
|
||||
// CalculateUsage calculate quota usage by reference id
|
||||
|
|
|
@ -25,14 +25,14 @@ import (
|
|||
|
||||
// Quota quota model for manager
|
||||
type Quota struct {
|
||||
ID int64 `orm:"pk;auto;column(id)" json:"id"`
|
||||
Ref driver.RefObject `orm:"-" json:"ref"`
|
||||
Reference string `orm:"column(reference)" json:"-"`
|
||||
ReferenceID string `orm:"column(reference_id)" json:"-"`
|
||||
Hard string `orm:"column(hard);type(jsonb)" json:"-"`
|
||||
Used string `orm:"column(used);type(jsonb)" json:"-"`
|
||||
CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
|
||||
UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
|
||||
ID int64 `orm:"pk;auto;column(id)" json:"id"`
|
||||
Ref driver.QuotaRefObject `orm:"-" json:"ref"`
|
||||
Reference string `orm:"column(reference)" json:"-"`
|
||||
ReferenceID string `orm:"column(reference_id)" json:"-"`
|
||||
Hard string `orm:"column(hard);type(jsonb)" json:"-"`
|
||||
Used string `orm:"column(used);type(jsonb)" json:"-"`
|
||||
CreationTime time.Time `orm:"column(creation_time);auto_now_add" json:"creation_time"`
|
||||
UpdateTime time.Time `orm:"column(update_time);auto_now" json:"update_time"`
|
||||
|
||||
HardVersion int64 `orm:"column(hard_version)" json:"-"`
|
||||
UsedVersion int64 `orm:"column(used_version)" json:"-"`
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/goharbor/harbor/src/lib/log"
|
||||
"github.com/goharbor/harbor/src/pkg/quota"
|
||||
"github.com/goharbor/harbor/src/pkg/quota/driver"
|
||||
"github.com/goharbor/harbor/src/pkg/quota/types"
|
||||
"github.com/goharbor/harbor/src/server/v2.0/models"
|
||||
)
|
||||
|
@ -54,7 +55,7 @@ func (q *Quota) ToSwagger(ctx context.Context) *models.Quota {
|
|||
|
||||
return &models.Quota{
|
||||
ID: q.ID,
|
||||
Ref: q.Ref,
|
||||
Ref: NewQuotaRefObject(q.Ref).ToSwagger(),
|
||||
Hard: NewResourceList(hard).ToSwagger(),
|
||||
Used: NewResourceList(used).ToSwagger(),
|
||||
CreationTime: strfmt.DateTime(q.CreationTime),
|
||||
|
@ -66,3 +67,24 @@ func (q *Quota) ToSwagger(ctx context.Context) *models.Quota {
|
|||
func NewQuota(quota *quota.Quota) *Quota {
|
||||
return &Quota{Quota: quota}
|
||||
}
|
||||
|
||||
// QuotaRefObject model
|
||||
type QuotaRefObject struct {
|
||||
driver.QuotaRefObject
|
||||
}
|
||||
|
||||
// ToSwagger converts the QuotaRefObject to the swagger model
|
||||
func (rl *QuotaRefObject) ToSwagger() models.QuotaRefObject {
|
||||
result := make(map[string]interface{}, len(rl.QuotaRefObject))
|
||||
|
||||
for name, value := range rl.QuotaRefObject {
|
||||
result[string(name)] = value
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// NewQuotaRefObject new QuotaRefObject instance
|
||||
func NewQuotaRefObject(qr driver.QuotaRefObject) *QuotaRefObject {
|
||||
return &QuotaRefObject{QuotaRefObject: qr}
|
||||
}
|
||||
|
|
|
@ -95,23 +95,23 @@ func (_m *Driver) HardLimits(ctx context.Context) types.ResourceList {
|
|||
}
|
||||
|
||||
// Load provides a mock function with given fields: ctx, key
|
||||
func (_m *Driver) Load(ctx context.Context, key string) (driver.RefObject, error) {
|
||||
func (_m *Driver) Load(ctx context.Context, key string) (driver.QuotaRefObject, error) {
|
||||
ret := _m.Called(ctx, key)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Load")
|
||||
}
|
||||
|
||||
var r0 driver.RefObject
|
||||
var r0 driver.QuotaRefObject
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) (driver.RefObject, error)); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) (driver.QuotaRefObject, error)); ok {
|
||||
return rf(ctx, key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) driver.RefObject); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, string) driver.QuotaRefObject); ok {
|
||||
r0 = rf(ctx, key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(driver.RefObject)
|
||||
r0 = ret.Get(0).(driver.QuotaRefObject)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ ARG GOLANG
|
|||
FROM ${GOLANG}
|
||||
|
||||
ARG SWAGGER_VERSION
|
||||
RUN curl -fsSL -o /usr/bin/swagger https://github.com/go-swagger/go-swagger/releases/download/$SWAGGER_VERSION/swagger_linux_amd64 && chmod +x /usr/bin/swagger
|
||||
RUN go install github.com/go-swagger/go-swagger/cmd/swagger@$SWAGGER_VERSION
|
||||
|
||||
ENTRYPOINT ["/usr/bin/swagger"]
|
||||
ENTRYPOINT ["swagger"]
|
||||
CMD ["--help"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user