mirror of
https://github.com/goharbor/harbor
synced 2024-09-20 15:25:43 +00:00
Populate public metadata into the event
Fixes #9455. Populate the public metadata into the event when doing the replication based on event Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
parent
dde372bc80
commit
4f981eefd2
|
@ -10,15 +10,15 @@ import (
|
|||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/core/label"
|
||||
|
||||
"github.com/goharbor/harbor/src/chartserver"
|
||||
"github.com/goharbor/harbor/src/common"
|
||||
"github.com/goharbor/harbor/src/common/rbac"
|
||||
hlog "github.com/goharbor/harbor/src/common/utils/log"
|
||||
"github.com/goharbor/harbor/src/core/config"
|
||||
"github.com/goharbor/harbor/src/core/label"
|
||||
rep_event "github.com/goharbor/harbor/src/replication/event"
|
||||
"github.com/goharbor/harbor/src/replication/model"
|
||||
)
|
||||
|
@ -429,6 +429,11 @@ func (cra *ChartRepositoryAPI) addEventContext(files []formFile, request *http.R
|
|||
return err
|
||||
}
|
||||
|
||||
public, err := cra.ProjectMgr.IsPublic(cra.namespace)
|
||||
if err != nil {
|
||||
hlog.Errorf("failed to check the public of project %s: %v", cra.namespace, err)
|
||||
public = false
|
||||
}
|
||||
e := &rep_event.Event{
|
||||
Type: rep_event.EventTypeChartUpload,
|
||||
Resource: &model.Resource{
|
||||
|
@ -436,6 +441,9 @@ func (cra *ChartRepositoryAPI) addEventContext(files []formFile, request *http.R
|
|||
Metadata: &model.ResourceMetadata{
|
||||
Repository: &model.Repository{
|
||||
Name: fmt.Sprintf("%s/%s", cra.namespace, chartDetails.Metadata.Name),
|
||||
Metadata: map[string]interface{}{
|
||||
"public": strconv.FormatBool(public),
|
||||
},
|
||||
},
|
||||
Vtags: []string{chartDetails.Metadata.Version},
|
||||
},
|
||||
|
|
|
@ -17,6 +17,7 @@ package registry
|
|||
import (
|
||||
"encoding/json"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -116,7 +117,6 @@ func (n *NotificationHandler) Post() {
|
|||
return
|
||||
}
|
||||
|
||||
// TODO: handle image delete event and chart event
|
||||
go func() {
|
||||
e := &rep_event.Event{
|
||||
Type: rep_event.EventTypeImagePush,
|
||||
|
@ -125,7 +125,9 @@ func (n *NotificationHandler) Post() {
|
|||
Metadata: &model.ResourceMetadata{
|
||||
Repository: &model.Repository{
|
||||
Name: repository,
|
||||
// TODO filling the metadata
|
||||
Metadata: map[string]interface{}{
|
||||
"public": strconv.FormatBool(pro.IsPublic()),
|
||||
},
|
||||
},
|
||||
Vtags: []string{tag},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue
Block a user