Skip to content

Commit 449cfd1

Browse files
committed
Allow fetching charts from a local source-watcher
Signed-off-by: Stefan Prodan <[email protected]>
1 parent de97aa9 commit 449cfd1

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

internal/loader/artifact_url.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"net/http"
2727
"net/url"
2828
"os"
29+
"strings"
2930

3031
"github.com/hashicorp/go-retryablehttp"
3132
digestlib "github.com/opencontainers/go-digest"
@@ -37,8 +38,13 @@ import (
3738
const (
3839
// envSourceControllerLocalhost is the name of the environment variable
3940
// used to override the hostname of the source-controller from which
40-
// the chart is usually downloaded.
41+
// the chart is downloaded.
4142
envSourceControllerLocalhost = "SOURCE_CONTROLLER_LOCALHOST"
43+
44+
// envSourceWatcherLocalhost is the name of the environment variable
45+
// used to override the hostname of the source-watcher from which
46+
// the chart is downloaded.
47+
envSourceWatcherLocalhost = "SOURCE_WATCHER_LOCALHOST"
4248
)
4349

4450
var (
@@ -54,7 +60,12 @@ var (
5460
// digest before loading the chart. It returns the loaded chart.Chart, or an
5561
// error. The error may be of type ErrIntegrity if the integrity check fails.
5662
func SecureLoadChartFromURL(client *retryablehttp.Client, URL, digest string) (*chart.Chart, error) {
57-
URL, err := overwriteHostname(URL, os.Getenv(envSourceControllerLocalhost))
63+
envSourceLocalhost := os.Getenv(envSourceControllerLocalhost)
64+
if strings.Contains(URL, "//source-watcher") {
65+
envSourceLocalhost = os.Getenv(envSourceWatcherLocalhost)
66+
}
67+
68+
URL, err := overwriteHostname(URL, envSourceLocalhost)
5869
if err != nil {
5970
return nil, err
6071
}

0 commit comments

Comments
 (0)