Extract chart repo url normalization logic
Move the logic to helm/utils exported as func NormalizeChartRepositoryURL Signed-off-by: Aurel Canciu <aurelcanciu@gmail.com>
This commit is contained in:
parent
ad995d80cc
commit
f3370d8004
|
@ -591,10 +591,8 @@ func (r *HelmChartReconciler) indexHelmRepositoryByURL(o runtime.Object) []strin
|
|||
if !ok {
|
||||
panic(fmt.Sprintf("Expected a HelmRepository, got %T", o))
|
||||
}
|
||||
if repo.Spec.URL != "" {
|
||||
// TODO(hidde): move this to a dedicated function in the internal Helm package
|
||||
// so it can be re-used for e.g. lookups.
|
||||
u := strings.TrimRight(repo.Spec.URL, "/") + "/"
|
||||
u := helm.NormalizeChartRepositoryURL(repo.Spec.URL)
|
||||
if u != "" {
|
||||
return []string{u}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Copyright 2020 The Flux CD contributors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package helm
|
||||
|
||||
import "strings"
|
||||
|
||||
// NormalizeChartRepositoryURL ensures repository urls are normalized
|
||||
func NormalizeChartRepositoryURL(url string) string {
|
||||
if url != "" {
|
||||
return strings.TrimRight(url, "/") + "/"
|
||||
}
|
||||
return url
|
||||
}
|
Loading…
Reference in New Issue