mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 12:15:20 +01:00
Minor change to comply with CI requirements
This commit is contained in:
parent
dc96ded36a
commit
957df50958
@ -96,7 +96,7 @@ func GetAccessLogs(accessLog models.AccessLog) ([]models.AccessLog, error) {
|
||||
return accessLogList, nil
|
||||
}
|
||||
|
||||
// AccessLog, invoked in service/notification.go
|
||||
// AccessLog ...
|
||||
func AccessLog(username, projectName, repoName, repoTag, action string) error {
|
||||
o := orm.NewOrm()
|
||||
sql := "insert into access_log (user_id, project_id, repo_name, repo_tag, operation, op_time) " +
|
||||
|
@ -43,6 +43,7 @@ type Tag struct {
|
||||
ImageID string `json:"image_id"`
|
||||
}
|
||||
|
||||
// Manifest ...
|
||||
type Manifest struct {
|
||||
SchemaVersion int `json:"schemaVersion"`
|
||||
Name string `json:"name"`
|
||||
@ -60,6 +61,7 @@ type blobSumItem struct {
|
||||
BlobSum string `json:"blobSum"`
|
||||
}
|
||||
|
||||
// ManifestDigest ...
|
||||
type ManifestDigest struct {
|
||||
MediaType string `json:"mediaType"`
|
||||
SchemaVersion int `json:"schemaVersion"`
|
||||
|
@ -52,7 +52,7 @@ func (n *NotificationHandler) Post() {
|
||||
log.Errorf("error while decoding json: %v", err)
|
||||
return
|
||||
}
|
||||
var username, action, repo, project, repo_tag, tag_url, digest string
|
||||
var username, action, repo, project, repoTag, tagURL, digest string
|
||||
var matched bool
|
||||
var client *http.Client
|
||||
for _, e := range notification.Events {
|
||||
@ -65,7 +65,7 @@ func (n *NotificationHandler) Post() {
|
||||
username = e.Actor.Name
|
||||
action = e.Action
|
||||
repo = e.Target.Repository
|
||||
tag_url = e.Target.URL
|
||||
tagURL = e.Target.URL
|
||||
digest = e.Target.Digest
|
||||
|
||||
client = registry.NewClientUsernameAuthHandlerEmbeded(username)
|
||||
@ -81,14 +81,14 @@ func (n *NotificationHandler) Post() {
|
||||
_, _, payload, err2 := n.registry.PullManifest(repo, digest, registry.ManifestVersion1)
|
||||
|
||||
if err2 != nil {
|
||||
log.Errorf("Failed to get manifests for repo, repo name: %s, tag: %s, error: %v", repo, tag_url, err2)
|
||||
log.Errorf("Failed to get manifests for repo, repo name: %s, tag: %s, error: %v", repo, tagURL, err2)
|
||||
return
|
||||
}
|
||||
|
||||
maniDig := models.ManifestDigest{}
|
||||
err = json.Unmarshal(payload, &maniDig)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to decode json from response for manifests, repo name: %s, tag: %s, error: %v", repo, tag_url, err)
|
||||
log.Errorf("Failed to decode json from response for manifests, repo name: %s, tag: %s, error: %v", repo, tagURL, err)
|
||||
return
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ func (n *NotificationHandler) Post() {
|
||||
sort.Strings(tagLayers)
|
||||
eq := compStringArray(digestLayers, tagLayers)
|
||||
if eq {
|
||||
repo_tag = tag
|
||||
repoTag = tag
|
||||
break
|
||||
}
|
||||
|
||||
@ -148,8 +148,8 @@ func (n *NotificationHandler) Post() {
|
||||
if username == "" {
|
||||
username = "anonymous"
|
||||
}
|
||||
log.Debugf("repo tag is : %v ", repo_tag)
|
||||
go dao.AccessLog(username, project, repo, repo_tag, action)
|
||||
log.Debugf("repo tag is : %v ", repoTag)
|
||||
go dao.AccessLog(username, project, repo, repoTag, action)
|
||||
if action == "push" {
|
||||
go func() {
|
||||
err2 := svc_utils.RefreshCatalogCache()
|
||||
|
Loading…
Reference in New Issue
Block a user