break out repo split and add unit test

This commit is contained in:
Colin Hoglund
2018-02-10 11:41:07 -05:00
parent 69c4be48ec
commit 21c54aea3d
2 changed files with 24 additions and 1 deletions

View File

@@ -55,7 +55,7 @@ func main() {
}
if create {
err = ensureRepoExists(svc, strings.SplitN(repo, "/", 2)[1])
err = ensureRepoExists(svc, getRepoName(repo))
if err != nil {
log.Fatal(fmt.Sprintf("error creating ECR repo: %v", err))
}
@@ -75,6 +75,10 @@ func main() {
}
}
func getRepoName(repo string) string {
return strings.SplitN(repo, "/", 2)[1]
}
func ensureRepoExists(svc *ecr.ECR, name string) (err error) {
input := &ecr.CreateRepositoryInput{}
input.SetRepositoryName(name)