Skip to content

Commit

Permalink
Remove chart APIs
Browse files Browse the repository at this point in the history
   1. Remove some chart-related steps for Dockerfile for portal  container
   2. Remove chart APIs for API center

Signed-off-by: AllForNothing <sshijun@vmware.com>
  • Loading branch information
AllForNothing committed Feb 24, 2023
1 parent 1f25f7f commit 3f8c343
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 209 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,6 @@ swagger_client:
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/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
Expand Down
35 changes: 0 additions & 35 deletions api/swagger.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions api/v2.0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
**Notes:** Base path is the code repository root dir.
106 changes: 2 additions & 104 deletions api/v2.0/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 1 addition & 10 deletions make/photon/portal/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,15 @@ 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/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}
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
Expand All @@ -35,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

Expand Down
52 changes: 7 additions & 45 deletions src/portal/app-swagger-ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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);
}
9 changes: 2 additions & 7 deletions src/portal/docker-build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FROM node:16.10.0 as builder
WORKDIR /build_dir

COPY src/portal /build_dir
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
Expand All @@ -13,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

Expand Down
7 changes: 4 additions & 3 deletions src/portal/scripts/convert-yaml-to-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ describe('ListProjectROComponent', () => {
let fixture: ComponentFixture<TestHostComponent>;
const mockedProjects: Project[] = [
{
chart_count: 0,
name: 'test1',
metadata: {},
project_id: 1,
repo_count: 1,
},
{
chart_count: 0,
name: 'test2',
metadata: {},
project_id: 2,
Expand Down

0 comments on commit 3f8c343

Please sign in to comment.