diff --git a/util/argo/argo.go b/util/argo/argo.go index b8535e20ec6c0..1dda11f167019 100644 --- a/util/argo/argo.go +++ b/util/argo/argo.go @@ -348,9 +348,9 @@ func GetRefSources(ctx context.Context, spec argoappv1.ApplicationSpec, db db.Ar refKeys := make(map[string]bool) for _, source := range spec.Sources { if source.Ref != "" { - isValidRefKey := regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString + isValidRefKey := regexp.MustCompile(`^[a-zA-Z0-9_-]+$`).MatchString if !isValidRefKey(source.Ref) { - return nil, fmt.Errorf("source.ref %s cannot contain any special characters except '_' and '-'", source.Ref) + return nil, fmt.Errorf("sources.ref %s cannot contain any special characters except '_' and '-'", source.Ref) } refKey := "$" + source.Ref if _, ok := refKeys[refKey]; ok { diff --git a/util/argo/argo_test.go b/util/argo/argo_test.go index d44aa7f6134b7..1e883f5e0b8c4 100644 --- a/util/argo/argo_test.go +++ b/util/argo/argo_test.go @@ -1043,14 +1043,14 @@ func Test_GetRefSources(t *testing.T) { repoDB.On("GetRepository", context.Background(), repo.Repo).Return(repo, nil) argoSpec := getMultiSourceAppSpec(argoappv1.ApplicationSources{ - {RepoURL: fmt.Sprintf("file://%s", repoPath), Ref: "source1"}, + {RepoURL: fmt.Sprintf("file://%s", repoPath), Ref: "source-1_2"}, {RepoURL: fmt.Sprintf("file://%s", repoPath)}, }) refSources, err := GetRefSources(context.TODO(), *argoSpec, repoDB) expectedRefSource := argoappv1.RefTargetRevisionMapping{ - "$source1": &argoappv1.RefTarget{ + "$source-1_2": &argoappv1.RefTarget{ Repo: *repo, }, }