Skip to content

Commit

Permalink
Fixing GCR Client for GKE images which used to be hosted under `googl…
Browse files Browse the repository at this point in the history
…e-containers`
  • Loading branch information
davidcollom committed Jun 18, 2024
1 parent 0fdb1ce commit e6ed3ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pkg/client/gcr/gcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

const (
lookupURL = "https://%s/v2/%s/%s/tags/list"
lookupURL = "https://%s/v2/%s/tags/list"
)

type Options struct {
Expand Down Expand Up @@ -48,11 +48,11 @@ func (c *Client) Name() string {
}

func (c *Client) Tags(ctx context.Context, host, repo, image string) ([]api.ImageTag, error) {
if repo == "google-containers" {
host = "gcr.io"
if repo != "" {
image = fmt.Sprintf("%s/%s", repo, image)
}

url := fmt.Sprintf(lookupURL, host, repo, image)
url := fmt.Sprintf(lookupURL, host, image)

req, err := http.NewRequest(http.MethodGet, url, nil)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/client/gcr/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ func (c *Client) IsHost(host string) bool {
func (c *Client) RepoImageFromPath(path string) (string, string) {
lastIndex := strings.LastIndex(path, "/")

// If there's no slash, then its a "root" level image
if lastIndex == -1 {
return "google-containers", path
return "", path
}

return path[:lastIndex], path[lastIndex+1:]
Expand Down

0 comments on commit e6ed3ac

Please sign in to comment.