diff --git a/src/portal/src/app/shared/shared.module.ts b/src/portal/src/app/shared/shared.module.ts index 65eb9ddda..76e3fb575 100644 --- a/src/portal/src/app/shared/shared.module.ts +++ b/src/portal/src/app/shared/shared.module.ts @@ -46,7 +46,7 @@ import { ListChartVersionRoComponent } from "./list-chart-version-ro/list-chart- import { IServiceConfig, SERVICE_CONFIG } from "../../lib/entities/service.config"; import { ErrorHandler } from "../../lib/utils/error-handler"; import { HarborLibraryModule } from "../../lib/harbor-library.module"; -import { CURRENT_BASE_HREF } from "../../lib/utils/utils"; +import { CURRENT_BASE_HREF, V1_BASE_HREF } from "../../lib/utils/utils"; const uiLibConfig: IServiceConfig = { enablei18Support: true, @@ -67,8 +67,9 @@ const uiLibConfig: IServiceConfig = { configurationEndpoint: CURRENT_BASE_HREF + "/configurations", scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan", labelEndpoint: CURRENT_BASE_HREF + "/labels", - helmChartEndpoint: CURRENT_BASE_HREF + "/chartrepo", + helmChartEndpoint: V1_BASE_HREF + "/chartrepo", downloadChartEndpoint: "/chartrepo", + helmChartLabelEndpoint: CURRENT_BASE_HREF + "/chartrepo", gcEndpoint: CURRENT_BASE_HREF + "/system/gc", ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll", quotaUrl: CURRENT_BASE_HREF + "/quotas" diff --git a/src/portal/src/lib/entities/service.config.ts b/src/portal/src/lib/entities/service.config.ts index 7a1a35591..f90dcbcab 100644 --- a/src/portal/src/lib/entities/service.config.ts +++ b/src/portal/src/lib/entities/service.config.ts @@ -229,6 +229,8 @@ export interface IServiceConfig { */ downloadChartEndpoint?: string; + helmChartLabelEndpoint?: string; + gcEndpoint?: string; ScanAllEndpoint?: string; diff --git a/src/portal/src/lib/harbor-library.module.ts b/src/portal/src/lib/harbor-library.module.ts index 9b9c94a28..b8a8db302 100644 --- a/src/portal/src/lib/harbor-library.module.ts +++ b/src/portal/src/lib/harbor-library.module.ts @@ -34,7 +34,7 @@ import { ErrorHandler, DefaultErrorHandler } from './utils/error-handler'; -import { DEFAULT_LANG_COOKIE_KEY, DEFAULT_SUPPORTING_LANGS, DEFAULT_LANG, CURRENT_BASE_HREF } from './utils/utils'; +import { DEFAULT_LANG_COOKIE_KEY, DEFAULT_SUPPORTING_LANGS, DEFAULT_LANG, CURRENT_BASE_HREF, V1_BASE_HREF } from './utils/utils'; import { OperationService } from './components/operation/operation.service'; import { GcHistoryComponent } from "./components/config/gc/gc-history/gc-history.component"; import { GcComponent } from "./components/config/gc/gc.component"; @@ -97,7 +97,8 @@ export const DefaultServiceConfig: IServiceConfig = { configurationEndpoint: CURRENT_BASE_HREF + "/configurations", scanJobEndpoint: CURRENT_BASE_HREF + "/jobs/scan", labelEndpoint: CURRENT_BASE_HREF + "/labels", - helmChartEndpoint: CURRENT_BASE_HREF + "/chartrepo", + helmChartEndpoint: V1_BASE_HREF + "/chartrepo", + helmChartLabelEndpoint: CURRENT_BASE_HREF + "/chartrepo", downloadChartEndpoint: "/chartrepo", gcEndpoint: CURRENT_BASE_HREF + "/system/gc", ScanAllEndpoint: CURRENT_BASE_HREF + "/system/scanAll" diff --git a/src/portal/src/lib/services/label.service.ts b/src/portal/src/lib/services/label.service.ts index 4e0a8a114..be363f39e 100644 --- a/src/portal/src/lib/services/label.service.ts +++ b/src/portal/src/lib/services/label.service.ts @@ -6,7 +6,7 @@ import { RequestQueryParams } from "./RequestQueryParams"; import { Label } from "./interface"; import { IServiceConfig, SERVICE_CONFIG } from "../entities/service.config"; -import { buildHttpRequestOptions, CURRENT_BASE_HREF, HTTP_JSON_OPTIONS } from "../utils/utils"; +import { buildHttpRequestOptions, CURRENT_BASE_HREF, V1_BASE_HREF, HTTP_JSON_OPTIONS } from "../utils/utils"; import { Observable, throwError as observableThrowError } from "rxjs"; export abstract class LabelService { @@ -72,6 +72,7 @@ export abstract class LabelService { export class LabelDefaultService extends LabelService { labelUrl: string; chartUrl: string; + chartLabelUrl: string; constructor( @Inject(SERVICE_CONFIG) config: IServiceConfig, @@ -79,7 +80,8 @@ export class LabelDefaultService extends LabelService { ) { super(); this.labelUrl = config.labelEndpoint ? config.labelEndpoint : CURRENT_BASE_HREF + "/labels"; - this.chartUrl = config.helmChartEndpoint ? config.helmChartEndpoint : CURRENT_BASE_HREF + "/chartrepo"; + this.chartUrl = config.helmChartEndpoint ? config.helmChartEndpoint : V1_BASE_HREF + "/chartrepo"; + this.chartLabelUrl = config.helmChartLabelEndpoint ? config.helmChartLabelEndpoint : CURRENT_BASE_HREF + "/chartrepo"; } @@ -208,7 +210,7 @@ export class LabelDefaultService extends LabelService { chartName: string, version: string ): Observable { - return this.http.get(`${this.chartUrl}/${projectName}/charts/${chartName}/${version}/labels`); + return this.http.get(`${this.chartLabelUrl}/${projectName}/charts/${chartName}/${version}/labels`); } markChartLabel( @@ -217,7 +219,7 @@ export class LabelDefaultService extends LabelService { version: string, label: Label, ): Observable { - return this.http.post(`${this.chartUrl}/${projectName}/charts/${chartName}/${version}/labels`, + return this.http.post(`${this.chartLabelUrl}/${projectName}/charts/${chartName}/${version}/labels`, JSON.stringify(label), HTTP_JSON_OPTIONS); } @@ -227,7 +229,7 @@ export class LabelDefaultService extends LabelService { version: string, label: Label, ): Observable { - return this.http.delete(`${this.chartUrl}/${projectName}/charts/${chartName}/${version}/labels/${label.id}`, HTTP_JSON_OPTIONS); + return this.http.delete(`${this.chartLabelUrl}/${projectName}/charts/${chartName}/${version}/labels/${label.id}`, HTTP_JSON_OPTIONS); } } diff --git a/src/portal/src/lib/utils/utils.ts b/src/portal/src/lib/utils/utils.ts index eac62db43..50245653f 100644 --- a/src/portal/src/lib/utils/utils.ts +++ b/src/portal/src/lib/utils/utils.ts @@ -13,6 +13,12 @@ enum APILevels { V1 = '', V2 = '/v2.0' } + +/** + * v1 base href + */ +export const V1_BASE_HREF = '/api' + APILevels.V1; + /** * Current base href */