mirror of
https://github.com/fluxcd/flux2.git
synced 2026-04-29 22:58:50 +00:00
Make resource selector args case insensitive
So that `<kind>/<name>` flags can be supplied as: * `secret/foo` * `Secret/foo` * `SeCrEt/foo` But result in: `Secret/foo`. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
parent
567acb6291
commit
1b8e980519
7 changed files with 25 additions and 8 deletions
|
|
@ -20,8 +20,9 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fluxcd/flux2/internal/utils"
|
||||
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
|
||||
|
||||
"github.com/fluxcd/flux2/internal/utils"
|
||||
)
|
||||
|
||||
var supportedHelmChartSourceKinds = []string{sourcev1.HelmRepositoryKind, sourcev1.GitRepositoryKind, sourcev1.BucketKind}
|
||||
|
|
@ -48,13 +49,14 @@ func (s *HelmChartSource) Set(str string) error {
|
|||
if sourceKind == "" || sourceName == "" {
|
||||
return fmt.Errorf("invalid helm chart source '%s', must be in format <kind>/<name>", str)
|
||||
}
|
||||
if !utils.ContainsItemString(supportedHelmChartSourceKinds, sourceKind) {
|
||||
cleanSourceKind, ok := utils.ContainsEqualFoldItemString(supportedHelmChartSourceKinds, sourceKind)
|
||||
if !ok {
|
||||
return fmt.Errorf("source kind '%s' is not supported, must be one of: %s",
|
||||
sourceKind, strings.Join(supportedHelmChartSourceKinds, ", "))
|
||||
}
|
||||
|
||||
s.Name = sourceName
|
||||
s.Kind = sourceKind
|
||||
s.Kind = cleanSourceKind
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue