Merge pull request #7076 from cd1989/update-api-basepath

Use baseURL from config
This commit is contained in:
Fangyuan Cheng 2019-03-28 09:40:23 +08:00 committed by GitHub
commit 2787306d47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,11 @@
import { Observable } from "rxjs"; import { Observable } from "rxjs";
import { Http } from "@angular/http"; import { Http } from "@angular/http";
import { Injectable } from "@angular/core"; import { Injectable, Inject } from "@angular/core";
import { RetagRequest } from "./interface"; import { RetagRequest } from "./interface";
import { HTTP_JSON_OPTIONS } from "../utils"; import { HTTP_JSON_OPTIONS } from "../utils";
import { catchError } from "rxjs/operators"; import { catchError } from "rxjs/operators";
import { throwError as observableThrowError } from "rxjs/index"; import { throwError as observableThrowError } from "rxjs/index";
import { IServiceConfig, SERVICE_CONFIG } from "../service.config";
/** /**
* Define the service methods to perform images retag. * Define the service methods to perform images retag.
@ -36,14 +37,16 @@ export abstract class RetagService {
@Injectable() @Injectable()
export class RetagDefaultService extends RetagService { export class RetagDefaultService extends RetagService {
constructor( constructor(
private http: Http private http: Http,
@Inject(SERVICE_CONFIG) private config: IServiceConfig
) { ) {
super(); super();
} }
retag(request: RetagRequest): Observable<any> { retag(request: RetagRequest): Observable<any> {
let baseUrl: string = this.config.repositoryBaseEndpoint ? this.config.repositoryBaseEndpoint : '/api/repositories';
return this.http return this.http
.post(`/api/repositories/${request.targetProject}/${request.targetRepo}/tags`, .post(`${baseUrl}/${request.targetProject}/${request.targetRepo}/tags`,
{ {
"tag": request.targetTag, "tag": request.targetTag,
"src_image": request.srcImage, "src_image": request.srcImage,