From 9973d99f3e255e002873df590bff52e18c23de69 Mon Sep 17 00:00:00 2001 From: Shijun Sun <30999793+AllForNothing@users.noreply.github.com> Date: Fri, 24 Feb 2023 14:47:42 +0800 Subject: [PATCH] Remove chart api (#18265) * remove chart api from swagger Delete the api path for chart in the swagger Signed-off-by: Wang Yan * Remove chart APIs 1. Remove some chart-related steps for Dockerfile for portal container 2. Remove chart APIs for API center Signed-off-by: AllForNothing --------- Signed-off-by: Wang Yan Signed-off-by: AllForNothing Co-authored-by: Wang Yan --- Makefile | 6 - README.md | 1 - api/swagger.yaml | 533 ------------------ api/v2.0/README.md | 4 +- api/v2.0/legacy_swagger.yaml | 370 ------------ api/v2.0/swagger.yaml | 106 +--- make/photon/portal/Dockerfile | 12 +- src/portal/app-swagger-ui/src/index.js | 52 +- src/portal/docker-build/Dockerfile | 10 +- src/portal/scripts/convert-yaml-to-json.js | 7 +- .../list-project-ro.component.spec.ts | 2 - 11 files changed, 18 insertions(+), 1085 deletions(-) delete mode 100644 api/swagger.yaml delete mode 100644 api/v2.0/legacy_swagger.yaml diff --git a/Makefile b/Makefile index 21c01ec3f..d98cb8db6 100644 --- a/Makefile +++ b/Makefile @@ -564,14 +564,8 @@ swagger_client: @echo "Generate swagger client" wget https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/4.3.1/openapi-generator-cli-4.3.1.jar -O openapi-generator-cli.jar rm -rf harborclient - mkdir -p harborclient/harbor_client - mkdir -p harborclient/harbor_swagger_client mkdir -p harborclient/harbor_v2_swagger_client - java -jar openapi-generator-cli.jar generate -i api/swagger.yaml -g python -o harborclient/harbor_client --package-name client - java -jar openapi-generator-cli.jar generate -i api/v2.0/legacy_swagger.yaml -g python -o harborclient/harbor_swagger_client --package-name swagger_client java -jar openapi-generator-cli.jar generate -i api/v2.0/swagger.yaml -g python -o harborclient/harbor_v2_swagger_client --package-name v2_swagger_client - cd harborclient/harbor_client; python ./setup.py install - cd harborclient/harbor_swagger_client; python ./setup.py install cd harborclient/harbor_v2_swagger_client; python ./setup.py install pip install docker -q pip freeze diff --git a/README.md b/README.md index 101d70841..923eaf1fa 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,6 @@ For learning the architecture design of Harbor, check the document [Architecture * Harbor RESTful API: The APIs for most administrative operations of Harbor and can be used to perform integrations with Harbor programmatically. * Part 1: [New or changed APIs](https://editor.swagger.io/?url=https://raw.githubusercontent.com/goharbor/harbor/main/api/v2.0/swagger.yaml) - * Part 2: [Legacy APIs](https://editor.swagger.io/?url=https://raw.githubusercontent.com/goharbor/harbor/main/api/v2.0/legacy_swagger.yaml) ## Install & Run diff --git a/api/swagger.yaml b/api/swagger.yaml deleted file mode 100644 index d53124f67..000000000 --- a/api/swagger.yaml +++ /dev/null @@ -1,533 +0,0 @@ -swagger: '2.0' -info: - title: Harbor API - description: These APIs provide services for manipulating Harbor project. - version: '' -host: localhost -schemes: - - http - - https -basePath: /api/ -produces: - - application/json -consumes: - - application/json -securityDefinitions: - basic: - type: basic -security: - - basic: [] - - {} -paths: - /version: - get: - summary: Get API version - description: Get the version of API that supported by the Harbor instance. - tags: - - Version - responses: - '200': - description: The supported API version - schema: - type: object - properties: - version: - type: string - - /chartrepo/health: - get: - summary: Check the health of chart repository service. - description: Check the health of chart repository service. - tags: - - Chart Repository - responses: - '200': - description: Health status of chart repository service is returned. - schema: - type: object - properties: - healthy: - type: boolean - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - /chartrepo/{repo}/charts: - get: - summary: Get all the charts under the specified project - description: Get all the charts under the specified project - tags: - - Chart Repository - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - responses: - '200': - description: Searched for charts of project in Harbor successfully. - schema: - type: array - items: - $ref: '#/definitions/ChartInfoEntry' - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - post: - summary: Upload a chart file to the specified project. - description: 'Upload a chart file to the specified project. With this API, the corresponding provance file can be uploaded together with chart file at once.' - tags: - - Chart Repository - consumes: - - multipart/form-data - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: chart - in: formData - type: file - required: true - description: The chart file - - name: prov - in: formData - type: file - required: false - description: The provance file - responses: - '201': - description: The specified chart is successfully uploaded. - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - '507': - $ref: '#/definitions/InsufficientStorageChartAPIError' - /chartrepo/{repo}/charts/{name}: - get: - summary: Get all the versions of the specified chart - description: Get all the versions of the specified chart - tags: - - Chart Repository - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: name - in: path - type: string - required: true - description: The chart name - responses: - '200': - description: Retrieved all versions of the specified chart - schema: - $ref: '#/definitions/ChartVersions' - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '404': - $ref: '#/definitions/NotFoundChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - delete: - summary: Delete all the versions of the specified chart - description: Delete all the versions of the specified chart - tags: - - Chart Repository - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: name - in: path - type: string - required: true - description: The chart name - responses: - '200': - description: The specified chart entry is successfully deleted. - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - /chartrepo/{repo}/charts/{name}/{version}: - get: - summary: Get the specified chart version - description: Get the specified chart version - tags: - - Chart Repository - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: name - in: path - type: string - required: true - description: The chart name - - name: version - in: path - type: string - required: true - description: The chart version - responses: - '200': - description: Successfully retrieved the chart version - schema: - $ref: '#/definitions/ChartVersionDetails' - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '404': - $ref: '#/definitions/NotFoundChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - delete: - summary: Delete the specified chart version - description: Delete the specified chart version - tags: - - Chart Repository - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: name - in: path - type: string - required: true - description: The chart name - - name: version - in: path - type: string - required: true - description: The chart version - responses: - '200': - description: The specified chart entry is successfully deleted. - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '404': - $ref: '#/definitions/NotFoundChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - /chartrepo/{repo}/prov: - post: - summary: Upload a provance file to the specified project. - description: Upload a provance file to the specified project. The provance file should be targeted for an existing chart file. - tags: - - Chart Repository - consumes: - - multipart/form-data - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: prov - in: formData - type: file - required: true - description: The provance file - responses: - '201': - description: The provance file is successfully uploaded. - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - '507': - $ref: '#/definitions/InsufficientStorageChartAPIError' - /chartrepo/charts: - post: - summary: Upload a chart file to the defult 'library' project. - description: Upload a chart file to the default 'library' project. Uploading together with the prov file at the same time is also supported. - tags: - - Chart Repository - consumes: - - multipart/form-data - parameters: - - name: chart - in: formData - type: file - required: true - description: The chart file - - name: prov - in: formData - type: file - required: false - description: The provance file - responses: - '201': - description: The specified chart is successfully uploaded. - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - '507': - $ref: '#/definitions/InsufficientStorageChartAPIError' -definitions: - ChartAPIError: - description: The error object returned by chart repository API - type: object - required: - - error - properties: - error: - type: string - description: The error message returned by the chart API - UnauthorizedChartAPIError: - description: Unauthorized - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - ForbiddenChartAPIError: - description: Operation is forbidden or quota exceeded - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - InternalChartAPIError: - description: Internal server error occurred - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - NotFoundChartAPIError: - description: Not found - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - InsufficientStorageChartAPIError: - description: Insufficient storage - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - ChartInfoEntry: - type: object - description: The object contains basic chart information - required: - - name - - total_versions - - created - properties: - name: - type: string - description: Name of chart - total_versions: - type: integer - description: Total count of chart versions - latest_version: - type: string - description: latest version of chart - created: - type: string - description: The created time of chart - updated: - type: string - description: The created time of chart - icon: - type: string - description: The icon path of chart - home: - type: string - description: The home website of chart - deprecated: - type: boolean - description: Flag to indicate if the chart is deprecated - ChartInfoList: - type: array - description: The chart list under the project - items: - $ref: '#/definitions/ChartInfoEntry' - ChartVersion: - type: object - description: A specified chart entry - allOf: - - $ref: '#/definitions/ChartMetadata' - - type: object - properties: - created: - type: string - description: The created time of the chart entry - removed: - type: boolean - description: A flag to indicate if the chart entry is removed - digest: - type: string - description: The digest value of the chart entry - urls: - type: array - description: The urls of the chart entry - items: - type: string - properties: - labels: - $ref: '#/definitions/Labels' - ChartVersions: - type: array - description: A list of chart entry - items: - $ref: '#/definitions/ChartVersion' - ChartVersionDetails: - type: object - description: The detailed information of the chart entry - properties: - metadata: - $ref: '#/definitions/ChartVersion' - security: - $ref: '#/definitions/SecurityReport' - dependencies: - type: array - items: - $ref: '#/definitions/Dependency' - values: - type: object - additionalProperties: - type: object - files: - type: object - additionalProperties: - type: string - labels: - $ref: '#/definitions/Labels' - ChartMetadata: - type: object - description: The metadata of chart version - required: - - name - - version - - engine - - icon - - apiVersion - - appVersion - properties: - name: - type: string - description: The name of the chart - home: - type: string - description: The URL to the relevant project page - sources: - type: array - description: The URL to the source code of chart - items: - type: string - version: - type: string - description: A SemVer 2 version of chart - description: - type: string - description: A one-sentence description of chart - keywords: - type: array - description: A list of string keywords - items: - type: string - engine: - type: string - description: The name of template engine - icon: - type: string - description: The URL to an icon file - apiVersion: - type: string - description: The API version of this chart - appVersion: - type: string - description: The version of the application enclosed in the chart - deprecated: - type: boolean - description: Whether or not this chart is deprecated - Labels: - type: array - description: A list of label - items: - $ref: '#/definitions/Label' - Label: - type: object - properties: - id: - type: integer - description: The ID of label. - name: - type: string - description: The name of label. - description: - type: string - description: The description of label. - color: - type: string - description: The color of label. - scope: - type: string - description: 'The scope of label, g for global labels and p for project labels.' - project_id: - type: integer - description: The project ID if the label is a project label. - creation_time: - type: string - description: The creation time of label. - update_time: - type: string - description: The update time of label. - deleted: - type: boolean - description: The label is deleted or not. - SecurityReport: - type: object - description: The security information of the chart - properties: - signature: - $ref: '#/definitions/DigitalSignature' - Dependency: - type: object - description: Another chart the chart depends on - required: - - name - - version - properties: - name: - type: string - description: The name of the chart denpendency - version: - type: string - description: The version of the chart dependency - repository: - type: string - description: The URL to the repository - DigitalSignature: - type: object - description: The signature of the chart - properties: - signed: - type: boolean - description: A flag to indicate if the chart is signed - prov_file: - type: string - description: The URL of the provance file diff --git a/api/v2.0/README.md b/api/v2.0/README.md index 193683209..7d3d4b5aa 100644 --- a/api/v2.0/README.md +++ b/api/v2.0/README.md @@ -9,10 +9,10 @@ This file lists all the files that are referring the swagger yaml file. - docs/configure_swagger.md - `https://raw.githubusercontent.com/goharbor/harbor/master/api/harbor/swagger.yaml` - make/photon/portal/Dockerfile - - `COPY ./api/harbor/swagger.yaml /build_dir` + - `COPY ./api/v2.0/swagger.yaml /build_dir/swagger.yaml` - tests/swaggerchecker.sh - `HARBOR_SWAGGER_FILE="https://raw.githubusercontent.com/$TRAVIS_REPO_SLUG/$TRAVIS_COMMIT/api/harbor/swagger.yaml"` - else `HARBOR_SWAGGER_FILE="https://raw.githubusercontent.com/$TRAVIS_PULL_REQUEST_SLUG/$TRAVIS_PULL_REQUEST_SHA/api/harbor/swagger.yaml"` -**Notes:** Base path is the code repository root dir. \ No newline at end of file +**Notes:** Base path is the code repository root dir. diff --git a/api/v2.0/legacy_swagger.yaml b/api/v2.0/legacy_swagger.yaml deleted file mode 100644 index 5cfd0d3ac..000000000 --- a/api/v2.0/legacy_swagger.yaml +++ /dev/null @@ -1,370 +0,0 @@ -swagger: '2.0' -info: - title: Harbor API - description: These APIs provide services for manipulating Harbor project. - version: '2.0' -host: localhost -schemes: - - http - - https -basePath: /api/v2.0 -produces: - - application/json - - text/plain -consumes: - - application/json -securityDefinitions: - basic: - type: basic -security: - - basic: [] - - {} -paths: - /chartrepo/{repo}/charts/{name}/{version}/labels: - get: - summary: Return the attached labels of chart. - description: Return the attached labels of the specified chart version. - tags: - - Products - - Chart Repository - - Label - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: name - in: path - type: string - required: true - description: The chart name - - name: version - in: path - type: string - required: true - description: The chart version - responses: - '200': - $ref: '#/definitions/Labels' - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '404': - $ref: '#/definitions/NotFoundChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' - post: - summary: Mark label to chart. - description: Mark label to the specified chart version. - tags: - - Products - - Chart Repository - - Label - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: name - in: path - type: string - required: true - description: The chart name - - name: version - in: path - type: string - required: true - description: The chart version - - name: label - in: body - required: true - schema: - $ref: '#/definitions/Label' - description: 'The label being marked to the chart version' - responses: - '200': - description: The label is successfully marked to the chart version. - '400': - $ref: '#/definitions/BadRequestFormatedError' - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '404': - $ref: '#/definitions/NotFoundChartAPIError' - '409': - $ref: '#/definitions/ConflictFormatedError' - '500': - $ref: '#/definitions/InternalChartAPIError' - /chartrepo/{repo}/charts/{name}/{version}/labels/{id}: - delete: - summary: Remove label from chart. - description: Remove label from the specified chart version. - tags: - - Products - - Chart Repository - - Label - parameters: - - name: repo - in: path - type: string - required: true - description: The project name - - name: name - in: path - type: string - required: true - description: The chart name - - name: version - in: path - type: string - required: true - description: The chart version - - name: id - in: path - type: integer - required: true - description: The label ID - responses: - '200': - description: The label is successfully unmarked from the chart version. - '400': - $ref: '#/definitions/BadRequestFormatedError' - '401': - $ref: '#/definitions/UnauthorizedChartAPIError' - '403': - $ref: '#/definitions/ForbiddenChartAPIError' - '404': - $ref: '#/definitions/NotFoundChartAPIError' - '500': - $ref: '#/definitions/InternalChartAPIError' -responses: - OK: - description: 'Success' - Created: - description: 'Created' - headers: - Location: - type: string - description: The URL of the created resource - BadRequest: - description: 'Bad Request' - Unauthorized: - description: 'Unauthorized' - Forbidden: - description: 'Forbidden' - NotFound: - description: 'Not Found' - Conflict: - description: 'Conflict' - PreconditionFailed: - description: 'Precondition Failed' - UnsupportedMediaType: - description: 'The Media Type of the request is not supported, it has to be "application/json"' - InternalServerError: - description: 'Internal Server Error' -definitions: - EmailServerSetting: - type: object - properties: - email_host: - type: string - description: The host of email server. - email_port: - type: integer - description: The port of email server. - email_username: - type: string - description: The username of email server. - email_password: - type: string - description: The password of email server. - email_ssl: - type: boolean - description: Use ssl/tls or not. - email_identity: - type: string - description: The dentity of email server. - ComponentOverviewEntry: - type: object - properties: - severity: - type: integer - description: '1-None/Negligible, 2-Unknown, 3-Low, 4-Medium, 5-High' - count: - type: integer - description: number of the components with certain severity. - Label: - type: object - properties: - id: - type: integer - description: The ID of label. - name: - type: string - description: The name of label. - description: - type: string - description: The description of label. - color: - type: string - description: The color of label. - scope: - type: string - description: 'The scope of label, g for global labels and p for project labels.' - project_id: - type: integer - description: The project ID if the label is a project label. - creation_time: - type: string - description: The creation time of label. - update_time: - type: string - description: The update time of label. - deleted: - type: boolean - description: The label is deleted or not. - ChartAPIError: - description: The error object returned by chart repository API - type: object - required: - - error - properties: - error: - type: string - description: The error message returned by the chart API - UnauthorizedChartAPIError: - description: Unauthorized - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - ForbiddenChartAPIError: - description: Operation is forbidden or quota exceeded - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - InternalChartAPIError: - description: Internal server error occurred - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - NotFoundChartAPIError: - description: Not found - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - InsufficientStorageChartAPIError: - description: Insufficient storage - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - BadRequestFormatedError: - description: Bad request - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - ConflictFormatedError: - description: Conflicts - type: object - allOf: - - $ref: '#/definitions/ChartAPIError' - ChartMetadata: - type: object - description: The metadata of chart version - required: - - name - - version - - engine - - icon - - apiVersion - - appVersion - properties: - name: - type: string - description: The name of the chart - home: - type: string - description: The URL to the relevant project page - sources: - type: array - description: The URL to the source code of chart - items: - type: string - version: - type: string - description: A SemVer 2 version of chart - description: - type: string - description: A one-sentence description of chart - keywords: - type: array - description: A list of string keywords - items: - type: string - engine: - type: string - description: The name of template engine - icon: - type: string - description: The URL to an icon file - apiVersion: - type: string - description: The API version of this chart - appVersion: - type: string - description: The version of the application enclosed in the chart - deprecated: - type: boolean - description: Whether or not this chart is deprecated - ChartVersion: - type: object - description: A specified chart entry - allOf: - - $ref: '#/definitions/ChartMetadata' - - type: object - properties: - created: - type: string - description: The created time of the chart entry - removed: - type: boolean - description: A flag to indicate if the chart entry is removed - digest: - type: string - description: The digest value of the chart entry - urls: - type: array - description: The urls of the chart entry - items: - type: string - properties: - labels: - $ref: '#/definitions/Labels' - Labels: - type: array - description: A list of label - items: - $ref: '#/definitions/Label' - Permission: - type: object - description: The permission - properties: - resource: - type: string - description: The permission resoruce - action: - type: string - description: The permission action - Namespace: - type: object - description: The namespace of registry - properties: - name: - type: string - description: The name of namespace - metadata: - type: object - description: The metadata of namespace diff --git a/api/v2.0/swagger.yaml b/api/v2.0/swagger.yaml index 0c9e2768a..7cc1efd73 100644 --- a/api/v2.0/swagger.yaml +++ b/api/v2.0/swagger.yaml @@ -37,9 +37,9 @@ paths: $ref: '#/responses/500' /search: get: - summary: 'Search for projects, repositories and helm charts' + summary: 'Search for projects and repositories' 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 and repositories offered at public status or related to the current logged in user. The response includes the project and repository list in a proper display order. parameters: - $ref: '#/parameters/requestId' - name: q @@ -6206,13 +6206,6 @@ definitions: type: array items: $ref: '#/definitions/SearchRepository' - chart: - description: Search results of the charts that macthed the filter keywords. - type: array - items: - $ref: '#/definitions/SearchResult' - x-omitempty: true - x-isnullable: true SearchRepository: type: object properties: @@ -6234,93 +6227,6 @@ definitions: artifact_count: type: integer description: The count of artifacts in the repository - SearchResult: - type: object - description: The chart search result item - properties: - Name: - type: string - description: The chart name with repo name - Score: - type: integer - description: The matched level - Chart: - $ref: '#/definitions/ChartVersion' - ChartVersion: - type: object - description: A specified chart entry - allOf: - - $ref: '#/definitions/ChartMetadata' - - type: object - properties: - created: - type: string - description: The created time of the chart entry - removed: - type: boolean - description: A flag to indicate if the chart entry is removed - digest: - type: string - description: The digest value of the chart entry - urls: - type: array - description: The urls of the chart entry - items: - type: string - properties: - labels: - type: array - description: A list of label - items: - $ref: '#/definitions/Label' - ChartMetadata: - type: object - description: The metadata of chart version - required: - - name - - version - - engine - - icon - - apiVersion - - appVersion - properties: - name: - type: string - description: The name of the chart - home: - type: string - description: The URL to the relevant project page - sources: - type: array - description: The URL to the source code of chart - items: - type: string - version: - type: string - description: A SemVer 2 version of chart - description: - type: string - description: A one-sentence description of chart - keywords: - type: array - description: A list of string keywords - items: - type: string - engine: - type: string - description: The name of template engine - icon: - type: string - description: The URL to an icon file - apiVersion: - type: string - description: The API version of this chart - appVersion: - type: string - description: The version of the application enclosed in the chart - deprecated: - type: boolean - description: Whether or not this chart is deprecated Repository: type: object properties: @@ -6956,10 +6862,6 @@ definitions: type: integer description: The number of the repositories under this project. x-omitempty: false - chart_count: - type: integer - description: The total number of charts under this project. - x-omitempty: false metadata: description: The metadata of the project. $ref: '#/definitions/ProjectMetadata' @@ -7017,10 +6919,6 @@ definitions: type: integer description: The number of the repositories under this project. x-omitempty: false - chart_count: - type: integer - description: The total number of charts under this project. - x-omitempty: false project_admin_count: type: integer description: The total number of project admin members. diff --git a/make/photon/portal/Dockerfile b/make/photon/portal/Dockerfile index ea1cb4ae1..9e9a389b7 100644 --- a/make/photon/portal/Dockerfile +++ b/make/photon/portal/Dockerfile @@ -9,13 +9,7 @@ ARG npm_registry=https://registry.npmjs.org RUN apt-get update \ && apt-get install -y --no-install-recommends python-yaml -COPY src/portal/package.json /build_dir -COPY src/portal/package-lock.json /build_dir -COPY src/portal/scripts /build_dir -COPY ./api/v2.0/legacy_swagger.yaml /build_dir/swagger.yaml -COPY ./api/v2.0/swagger.yaml /build_dir/swagger2.yaml -COPY ./api/swagger.yaml /build_dir/swagger3.yaml - +COPY ./api/v2.0/swagger.yaml /build_dir/swagger.yaml COPY src/portal /build_dir ENV NPM_CONFIG_REGISTRY=${npm_registry} @@ -23,10 +17,7 @@ RUN npm install --unsafe-perm RUN npm run generate-build-timestamp RUN node --max_old_space_size=2048 'node_modules/@angular/cli/bin/ng' build --configuration production RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger.yaml > dist/swagger.json -RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger2.yaml > dist/swagger2.json -RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger3.yaml > dist/swagger3.json -RUN cp swagger.yaml dist COPY ./LICENSE /build_dir/dist RUN cd app-swagger-ui && npm install --unsafe-perm @@ -36,7 +27,6 @@ FROM ${harbor_base_namespace}/harbor-portal-base:${harbor_base_image_version} COPY --from=nodeportal /build_dir/dist /usr/share/nginx/html COPY --from=nodeportal /build_dir/app-swagger-ui/dist /usr/share/nginx/html -COPY --from=nodeportal /build_dir/package*.json /usr/share/nginx/ VOLUME /var/cache/nginx /var/log/nginx /run diff --git a/src/portal/app-swagger-ui/src/index.js b/src/portal/app-swagger-ui/src/index.js index ce49ba25e..ee5d9cb0f 100644 --- a/src/portal/app-swagger-ui/src/index.js +++ b/src/portal/app-swagger-ui/src/index.js @@ -6,23 +6,16 @@ const helpInfo = ' please logout Harbor first or manually delete the cookies under the current domain.'; const SAFE_METHODS = ['GET', 'HEAD', 'OPTIONS', 'TRACE']; -// get swagger.json and swagger2.json from portal container then render swagger ui +// get swagger.json from portal container then render swagger ui // before rendering, the ui shows a loading style -Promise.all([ - fetch('/swagger.json').then(value => value.json()), - fetch('/swagger2.json').then(value => value.json()) -]) - .then(value => { - // merger swagger.json and swagger2.json - const json = {}; - mergeDeep(json, value[0], value[1]); - json['host'] = window.location.host; - const protocal = window.location.protocol; - json['schemes'] = [protocal.replace(':', '')]; - json.info.description = json.info.description + helpInfo; +fetch('/swagger.json').then(value => value.json()).then(res => { + res['host'] = window.location.host; + const protocal = window.location.protocol; + res['schemes'] = [protocal.replace(':', '')]; + res.info.description = res.info.description + helpInfo; // start to render SwaggerUI({ - spec: json, + spec: res, dom_id: '#swagger-ui-container', deepLinking: true, presets: [SwaggerUI.presets.apis], @@ -60,34 +53,3 @@ Promise.all([ .catch((err) => { console.error(err); }); - - - - - - - -function mergeDeep(target, ...sources) { - if (!sources.length) { - return target; - } - const source = sources.shift(); - - if (isObject(target) && isObject(source)) { - for (const key in source) { - if (isObject(source[key])) { - if (!target[key]) { - Object.assign(target, { [key]: {} }); - } - mergeDeep(target[key], source[key]); - } else { - Object.assign(target, { [key]: source[key] }); - } - } - } - return mergeDeep(target, ...sources); -} - -function isObject(item) { - return item && typeof item === 'object' && !Array.isArray(item); -} diff --git a/src/portal/docker-build/Dockerfile b/src/portal/docker-build/Dockerfile index c744fc060..bc75fdeb9 100644 --- a/src/portal/docker-build/Dockerfile +++ b/src/portal/docker-build/Dockerfile @@ -3,9 +3,8 @@ FROM node:16.10.0 as builder WORKDIR /build_dir COPY src/portal /build_dir -COPY api/v2.0/legacy_swagger.yaml /build_dir/swagger.yaml -COPY api/v2.0/swagger.yaml /build_dir/swagger2.yaml -COPY api/swagger.yaml /build_dir/swagger3.yaml +COPY api/v2.0/swagger.yaml /build_dir/swagger.yaml + RUN apt-get update \ && apt-get install -y --no-install-recommends python-yaml @@ -14,11 +13,6 @@ RUN npm run postinstall RUN npm run generate-build-timestamp RUN node --max_old_space_size=2048 'node_modules/@angular/cli/bin/ng' build --configuration production RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger.yaml > dist/swagger.json -RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger2.yaml > dist/swagger2.json -RUN python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print json.dumps(y)' < swagger3.yaml > dist/swagger3.json - -COPY LICENSE /build_dir/dist - RUN cd app-swagger-ui && npm install --unsafe-perm RUN cd app-swagger-ui && npm run build diff --git a/src/portal/scripts/convert-yaml-to-json.js b/src/portal/scripts/convert-yaml-to-json.js index 8ab88dee5..c86c8a8ba 100644 --- a/src/portal/scripts/convert-yaml-to-json.js +++ b/src/portal/scripts/convert-yaml-to-json.js @@ -3,15 +3,16 @@ 1.npm install js-yaml --save-dev 2.npm install ng-swagger-gen --save-dev */ -//configuration +//configuration. For dev build, the input path is '../../api/v2.0/swagger.yaml' let inputFile = '../../api/v2.0/swagger.yaml'; const outputDir = 'ng-swagger-gen'; //convert swagger.yaml to swagger.json const yaml = require('js-yaml'); const fs = require('fs'); -if (fs.existsSync('swagger2.yaml')) { - inputFile = 'swagger2.yaml'; +//when building portal container(production build), the input path is './swagger.yaml'. Refer to portal Dockerfile +if (fs.existsSync('swagger.yaml')) { + inputFile = 'swagger.yaml'; } if (!fs.existsSync(outputDir)) { fs.mkdirSync(outputDir); diff --git a/src/portal/src/app/shared/components/list-project-ro/list-project-ro.component.spec.ts b/src/portal/src/app/shared/components/list-project-ro/list-project-ro.component.spec.ts index 2e2910d25..cac8f0075 100644 --- a/src/portal/src/app/shared/components/list-project-ro/list-project-ro.component.spec.ts +++ b/src/portal/src/app/shared/components/list-project-ro/list-project-ro.component.spec.ts @@ -17,14 +17,12 @@ describe('ListProjectROComponent', () => { let fixture: ComponentFixture; const mockedProjects: Project[] = [ { - chart_count: 0, name: 'test1', metadata: {}, project_id: 1, repo_count: 1, }, { - chart_count: 0, name: 'test2', metadata: {}, project_id: 2,