-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ghcr.io: List packages based on whether owner is an org or a user (#180)
Co-authored-by: David Collom <[email protected]>
- Loading branch information
1 parent
45f5a4f
commit 7f21d1e
Showing
3 changed files
with
80 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,21 @@ | ||
package ghcr | ||
|
||
import ( | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
var ( | ||
reg = regexp.MustCompile(`^ghcr.io$`) | ||
) | ||
|
||
func (c *Client) IsHost(host string) bool { | ||
return reg.MatchString(host) | ||
return host == "ghcr.io" | ||
} | ||
|
||
func (c *Client) RepoImageFromPath(path string) (string, string) { | ||
lastIndex := strings.LastIndex(path, "/") | ||
|
||
return path[:lastIndex], path[lastIndex+1:] | ||
var owner, pkg string | ||
parts := strings.SplitN(path, "/", 2) | ||
if len(parts) > 0 { | ||
owner = parts[0] | ||
} | ||
if len(parts) > 1 { | ||
pkg = parts[1] | ||
} | ||
return owner, pkg | ||
} |
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