From 44a33b0a5f7c5f64eb97a07a3d58587e6fbeb909 Mon Sep 17 00:00:00 2001 From: Jesse Suen Date: Wed, 6 Jun 2018 14:25:23 -0700 Subject: [PATCH] Repo names containing underscores were not being accepted (resolves #258) --- util/db/repository.go | 3 ++- util/db/repository_test.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/util/db/repository.go b/util/db/repository.go index 5e9ed4f83d..3dc0e3dc26 100644 --- a/util/db/repository.go +++ b/util/db/repository.go @@ -123,7 +123,8 @@ func repoURLToSecretName(repo string) string { h := fnv.New32a() _, _ = h.Write([]byte(repo)) parts := strings.Split(strings.TrimSuffix(repo, ".git"), "/") - return fmt.Sprintf("repo-%s-%v", parts[len(parts)-1], h.Sum32()) + shortName := strings.Replace(parts[len(parts)-1], "_", "-", -1) + return fmt.Sprintf("repo-%s-%v", shortName, h.Sum32()) } // repoToStringData converts a repository object to string data for serialization to a secret diff --git a/util/db/repository_test.go b/util/db/repository_test.go index 40eb30807a..36adc8e823 100644 --- a/util/db/repository_test.go +++ b/util/db/repository_test.go @@ -8,6 +8,7 @@ func TestRepoURLToSecretName(t *testing.T) { "https://github.com/argoproj/ARGO-cd": "repo-argo-cd-821842295", "https://github.com/argoproj/argo-cd": "repo-argo-cd-821842295", "https://github.com/argoproj/argo-cd.git": "repo-argo-cd-821842295", + "https://github.com/argoproj/argo_cd.git": "repo-argo-cd-1049844989", "ssh://git@github.com/argoproj/argo-cd.git": "repo-argo-cd-1019298066", }