Skip to content

Commit a0ffd46

Browse files
authored
Merge pull request #1342 from fluxcd/backport-1341-to-release/v1.4.x
[release/v1.4.x] Allow fetching charts from a local source-watcher
2 parents 168e681 + 9c0e60e commit a0ffd46

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

internal/loader/artifact_url.go

Lines changed: 14 additions & 3 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,12 +60,17 @@ 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+
sourceLocalhost := os.Getenv(envSourceControllerLocalhost)
64+
if strings.Contains(URL, "//source-watcher") {
65+
sourceLocalhost = os.Getenv(envSourceWatcherLocalhost)
66+
}
67+
68+
u, err := overwriteHostname(URL, sourceLocalhost)
5869
if err != nil {
5970
return nil, err
6071
}
6172

62-
req, err := retryablehttp.NewRequest(http.MethodGet, URL, nil)
73+
req, err := retryablehttp.NewRequest(http.MethodGet, u, nil)
6374
if err != nil {
6475
return nil, err
6576
}

0 commit comments

Comments
 (0)