Fix frontend failure caused by absolute path

Fix failures because front downlowd chart using relative path

Signed-off-by: Qian Deng <dengq@vmware.com>
This commit is contained in:
Qian Deng 2019-05-08 13:58:17 +08:00
parent 3022b617f2
commit f607c5177d
5 changed files with 12 additions and 8 deletions

View File

@ -65,6 +65,7 @@ jobservice:
max_job_workers: 10
chart:
# Harbor Default will using relative url in chart, if you want using absolute url you should enable it by change the following value to disabled
absolute_url: disabled
# Log configurations

View File

@ -12,7 +12,6 @@ chartm_env = os.path.join(config_dir, "chartserver", "env")
def prepare_chartmuseum(config_dict):
core_secret = config_dict['core_secret']
registry_custom_ca_bundle_path = config_dict['registry_custom_ca_bundle_path']
redis_host = config_dict['redis_host']
redis_port = config_dict['redis_port']
redis_password = config_dict['redis_password']

View File

@ -218,7 +218,6 @@ func (c *Controller) SearchChart(q string, namespaces []string) ([]*search.Resul
// Get the content bytes of the chart version
func (c *Controller) getChartVersionContent(namespace string, subPath string) ([]byte, error) {
hlog.Infof("namespace: %v, subpath: %v", namespace, subPath)
var url string
if strings.HasPrefix(subPath, "http") {
extEndpoint, err := config.ExtEndpoint()
@ -226,7 +225,6 @@ func (c *Controller) getChartVersionContent(namespace string, subPath string) ([
return nil, errors.Wrap(err, "can not get ext endpoint")
}
url = strings.TrimPrefix(subPath, fmt.Sprintf("%s/%s", extEndpoint, "chartrepo/"))
hlog.Infof("extendpoint: %v, trim head: %v result url: %v", extEndpoint, fmt.Sprintf("%s/%s", extEndpoint, "chartrepo"), url)
} else {
url = path.Join(namespace, subPath)
}

View File

@ -545,9 +545,7 @@ func isMultipartFormData(req *http.Request) bool {
// Return the chart full name
func chartFullName(namespace, chartName, version string) string {
if strings.HasPrefix(chartName, "http") {
return fmt.Sprintf("%s:%s", namespace, chartName, version)
} else {
return fmt.Sprintf("%s:%s", chartName, version)
}
return fmt.Sprintf("%s/%s:%s", namespace, chartName, version)
}
}

View File

@ -178,7 +178,15 @@ export class HelmChartDefaultService extends HelmChartService {
projectName: string,
filename: string,
): Observable<any> {
return this.http.get(`${this.config.downloadChartEndpoint}/${projectName}/${filename}`, {
let url: string;
let chartFileRegexPattern = new RegExp('^http.*/chartrepo/(.*)');
if (chartFileRegexPattern.test(filename)) {
let match = filename.match('^http.*/chartrepo/(.*)');
url = `${this.config.downloadChartEndpoint}/${match[1]}`;
} else {
url = `${this.config.downloadChartEndpoint}/${projectName}/${filename}`;
}
return this.http.get(url, {
responseType: ResponseContentType.Blob,
})
.pipe(map(response => {