Skip to content

Commit

Permalink
Update alias of domain
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Jun 20, 2024
1 parent 2e3b0ed commit 0712c25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/crproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ func main() {
}),
crproxy.WithPathInfoModifyFunc(func(info *crproxy.ImageInfo) *crproxy.ImageInfo {
// docker.io/busybox => docker.io/library/busybox
if info.Host == "registry-1.docker.io" && !strings.Contains(info.Name, "/") {
if info.Host == "docker.io" && !strings.Contains(info.Name, "/") {
info.Name = "library/" + info.Name
}
if info.Host == "registry.ollama.ai" && !strings.Contains(info.Name, "/") {
if info.Host == "ollama.ai" && !strings.Contains(info.Name, "/") {
info.Name = "library/" + info.Name
}
return info
Expand Down
3 changes: 2 additions & 1 deletion crproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ func (c *CRProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
errcode.ServeJSON(rw, errcode.ErrorCodeDenied)
return
}
info.Host = c.getDomainAlias(info.Host)

if c.modify != nil {
n := c.modify(&ImageInfo{
Expand All @@ -498,6 +497,8 @@ func (c *CRProxy) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
return
}

info.Host = c.getDomainAlias(info.Host)

if info.TagsList && c.disableTagsList {
emptyTagsList(rw, r)
return
Expand Down
4 changes: 3 additions & 1 deletion sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func (c *CRProxy) SyncImageLayer(ctx context.Context, image string, filter func(

host := reference.Domain(named)

host = c.getDomainAlias(host)
var name reference.Named

info := &ImageInfo{
Expand All @@ -116,6 +115,9 @@ func (c *CRProxy) SyncImageLayer(ctx context.Context, image string, filter func(
}
}

host = c.getDomainAlias(host)
info.Host = host

err = c.ping(host)
if err != nil {
return err
Expand Down

0 comments on commit 0712c25

Please sign in to comment.