Repo names containing underscores were not being accepted (resolves #258)

This commit is contained in:
Jesse Suen 2018-06-06 14:25:23 -07:00
parent 85078bdb66
commit 44a33b0a5f
No known key found for this signature in database
GPG key ID: 90C911E8A6106562
2 changed files with 3 additions and 1 deletions

View file

@ -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

View file

@ -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",
}