Skip to content

Commit

Permalink
normalize git repo (argoproj#7)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Crenshaw <[email protected]>

Signed-off-by: Michael Crenshaw <[email protected]>
  • Loading branch information
crenshaw-dev authored Dec 6, 2022
1 parent 55ec032 commit 4c09eaf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,8 @@ func helmTemplate(appPath string, repoRoot string, env *v1alpha1.Env, q *apiclie
pathStrings := strings.Split(val, "/")
refVar := strings.Split(val, "/")[0]
refSourceRepo := q.RefSources[refVar].Repo.Repo
repoPath, err := gitRepoPaths.GetPath(refSourceRepo)
if err != nil {
repoPath := gitRepoPaths.GetPathIfExists(git.NormalizeGitURL(refSourceRepo))
if repoPath == "" {
log.Warnf("Failed to find path for ref %s", refVar)
continue
}
Expand Down
10 changes: 10 additions & 0 deletions util/io/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,13 @@ func (p *TempPaths) GetPath(key string) (string, error) {
p.paths[key] = repoPath
return repoPath, nil
}

// GetPathIfExists gets a path for the given key if it exists. Otherwise, returns an empty string.
func (p *TempPaths) GetPathIfExists(key string) string {
p.lock.Lock()
defer p.lock.Unlock()
if val, ok := p.paths[key]; ok {
return val
}
return ""
}

0 comments on commit 4c09eaf

Please sign in to comment.