|
5 | 5 | "errors" |
6 | 6 | "fmt" |
7 | 7 | "net/http" |
| 8 | + "net/url" |
8 | 9 | "os" |
9 | 10 | "path" |
10 | 11 | "path/filepath" |
@@ -152,15 +153,23 @@ func (m *manager) AddHelmDeployment(deploymentName string) error { |
152 | 153 | requestURL := "" |
153 | 154 |
|
154 | 155 | if chartLocation == chartRepo { |
155 | | - helmConfig.Chart.RepoURL, err = m.log.Question(&survey.QuestionOptions{ |
156 | | - Question: "Please specify the full URL of the chart repo (e.g. https://charts.org.tld/)", |
157 | | - ValidationRegexPattern: "^http(s)?://.*", |
| 156 | + tempChartRepoURL, err := m.log.Question(&survey.QuestionOptions{ |
| 157 | + Question: "Please specify the full URL of the chart repo (e.g. https://charts.org.tld/)", |
| 158 | + ValidationFunc: func(value string) error { |
| 159 | + _, err := url.ParseRequestURI(chartRepoURL(value)) |
| 160 | + if err != nil { |
| 161 | + return err |
| 162 | + } |
| 163 | + return nil |
| 164 | + }, |
158 | 165 | }) |
159 | 166 | if err != nil { |
160 | 167 | return err |
161 | 168 | } |
162 | 169 |
|
163 | | - requestURL = helmConfig.Chart.RepoURL + "/index.yaml" |
| 170 | + helmConfig.Chart.RepoURL = chartRepoURL(tempChartRepoURL) |
| 171 | + |
| 172 | + requestURL = strings.TrimRight(helmConfig.Chart.RepoURL, "/") + "/index.yaml" |
164 | 173 |
|
165 | 174 | helmConfig.Chart.Name, err = m.log.Question(&survey.QuestionOptions{ |
166 | 175 | Question: "Please specify the name of the chart within your chart repository (e.g. payment-service)", |
@@ -354,3 +363,11 @@ func (m *manager) AddComponentDeployment(deploymentName, image string, servicePo |
354 | 363 |
|
355 | 364 | return nil |
356 | 365 | } |
| 366 | + |
| 367 | +func chartRepoURL(url string) string { |
| 368 | + repoURL := url |
| 369 | + if !(strings.HasPrefix(url, "https://") || strings.HasPrefix(url, "http://")) { |
| 370 | + repoURL = "https://" + url |
| 371 | + } |
| 372 | + return repoURL |
| 373 | +} |
0 commit comments