mirror of
https://github.com/goharbor/harbor.git
synced 2024-09-30 06:18:02 +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
|
# Maximum number of job workers in job service
|
||||||
max_job_workers: 10
|
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 configurations
|
||||||
log:
|
log:
|
||||||
# options are debug, info, warn, error
|
# options are debug, info, warn, error
|
||||||
|
@ -28,7 +28,11 @@ DISABLE_METRICS=false
|
|||||||
DISABLE_API=false
|
DISABLE_API=false
|
||||||
DISABLE_STATEFILES=false
|
DISABLE_STATEFILES=false
|
||||||
ALLOW_OVERWRITE=true
|
ALLOW_OVERWRITE=true
|
||||||
|
{% if chart_absolute_url %}
|
||||||
|
CHART_URL={{public_url}}/chartrepo
|
||||||
|
{% else %}
|
||||||
CHART_URL=
|
CHART_URL=
|
||||||
|
{% endif %}
|
||||||
AUTH_ANONYMOUS_GET=false
|
AUTH_ANONYMOUS_GET=false
|
||||||
TLS_CERT=
|
TLS_CERT=
|
||||||
TLS_KEY=
|
TLS_KEY=
|
||||||
|
@ -96,6 +96,8 @@ def prepare_chartmuseum(config_dict):
|
|||||||
cache_redis_addr=cache_redis_addr,
|
cache_redis_addr=cache_redis_addr,
|
||||||
cache_redis_password=cache_redis_password,
|
cache_redis_password=cache_redis_password,
|
||||||
cache_redis_db_index=cache_redis_db_index,
|
cache_redis_db_index=cache_redis_db_index,
|
||||||
core_secret=core_secret,
|
core_secret=config_dict['core_secret'],
|
||||||
storage_driver=storage_driver,
|
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_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'
|
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
|
# jobservice config
|
||||||
js_config = configs.get('jobservice') or {}
|
js_config = configs.get('jobservice') or {}
|
||||||
config_dict['max_job_workers'] = js_config["max_job_workers"]
|
config_dict['max_job_workers'] = js_config["max_job_workers"]
|
||||||
|
@ -3,6 +3,7 @@ package chartserver
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -190,7 +191,9 @@ func (c *Controller) mergeIndexFile(namespace string,
|
|||||||
version.Name = nameWithNS
|
version.Name = nameWithNS
|
||||||
// Currently there is only one url
|
// Currently there is only one url
|
||||||
for index, url := range version.URLs {
|
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
|
package chartserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
hlog "github.com/goharbor/harbor/src/common/utils/log"
|
"github.com/pkg/errors"
|
||||||
"k8s.io/helm/cmd/helm/search"
|
"k8s.io/helm/cmd/helm/search"
|
||||||
|
|
||||||
|
hlog "github.com/goharbor/harbor/src/common/utils/log"
|
||||||
|
"github.com/goharbor/harbor/src/core/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -216,8 +218,16 @@ func (c *Controller) SearchChart(q string, namespaces []string) ([]*search.Resul
|
|||||||
|
|
||||||
// Get the content bytes of the chart version
|
// Get the content bytes of the chart version
|
||||||
func (c *Controller) getChartVersionContent(namespace string, subPath string) ([]byte, error) {
|
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)
|
url = fmt.Sprintf("%s/%s", c.backendServerAddress.String(), url)
|
||||||
|
|
||||||
return c.apiClient.GetContent(url)
|
return c.apiClient.GetContent(url)
|
||||||
}
|
}
|
||||||
|
@ -544,5 +544,8 @@ func isMultipartFormData(req *http.Request) bool {
|
|||||||
|
|
||||||
// Return the chart full name
|
// Return the chart full name
|
||||||
func chartFullName(namespace, chartName, version string) string {
|
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)
|
return fmt.Sprintf("%s/%s:%s", namespace, chartName, version)
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,15 @@ export class HelmChartDefaultService extends HelmChartService {
|
|||||||
projectName: string,
|
projectName: string,
|
||||||
filename: string,
|
filename: string,
|
||||||
): Observable<any> {
|
): 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,
|
responseType: ResponseContentType.Blob,
|
||||||
})
|
})
|
||||||
.pipe(map(response => {
|
.pipe(map(response => {
|
||||||
|
Loading…
Reference in New Issue
Block a user