From fc18a045a6209196771836f3a89b89df2b88ef75 Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Sun, 14 Feb 2021 12:10:56 +0200 Subject: [PATCH] Allow the controller to be run locally Signed-off-by: Stefan Prodan --- controllers/helmrelease_controller_chart.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/controllers/helmrelease_controller_chart.go b/controllers/helmrelease_controller_chart.go index 1e7c06ff9..59682b07d 100644 --- a/controllers/helmrelease_controller_chart.go +++ b/controllers/helmrelease_controller_chart.go @@ -98,7 +98,16 @@ func (r *HelmReleaseReconciler) loadHelmChart(source *sourcev1.HelmChart) (*char defer f.Close() defer os.Remove(f.Name()) - res, err := http.Get(source.GetArtifact().URL) + url := source.GetArtifact().URL + if hostname := os.Getenv("SOURCE_CONTROLLER_LOCALHOST"); hostname != "" { + url = fmt.Sprintf("http://%s/%s/%s/%s/latest.tar.gz", + hostname, + strings.ToLower(source.Kind), + source.GetNamespace(), + source.GetName()) + } + + res, err := http.Get(url) if err != nil { return nil, err }