mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-29 22:07:32 +02:00
Merge pull request #7719 from ninjadq/fix_chart_relative_url_issue
Fix chart relative url issue
This commit is contained in:
commit
4188c4db76
@ -64,6 +64,10 @@ jobservice:
|
||||
# Maximum number of job workers in job service
|
||||
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
|
||||
log:
|
||||
# options are debug, info, warn, error
|
||||
|
@ -28,7 +28,11 @@ DISABLE_METRICS=false
|
||||
DISABLE_API=false
|
||||
DISABLE_STATEFILES=false
|
||||
ALLOW_OVERWRITE=true
|
||||
{% if chart_absolute_url %}
|
||||
CHART_URL={{public_url}}/chartrepo
|
||||
{% else %}
|
||||
CHART_URL=
|
||||
{% endif %}
|
||||
AUTH_ANONYMOUS_GET=false
|
||||
TLS_CERT=
|
||||
TLS_KEY=
|
||||
|
@ -96,6 +96,8 @@ def prepare_chartmuseum(config_dict):
|
||||
cache_redis_addr=cache_redis_addr,
|
||||
cache_redis_password=cache_redis_password,
|
||||
cache_redis_db_index=cache_redis_db_index,
|
||||
core_secret=core_secret,
|
||||
core_secret=config_dict['core_secret'],
|
||||
storage_driver=storage_driver,
|
||||
all_storage_driver_configs=all_storage_provider_configs)
|
||||
all_storage_driver_configs=all_storage_provider_configs,
|
||||
public_url=config_dict['public_url'],
|
||||
chart_absolute_url=config_dict['chart_absolute_url'])
|
@ -170,6 +170,10 @@ def parse_yaml_config(config_file_path):
|
||||
config_dict['clair_https_proxy'] = clair_configs.get('https_proxy') or ''
|
||||
config_dict['clair_no_proxy'] = clair_configs.get('no_proxy') or '127.0.0.1,localhost,core,registry'
|
||||
|
||||
# Chart configs
|
||||
chart_configs = configs.get("chart") or {}
|
||||
config_dict['chart_absolute_url'] = chart_configs.get('absolute_url') or ''
|
||||
|
||||
# jobservice config
|
||||
js_config = configs.get('jobservice') or {}
|
||||
config_dict['max_job_workers'] = js_config["max_job_workers"]
|
||||
|
@ -3,6 +3,7 @@ package chartserver
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -190,7 +191,9 @@ func (c *Controller) mergeIndexFile(namespace string,
|
||||
version.Name = nameWithNS
|
||||
// Currently there is only one url
|
||||
for index, url := range version.URLs {
|
||||
version.URLs[index] = path.Join(namespace, url)
|
||||
if !strings.HasPrefix(url, "http") {
|
||||
version.URLs[index] = path.Join(namespace, url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,16 @@
|
||||
package chartserver
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
hlog "github.com/goharbor/harbor/src/common/utils/log"
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/helm/cmd/helm/search"
|
||||
|
||||
hlog "github.com/goharbor/harbor/src/common/utils/log"
|
||||
"github.com/goharbor/harbor/src/core/config"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -216,8 +218,16 @@ 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) {
|
||||
url := path.Join(namespace, subPath)
|
||||
var url string
|
||||
if strings.HasPrefix(subPath, "http") {
|
||||
extEndpoint, err := config.ExtEndpoint()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "can not get ext endpoint")
|
||||
}
|
||||
url = strings.TrimPrefix(subPath, fmt.Sprintf("%s/%s", extEndpoint, "chartrepo/"))
|
||||
} else {
|
||||
url = path.Join(namespace, subPath)
|
||||
}
|
||||
url = fmt.Sprintf("%s/%s", c.backendServerAddress.String(), url)
|
||||
|
||||
return c.apiClient.GetContent(url)
|
||||
}
|
||||
|
@ -544,5 +544,8 @@ 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", chartName, version)
|
||||
}
|
||||
return fmt.Sprintf("%s/%s:%s", namespace, chartName, version)
|
||||
}
|
||||
|
@ -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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user