mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-15 23:05:57 +01:00
Enable absolute url in helm chart
assign public_url to chart-url remove namespace merge in index.yaml Signed-off-by: Qian Deng <dengq@vmware.com>
This commit is contained in:
parent
cbcc28ed16
commit
cd6c5a9f10
@ -28,7 +28,7 @@ DISABLE_METRICS=false
|
||||
DISABLE_API=false
|
||||
DISABLE_STATEFILES=false
|
||||
ALLOW_OVERWRITE=true
|
||||
CHART_URL=
|
||||
CHART_URL={{public_url}}/chartrepo
|
||||
AUTH_ANONYMOUS_GET=false
|
||||
TLS_CERT=
|
||||
TLS_KEY=
|
||||
|
@ -12,6 +12,7 @@ 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']
|
||||
@ -96,6 +97,7 @@ 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'])
|
@ -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,18 @@ 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)
|
||||
hlog.Infof("namespace: %v, subpath: %v", 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/"))
|
||||
hlog.Infof("extendpoint: %v, trim head: %v result url: %v", extEndpoint, fmt.Sprintf("%s/%s", extEndpoint, "chartrepo"), url)
|
||||
} else {
|
||||
url = path.Join(namespace, subPath)
|
||||
}
|
||||
url = fmt.Sprintf("%s/%s", c.backendServerAddress.String(), url)
|
||||
|
||||
return c.apiClient.GetContent(url)
|
||||
}
|
||||
|
@ -544,5 +544,10 @@ func isMultipartFormData(req *http.Request) bool {
|
||||
|
||||
// Return the chart full name
|
||||
func chartFullName(namespace, chartName, version string) string {
|
||||
return fmt.Sprintf("%s/%s:%s", namespace, chartName, version)
|
||||
if strings.HasPrefix(chartName, "http") {
|
||||
return fmt.Sprintf("%s:%s", namespace, chartName, version)
|
||||
} else {
|
||||
return fmt.Sprintf("%s/%s:%s", namespace, chartName, version)
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user