mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +01:00
Merge pull request #13393 from chlins/fix/p2p-preheat-instance-and-policy-post-no-location
fix(preheat): add location when create instance and policy
This commit is contained in:
commit
2bab4a10db
@ -957,9 +957,7 @@ paths:
|
|||||||
$ref: '#/definitions/Instance'
|
$ref: '#/definitions/Instance'
|
||||||
responses:
|
responses:
|
||||||
'201':
|
'201':
|
||||||
description: Response to insatnce created
|
$ref: '#/responses/201'
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/InstanceCreatedResp'
|
|
||||||
'400':
|
'400':
|
||||||
$ref: '#/responses/400'
|
$ref: '#/responses/400'
|
||||||
'401':
|
'401':
|
||||||
@ -1008,9 +1006,7 @@ paths:
|
|||||||
- $ref: '#/parameters/instanceName'
|
- $ref: '#/parameters/instanceName'
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Instance ID deleted
|
$ref: '#/responses/200'
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/InstanceDeletedResp'
|
|
||||||
'401':
|
'401':
|
||||||
$ref: '#/responses/401'
|
$ref: '#/responses/401'
|
||||||
'403':
|
'403':
|
||||||
@ -1036,9 +1032,7 @@ paths:
|
|||||||
$ref: '#/definitions/Instance'
|
$ref: '#/definitions/Instance'
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: Success
|
$ref: '#/responses/200'
|
||||||
schema:
|
|
||||||
$ref: '#/definitions/InstanceUpdateResp'
|
|
||||||
'400':
|
'400':
|
||||||
$ref: '#/responses/400'
|
$ref: '#/responses/400'
|
||||||
'401':
|
'401':
|
||||||
@ -2018,24 +2012,6 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
description: The timestamp of instance setting up
|
description: The timestamp of instance setting up
|
||||||
InstanceUpdateResp:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
updated:
|
|
||||||
type: integer
|
|
||||||
description: ID of instance updated
|
|
||||||
InstanceDeletedResp:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
removed:
|
|
||||||
type: integer
|
|
||||||
description: ID of instance removed
|
|
||||||
InstanceCreatedResp:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
description: ID of instance created
|
|
||||||
PreheatPolicy:
|
PreheatPolicy:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-openapi/runtime/middleware"
|
"github.com/go-openapi/runtime/middleware"
|
||||||
@ -68,7 +69,9 @@ func (api *preheatAPI) CreateInstance(ctx context.Context, params operation.Crea
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return api.SendError(ctx, err)
|
return api.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
return operation.NewCreateInstanceCreated()
|
|
||||||
|
location := fmt.Sprintf("%s/%s", strings.TrimSuffix(params.HTTPRequest.URL.Path, "/"), instance.Name)
|
||||||
|
return operation.NewCreateInstanceCreated().WithLocation(location)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *preheatAPI) DeleteInstance(ctx context.Context, params operation.DeleteInstanceParams) middleware.Responder {
|
func (api *preheatAPI) DeleteInstance(ctx context.Context, params operation.DeleteInstanceParams) middleware.Responder {
|
||||||
@ -238,7 +241,9 @@ func (api *preheatAPI) CreatePolicy(ctx context.Context, params operation.Create
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return api.SendError(ctx, err)
|
return api.SendError(ctx, err)
|
||||||
}
|
}
|
||||||
return operation.NewCreatePolicyCreated()
|
|
||||||
|
location := fmt.Sprintf("%s/%s", strings.TrimSuffix(params.HTTPRequest.URL.Path, "/"), policy.Name)
|
||||||
|
return operation.NewCreatePolicyCreated().WithLocation(location)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatePolicy is Update preheat policy
|
// UpdatePolicy is Update preheat policy
|
||||||
|
Loading…
Reference in New Issue
Block a user