ci: lint the swagger file (#14916)

Signed-off-by: He Weiwei <hweiwei@vmware.com>
This commit is contained in:
He Weiwei 2021-05-19 10:36:09 +08:00 committed by GitHub
parent 4492e47e89
commit c6bd7b2ec2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 197 additions and 49 deletions

View File

@ -2,3 +2,5 @@ src/portal/node_modules/
doc/ doc/
docs/ docs/
.git .git
make/common/config/
harbor-offline-installer-*.tgz

41
.spectral.yaml Normal file
View File

@ -0,0 +1,41 @@
extends: [[spectral:oas, all]]
functionsDir: "./tools/spectral/functions"
functions: [requireRequestId]
rules:
info-contact: false
info-license: false
license-url: false
no-$ref-siblings: false
oas2-valid-definition-example: false
oas2-valid-response-schema-example: false
openapi-tags: false
operation-default-response: false
operation-tag-defined: false
required-operationId:
description: must have a operationId.
given: $.paths[*][*]
severity: error
then:
field: operationId
function: truthy
camel-case-operationId:
description: should be camelCased.
type: style
given: $.paths[*][*].operationId
then:
function: casing
functionOptions:
type: camel
requestId-required:
description: must have a requestId paramaters.
given: $.paths[*][*]
severity: error
then:
field: parameters
function: requireRequestId

View File

@ -295,17 +295,34 @@ ifeq ($(CHARTFLAG), true)
DOCKERSAVE_PARA+= $(DOCKERIMAGENAME_CHART_SERVER):$(VERSIONTAG) DOCKERSAVE_PARA+= $(DOCKERIMAGENAME_CHART_SERVER):$(VERSIONTAG)
endif endif
RUNCONTAINER=$(DOCKERCMD) run --rm -u $(shell id -u):$(shell id -g) -v $(BUILDPATH):$(BUILDPATH) -w $(BUILDPATH)
# $1 the name of the docker image
# $2 the tag of the docker image
# $3 the command to build the docker image
define prepare_docker_image
@if [ "$(shell ${DOCKERIMAGES} -q $(1):$(2) 2> /dev/null)" == "" ]; then \
$(3) && echo "build $(1):$(2) successfully" || (echo "build $(1):$(2) failed" && exit 1) ; \
fi
endef
# lint swagger doc
SPECTRAL_IMAGENAME=goharbor/spectral
SPECTRAL_VERSION=v5.9.1
SPECTRAL_IMAGE_BUILD_CMD=${DOCKERBUILD} -f ${TOOLSPATH}/spectral/Dockerfile --build-arg GOLANG=${GOBUILDIMAGE} --build-arg SPECTRAL_VERSION=${SPECTRAL_VERSION} -t ${SPECTRAL_IMAGENAME}:$(SPECTRAL_VERSION) .
SPECTRAL=$(RUNCONTAINER) $(SPECTRAL_IMAGENAME):$(SPECTRAL_VERSION)
lint_apis:
$(call prepare_docker_image,${SPECTRAL_IMAGENAME},${SPECTRAL_VERSION},${SPECTRAL_IMAGE_BUILD_CMD})
$(SPECTRAL) lint ./api/v2.0/swagger.yaml
SWAGGER_IMAGENAME=goharbor/swagger SWAGGER_IMAGENAME=goharbor/swagger
SWAGGER_VERSION=v0.25.0 SWAGGER_VERSION=v0.25.0
SWAGGER=$(DOCKERCMD) run --rm -u $(shell id -u):$(shell id -g) -v $(BUILDPATH):$(BUILDPATH) -w $(BUILDPATH) ${SWAGGER_IMAGENAME}:${SWAGGER_VERSION} 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_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) . SWAGGER_IMAGE_BUILD_CMD=${DOCKERBUILD} -f ${TOOLSPATH}/swagger/Dockerfile --build-arg GOLANG=${GOBUILDIMAGE} --build-arg SWAGGER_VERSION=${SWAGGER_VERSION} -t ${SWAGGER_IMAGENAME}:$(SWAGGER_VERSION) .
SWAGGER_IMAGENAME:
@if [ "$(shell ${DOCKERIMAGES} -q ${SWAGGER_IMAGENAME}:$(SWAGGER_VERSION) 2> /dev/null)" == "" ]; then \
${SWAGGER_IMAGE_BUILD_CMD} && echo "build swagger image successfully" || (echo "build swagger image failed" && exit 1) ; \
fi
# $1 the path of swagger spec # $1 the path of swagger spec
# $2 the path of base directory for generating the files # $2 the path of base directory for generating the files
# $3 the name of the application # $3 the name of the application
@ -316,21 +333,18 @@ define swagger_generate_server
@$(SWAGGER_GENERATE_SERVER) -f $(1) -A $(3) --target $(2) @$(SWAGGER_GENERATE_SERVER) -f $(1) -A $(3) --target $(2)
endef endef
gen_apis: SWAGGER_IMAGENAME gen_apis: lint_apis
$(call prepare_docker_image,${SWAGGER_IMAGENAME},${SWAGGER_VERSION},${SWAGGER_IMAGE_BUILD_CMD})
$(call swagger_generate_server,api/v2.0/swagger.yaml,src/server/v2.0,harbor) $(call swagger_generate_server,api/v2.0/swagger.yaml,src/server/v2.0,harbor)
MOCKERY_IMAGENAME=goharbor/mockery MOCKERY_IMAGENAME=goharbor/mockery
MOCKERY_VERSION=v2.1.0 MOCKERY_VERSION=v2.1.0
MOCKERY=$(DOCKERCMD) run --rm -u $(shell id -u):$(shell id -g) -v $(BUILDPATH):$(BUILDPATH) -w $(BUILDPATH) ${MOCKERY_IMAGENAME}:${MOCKERY_VERSION} MOCKERY=$(RUNCONTAINER) ${MOCKERY_IMAGENAME}:${MOCKERY_VERSION}
MOCKERY_IMAGE_BUILD_CMD=${DOCKERBUILD} -f ${TOOLSPATH}/mockery/Dockerfile --build-arg GOLANG=${GOBUILDIMAGE} --build-arg MOCKERY_VERSION=${MOCKERY_VERSION} -t ${MOCKERY_IMAGENAME}:$(MOCKERY_VERSION) . MOCKERY_IMAGE_BUILD_CMD=${DOCKERBUILD} -f ${TOOLSPATH}/mockery/Dockerfile --build-arg GOLANG=${GOBUILDIMAGE} --build-arg MOCKERY_VERSION=${MOCKERY_VERSION} -t ${MOCKERY_IMAGENAME}:$(MOCKERY_VERSION) .
MOCKERY_IMAGE: gen_mocks:
@if [ "$(shell ${DOCKERIMAGES} -q ${MOCKERY_IMAGENAME}:$(MOCKERY_VERSION) 2> /dev/null)" == "" ]; then \ $(call prepare_docker_image,${MOCKERY_IMAGENAME},${MOCKERY_VERSION},${MOCKERY_IMAGE_BUILD_CMD})
${MOCKERY_IMAGE_BUILD_CMD} && echo "build mockery image successfully" || (echo "build mockery image failed" && exit 1) ; \
fi
gen_mocks: MOCKERY_IMAGE
${MOCKERY} go generate ./... ${MOCKERY} go generate ./...
mocks_check: gen_mocks mocks_check: gen_mocks

View File

@ -26,6 +26,8 @@ paths:
tags: tags:
- health - health
operationId: getHealth operationId: getHealth
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: The health status of Harbor components description: The health status of Harbor components
@ -39,6 +41,7 @@ paths:
description: |- description: |-
The Search endpoint returns information about the projects, repositories and helm charts offered at public status or related to the current logged in user. The response includes the project, repository list and charts in a proper display order. The Search endpoint returns information about the projects, repositories and helm charts offered at public status or related to the current logged in user. The response includes the project, repository list and charts in a proper display order.
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: q - name: q
in: query in: query
description: Search parameter for project and repository name. description: Search parameter for project and repository name.
@ -61,6 +64,8 @@ paths:
tags: tags:
- statistic - statistic
operationId: getStatistic operationId: getStatistic
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: The statistic information description: The statistic information
@ -77,6 +82,7 @@ paths:
description: | description: |
This endpoint ping the available ldap service for test related configuration parameters. This endpoint ping the available ldap service for test related configuration parameters.
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: ldapconf - name: ldapconf
in: body in: body
description: 'ldap configuration. support input ldap service configuration. If it is a empty request, will load current configuration from the system.' description: 'ldap configuration. support input ldap service configuration. If it is a empty request, will load current configuration from the system.'
@ -105,6 +111,7 @@ paths:
description: | description: |
This endpoint searches the available ldap users based on related configuration parameters. Support searched by input ladp configuration, load configuration from the system and specific filter. This endpoint searches the available ldap users based on related configuration parameters. Support searched by input ladp configuration, load configuration from the system and specific filter.
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: username - name: username
in: query in: query
type: string type: string
@ -134,6 +141,7 @@ paths:
description: | description: |
This endpoint adds the selected available ldap users to harbor based on related configuration parameters from the system. System will try to guess the user email address and realname, add to harbor user information. If have errors when import user, will return the list of importing failed uid and the failed reason. This endpoint adds the selected available ldap users to harbor based on related configuration parameters from the system. System will try to guess the user email address and realname, add to harbor user information. If have errors when import user, will return the list of importing failed uid and the failed reason.
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: uid_list - name: uid_list
in: body in: body
description: The uid listed for importing. This list will check users validity of ldap service based on configuration from the system. description: The uid listed for importing. This list will check users validity of ldap service based on configuration from the system.
@ -166,6 +174,7 @@ paths:
description: | description: |
This endpoint searches the available ldap groups based on related configuration parameters. support to search by groupname or groupdn. This endpoint searches the available ldap groups based on related configuration parameters. support to search by groupname or groupdn.
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: groupname - name: groupname
in: query in: query
type: string type: string
@ -3126,6 +3135,7 @@ paths:
- replication - replication
operationId: listReplicationPolicies operationId: listReplicationPolicies
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/query' - $ref: '#/parameters/query'
- $ref: '#/parameters/sort' - $ref: '#/parameters/sort'
- $ref: '#/parameters/page' - $ref: '#/parameters/page'
@ -3162,6 +3172,7 @@ paths:
- replication - replication
operationId: createReplicationPolicy operationId: createReplicationPolicy
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: policy - name: policy
in: body in: body
description: The replication policy description: The replication policy
@ -3189,6 +3200,7 @@ paths:
- replication - replication
operationId: getReplicationPolicy operationId: getReplicationPolicy
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: id - name: id
in: path in: path
type: integer type: integer
@ -3213,6 +3225,7 @@ paths:
- replication - replication
operationId: deleteReplicationPolicy operationId: deleteReplicationPolicy
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: id - name: id
in: path in: path
type: integer type: integer
@ -3239,6 +3252,7 @@ paths:
- replication - replication
operationId: updateReplicationPolicy operationId: updateReplicationPolicy
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: id - name: id
in: path in: path
type: integer type: integer
@ -3272,6 +3286,7 @@ paths:
- replication - replication
operationId: listReplicationExecutions operationId: listReplicationExecutions
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/sort' - $ref: '#/parameters/sort'
- $ref: '#/parameters/page' - $ref: '#/parameters/page'
- $ref: '#/parameters/pageSize' - $ref: '#/parameters/pageSize'
@ -3317,6 +3332,7 @@ paths:
- replication - replication
operationId: startReplication operationId: startReplication
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: execution - name: execution
in: body in: body
description: The ID of policy that the execution belongs to description: The ID of policy that the execution belongs to
@ -3342,6 +3358,7 @@ paths:
- replication - replication
operationId: getReplicationExecution operationId: getReplicationExecution
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: id - name: id
in: path in: path
type: integer type: integer
@ -3368,6 +3385,7 @@ paths:
- replication - replication
operationId: stopReplication operationId: stopReplication
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: id - name: id
in: path in: path
type: integer type: integer
@ -3393,6 +3411,7 @@ paths:
- replication - replication
operationId: listReplicationTasks operationId: listReplicationTasks
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/sort' - $ref: '#/parameters/sort'
- $ref: '#/parameters/page' - $ref: '#/parameters/page'
- $ref: '#/parameters/pageSize' - $ref: '#/parameters/pageSize'
@ -3442,6 +3461,7 @@ paths:
produces: produces:
- text/plain - text/plain
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: id - name: id
in: path in: path
type: integer type: integer
@ -3731,6 +3751,8 @@ paths:
tags: tags:
- scanAll - scanAll
operationId: getLatestScanAllMetrics operationId: getLatestScanAllMetrics
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: OK description: OK
@ -3752,6 +3774,8 @@ paths:
- scanAll - scanAll
operationId: getLatestScheduledScanAllMetrics operationId: getLatestScheduledScanAllMetrics
deprecated: true deprecated: true
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: OK description: OK
@ -3773,6 +3797,8 @@ paths:
This API is for retrieving general system info, this can be called by anonymous request. Some attributes will be omitted in the response when this API is called by anonymous request. This API is for retrieving general system info, this can be called by anonymous request. Some attributes will be omitted in the response when this API is called by anonymous request.
tags: tags:
- systeminfo - systeminfo
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: Get general info successfully. description: Get general info successfully.
@ -3788,6 +3814,8 @@ paths:
This endpoint is for retrieving system volume info that only provides for admin user. Note that the response only reflects the storage status of local disk. This endpoint is for retrieving system volume info that only provides for admin user. Note that the response only reflects the storage status of local disk.
tags: tags:
- systeminfo - systeminfo
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: Get system volumes successfully. description: Get system volumes successfully.
@ -3811,6 +3839,8 @@ paths:
- systeminfo - systeminfo
produces: produces:
- application/octet-stream - application/octet-stream
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: Get default root certificate successfully. description: Get default root certificate successfully.
@ -3833,6 +3863,7 @@ paths:
- oidc - oidc
operationId: pingOIDC operationId: pingOIDC
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: endpoint - name: endpoint
in: body in: body
description: Request body for OIDC endpoint to be tested. description: Request body for OIDC endpoint to be tested.
@ -3863,6 +3894,7 @@ paths:
- gc - gc
operationId: getGCHistory operationId: getGCHistory
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/query' - $ref: '#/parameters/query'
- $ref: '#/parameters/sort' - $ref: '#/parameters/sort'
- $ref: '#/parameters/page' - $ref: '#/parameters/page'
@ -3893,6 +3925,7 @@ paths:
description: This endpoint let user get gc status filtered by specific ID. description: This endpoint let user get gc status filtered by specific ID.
operationId: getGC operationId: getGC
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/gcId' - $ref: '#/parameters/gcId'
tags: tags:
- gc - gc
@ -3915,6 +3948,7 @@ paths:
description: This endpoint let user get gc job logs filtered by specific ID. description: This endpoint let user get gc job logs filtered by specific ID.
operationId: getGCLog operationId: getGCLog
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/gcId' - $ref: '#/parameters/gcId'
tags: tags:
- gc - gc
@ -3942,6 +3976,8 @@ paths:
operationId: getGCSchedule operationId: getGCSchedule
tags: tags:
- gc - gc
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: Get gc's schedule. description: Get gc's schedule.
@ -3959,6 +3995,7 @@ paths:
This endpoint is for update gc schedule. This endpoint is for update gc schedule.
operationId: createGCSchedule operationId: createGCSchedule
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: schedule - name: schedule
in: body in: body
required: true required: true
@ -3986,6 +4023,7 @@ paths:
This endpoint is for update gc schedule. This endpoint is for update gc schedule.
operationId: updateGCSchedule operationId: updateGCSchedule
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: schedule - name: schedule
in: body in: body
required: true required: true
@ -4012,6 +4050,8 @@ paths:
operationId: getSystemCVEAllowlist operationId: getSystemCVEAllowlist
tags: tags:
- SystemCVEAllowlist - SystemCVEAllowlist
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: Successfully retrieved the CVE allowlist. description: Successfully retrieved the CVE allowlist.
@ -4029,6 +4069,7 @@ paths:
tags: tags:
- SystemCVEAllowlist - SystemCVEAllowlist
parameters: parameters:
- $ref: '#/parameters/requestId'
- in: body - in: body
name: allowlist name: allowlist
description: The allowlist with new content description: The allowlist with new content
@ -4050,6 +4091,8 @@ paths:
tags: tags:
- scanAll - scanAll
operationId: getScanAllSchedule operationId: getScanAllSchedule
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: Get a schedule for the scan all job, which scans all of images in Harbor. description: Get a schedule for the scan all job, which scans all of images in Harbor.
@ -4067,6 +4110,7 @@ paths:
summary: Update scan all's schedule. summary: Update scan all's schedule.
description: This endpoint is for updating the schedule of scan all job, which scans all of images in Harbor. description: This endpoint is for updating the schedule of scan all job, which scans all of images in Harbor.
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: schedule - name: schedule
in: body in: body
required: true required: true
@ -4093,6 +4137,7 @@ paths:
summary: Create a schedule or a manual trigger for the scan all job. summary: Create a schedule or a manual trigger for the scan all job.
description: This endpoint is for creating a schedule or a manual trigger for the scan all job, which scans all of images in Harbor. description: This endpoint is for creating a schedule or a manual trigger for the scan all job, which scans all of images in Harbor.
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: schedule - name: schedule
in: body in: body
required: true required: true
@ -4119,12 +4164,15 @@ paths:
$ref: '#/responses/500' $ref: '#/responses/500'
/ping: /ping:
get: get:
operationId: getPing
summary: Ping Harbor to check if it's alive. summary: Ping Harbor to check if it's alive.
description: This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components. description: This API simply replies a pong to indicate the process to handle API is up, disregarding the health status of dependent components.
tags: tags:
- ping - ping
produces: produces:
- text/plain - text/plain
parameters:
- $ref: '#/parameters/requestId'
responses: responses:
'200': '200':
description: The API server is alive description: The API server is alive
@ -4666,6 +4714,7 @@ paths:
- scanner - scanner
operationId: setScannerAsDefault operationId: setScannerAsDefault
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: registration_id - name: registration_id
in: path in: path
description: The scanner registration identifier. description: The scanner registration identifier.
@ -4883,6 +4932,7 @@ paths:
description: | description: |
This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB. This endpoint let administrator of Harbor mark a registered user as removed.It actually won't be deleted from DB.
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: user_id - name: user_id
in: path in: path
type: integer type: integer
@ -4910,6 +4960,7 @@ paths:
- user - user
operationId: setUserSysAdmin operationId: setUserSysAdmin
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: user_id - name: user_id
in: path in: path
type: integer type: integer
@ -4941,6 +4992,7 @@ paths:
- user - user
operationId: updateUserPassword operationId: updateUserPassword
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: user_id - name: user_id
in: path in: path
type: integer type: integer
@ -4970,6 +5022,7 @@ paths:
- user - user
operationId: getCurrentUserPermissions operationId: getCurrentUserPermissions
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: scope - name: scope
in: query in: query
type: string type: string
@ -5090,6 +5143,7 @@ paths:
- label - label
operationId: CreateLabel operationId: CreateLabel
parameters: parameters:
- $ref: '#/parameters/requestId'
- name: label - name: label
in: body in: body
description: The json object of label. description: The json object of label.
@ -5122,6 +5176,7 @@ paths:
- label - label
operationId: GetLabelByID operationId: GetLabelByID
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/labelId' - $ref: '#/parameters/labelId'
responses: responses:
'200': '200':
@ -5142,6 +5197,7 @@ paths:
- label - label
operationId: UpdateLabel operationId: UpdateLabel
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/labelId' - $ref: '#/parameters/labelId'
- name: label - name: label
in: body in: body
@ -5170,6 +5226,7 @@ paths:
- label - label
operationId: DeleteLabel operationId: DeleteLabel
parameters: parameters:
- $ref: '#/parameters/requestId'
- $ref: '#/parameters/labelId' - $ref: '#/parameters/labelId'
responses: responses:
'200': '200':
@ -5851,12 +5908,12 @@ definitions:
type: string type: string
format: date-time format: date-time
description: 'The start time of the scan process that generating report' description: 'The start time of the scan process that generating report'
example: '2006-01-02T14:04:05' example: '2006-01-02T14:04:05Z'
end_time: end_time:
type: string type: string
format: date-time format: date-time
description: 'The end time of the scan process that generating report' description: 'The end time of the scan process that generating report'
example: '2006-01-02T15:04:05' example: '2006-01-02T15:04:05Z'
complete_percent: complete_percent:
type: integer type: integer
description: 'The complete percent of the scanning which value is between 0 and 100' description: 'The complete percent of the scanning which value is between 0 and 100'
@ -5912,7 +5969,7 @@ definitions:
op_time: op_time:
type: string type: string
format: date-time format: date-time
example: '2006-01-02T15:04:05' example: '2006-01-02T15:04:05Z'
description: The time when this operation is triggered. description: The time when this operation is triggered.
Metadata: Metadata:
type: object type: object
@ -7372,7 +7429,7 @@ definitions:
adapter: adapter:
type: string type: string
description: Optional property to describe the name of the scanner registration description: Optional property to describe the name of the scanner registration
example: "Clair" example: "Trivy"
vendor: vendor:
type: string type: string
description: Optional property to describe the vendor of the scanner registration description: Optional property to describe the vendor of the scanner registration

View File

@ -79,12 +79,14 @@ export class GcComponent implements OnInit {
}, ONE_MINUTE); }, ONE_MINUTE);
this.gcService.createGCSchedule({ this.gcService.createGCSchedule({
parameters: {
delete_untagged: this.shouldDeleteUntagged,
dry_run: false
},
schedule: { schedule: {
type: ScheduleType.MANUAL parameters: {
delete_untagged: this.shouldDeleteUntagged,
dry_run: false
},
schedule: {
type: ScheduleType.MANUAL
}
} }
}).subscribe( }).subscribe(
response => { response => {
@ -99,12 +101,14 @@ export class GcComponent implements OnInit {
dryRun() { dryRun() {
this.dryRunOnGoing = true; this.dryRunOnGoing = true;
this.gcService.createGCSchedule({ this.gcService.createGCSchedule({
parameters: {
delete_untagged: this.shouldDeleteUntagged,
dry_run: true
},
schedule: { schedule: {
type: ScheduleType.MANUAL parameters: {
delete_untagged: this.shouldDeleteUntagged,
dry_run: true
},
schedule: {
type: ScheduleType.MANUAL
}
} }
}) })
.pipe(finalize(() => this.dryRunOnGoing = false)) .pipe(finalize(() => this.dryRunOnGoing = false))
@ -125,13 +129,15 @@ export class GcComponent implements OnInit {
saveGcSchedule(cron: string) { saveGcSchedule(cron: string) {
if (this.originCron && this.originCron.type !== ScheduleType.NONE) {// no schedule, then create if (this.originCron && this.originCron.type !== ScheduleType.NONE) {// no schedule, then create
this.gcService.createGCSchedule({ this.gcService.createGCSchedule({
parameters: {
delete_untagged: this.shouldDeleteUntagged,
dry_run: false
},
schedule: { schedule: {
type: GcComponent.getScheduleType(cron), parameters: {
cron: cron delete_untagged: this.shouldDeleteUntagged,
dry_run: false
},
schedule: {
type: GcComponent.getScheduleType(cron),
cron: cron
}
} }
}).subscribe( }).subscribe(
response => { response => {
@ -145,13 +151,15 @@ export class GcComponent implements OnInit {
); );
} else { } else {
this.gcService.updateGCSchedule({ this.gcService.updateGCSchedule({
parameters: {
delete_untagged: this.shouldDeleteUntagged,
dry_run: false
},
schedule: { schedule: {
type: GcComponent.getScheduleType(cron), parameters: {
cron: cron delete_untagged: this.shouldDeleteUntagged,
dry_run: false
},
schedule: {
type: GcComponent.getScheduleType(cron),
cron: cron
}
} }
}).subscribe( }).subscribe(
response => { response => {

View File

@ -73,7 +73,9 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
getExecutionDetail(): void { getExecutionDetail(): void {
this.inProgress = true; this.inProgress = true;
if (this.executionId) { if (this.executionId) {
this.replicationService.getReplicationExecution(+this.executionId) this.replicationService.getReplicationExecution({
id: +this.executionId
})
.pipe(finalize(() => (this.inProgress = false))) .pipe(finalize(() => (this.inProgress = false)))
.subscribe(res => { .subscribe(res => {
this.execution = res; this.execution = res;
@ -136,8 +138,9 @@ export class ReplicationTasksComponent implements OnInit, OnDestroy {
stopJob() { stopJob() {
this.stopOnGoing = true; this.stopOnGoing = true;
this.replicationService.stopReplication(+this.executionId) this.replicationService.stopReplication({
.subscribe(response => { id: +this.executionId
}).subscribe(response => {
this.stopOnGoing = false; this.stopOnGoing = false;
this.getExecutionDetail(); this.getExecutionDetail();
this.translate.get("REPLICATION.STOP_SUCCESS", { param: this.executionId }).subscribe((res: string) => { this.translate.get("REPLICATION.STOP_SUCCESS", { param: this.executionId }).subscribe((res: string) => {

View File

@ -33,8 +33,9 @@ export class ReplicationTasksRoutingResolverService implements Resolve<Replicati
if (!executionId) { if (!executionId) {
executionId = route.queryParams['project_id']; executionId = route.queryParams['project_id'];
} }
return this.replicationService.getReplicationExecution(+executionId) return this.replicationService.getReplicationExecution({
.pipe(map((res: ReplicationExecution) => { id: +executionId
}).pipe(map((res: ReplicationExecution) => {
if (!res) { if (!res) {
this.router.navigate(['/harbor', 'projects']); this.router.navigate(['/harbor', 'projects']);
} }

View File

@ -137,8 +137,9 @@ export class CreateEditLabelComponent implements OnInit, OnDestroy {
if (this.labelId <= 0) { if (this.labelId <= 0) {
this.labelModel.scope = this.scope; this.labelModel.scope = this.scope;
this.labelModel.project_id = this.projectId; this.labelModel.project_id = this.projectId;
this.labelService.CreateLabel(this.labelModel) this.labelService.CreateLabel({
.subscribe(res => { label: this.labelModel
}).subscribe(res => {
this.inProgress = false; this.inProgress = false;
this.reload.emit(); this.reload.emit();
this.labelModel = this.initLabel(); this.labelModel = this.initLabel();

View File

@ -186,7 +186,7 @@ export class LabelComponent implements OnInit {
this.operationService.publishInfo(operMessage); this.operationService.publishInfo(operMessage);
return this.labelService return this.labelService
.DeleteLabel(target.id) .DeleteLabel({labelId: target.id})
.pipe(map( .pipe(map(
response => { response => {
this.translateService.get('BATCH.DELETED_SUCCESS') this.translateService.get('BATCH.DELETED_SUCCESS')

View File

@ -0,0 +1,8 @@
ARG GOLANG
FROM ${GOLANG}
ARG SPECTRAL_VERSION
RUN curl -fsSL -o /usr/bin/spectral https://github.com/stoplightio/spectral/releases/download/$SPECTRAL_VERSION/spectral-linux && chmod +x /usr/bin/spectral
ENTRYPOINT ["/usr/bin/spectral"]
CMD ["--version"]

View File

@ -0,0 +1,13 @@
module.exports = parameters => {
for (const param of parameters) {
if (param.name === 'X-Request-Id' && param.in === 'header') {
return
}
}
return [
{
message: 'X-Request-Id must be in "parameters".',
},
];
};