Skip to content

Commit

Permalink
set tag pull time for proxy cache
Browse files Browse the repository at this point in the history
fixes goharbor#18708

to set the pull time of tag for the first time cache the artifact.

Signed-off-by: Wang Yan <wangyan@vmware.com>
  • Loading branch information
wy65701436 committed May 24, 2023
1 parent 43c6586 commit 761596f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/controller/proxy/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/goharbor/harbor/src/lib/log"
"github.com/goharbor/harbor/src/lib/orm"
proModels "github.com/goharbor/harbor/src/pkg/project/models"
model_tag "github.com/goharbor/harbor/src/pkg/tag/model/tag"
)

const (
Expand Down Expand Up @@ -117,7 +118,20 @@ func (c *controller) EnsureTag(ctx context.Context, art lib.ArtifactInfo, tagNam
if a == nil {
return fmt.Errorf("the artifact is not ready yet, failed to tag it to %v", tagName)
}
return tag.Ctl.Ensure(ctx, a.RepositoryID, a.Artifact.ID, tagName)
if err := tag.Ctl.Ensure(ctx, a.RepositoryID, a.Artifact.ID, tagName); err != nil {
return err
}
// update the pull time of tag for the first time cache
if err := tag.Ctl.Update(ctx, &tag.Tag{
Tag: model_tag.Tag{
RepositoryID: a.RepositoryID,
Name: tagName,
PullTime: time.Now(),
},
}, "PullTime"); err != nil {
return err
}
return nil
}

func (c *controller) UseLocalBlob(ctx context.Context, art lib.ArtifactInfo) bool {
Expand Down Expand Up @@ -239,6 +253,9 @@ func (c *controller) ProxyManifest(ctx context.Context, art lib.ArtifactInfo, re
}
}
if a != nil {
fmt.Println("++++++++++====================")
fmt.Println(art.Tag)
fmt.Println("++++++++++====================")
SendPullEvent(bCtx, a, art.Tag, operator)
}
}(operator.FromContext(ctx))
Expand Down

0 comments on commit 761596f

Please sign in to comment.