-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from AliyunContainerService/features/read-auth-…
…from-repo-file-and-add-debug read auth info from repo file, add debug
- Loading branch information
Showing
8 changed files
with
109 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// Modifications copyright (C) 2019 Alibaba Group Holding Limited / Yuning Xie ([email protected]) | ||
|
||
package helm | ||
|
||
import ( | ||
|
@@ -17,6 +19,19 @@ type ( | |
} | ||
) | ||
|
||
// GetRepoByURL returns repository by url | ||
func GetRepoByURL(url string) (*Repo, error) { | ||
r, err := repoFile() | ||
if err != nil { | ||
return nil, err | ||
} | ||
entry, exists := findRepoEntryByURL(url, r) | ||
if !exists { | ||
return nil, fmt.Errorf("no repo url %q found", url) | ||
} | ||
return &Repo{entry}, nil | ||
} | ||
|
||
// GetRepoByName returns repository by name | ||
func GetRepoByName(name string) (*Repo, error) { | ||
r, err := repoFile() | ||
|
@@ -76,3 +91,16 @@ func findRepoEntry(name string, r *repo.RepoFile) (*repo.Entry, bool) { | |
} | ||
return entry, exists | ||
} | ||
|
||
func findRepoEntryByURL(url string, r *repo.RepoFile) (*repo.Entry, bool) { | ||
var entry *repo.Entry | ||
exists := false | ||
for _, re := range r.Repositories { | ||
if strings.TrimSuffix(re.URL, "/") == strings.TrimSuffix(url, "/") { | ||
entry = re | ||
exists = true | ||
break | ||
} | ||
} | ||
return entry, exists | ||
} |