Fix bug for replicating chart triggered by event (#11578)

Use the new event model to fix bug for replicating chart triggered by event

Signed-off-by: Wenkai Yin <yinw@vmware.com>
This commit is contained in:
Wenkai Yin(尹文开) 2020-04-16 16:15:21 +08:00 committed by GitHub
parent 790064df2e
commit e3cbfac0cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 4 deletions

View File

@ -99,7 +99,11 @@ func (c *Controller) DeleteChartVersion(namespace, chartName, version string) er
Repository: &model.Repository{
Name: fmt.Sprintf("%s/%s", namespace, chartName),
},
Vtags: []string{version},
Artifacts: []*model.Artifact{
{
Tags: []string{version},
},
},
},
},
}

View File

@ -118,14 +118,14 @@ func modifyResponse(res *http.Response) error {
}()
// Trigger harbor webhook
if e != nil && e.Resource != nil && e.Resource.Metadata != nil && len(e.Resource.Metadata.Vtags) > 0 &&
if e != nil && e.Resource != nil && e.Resource.Metadata != nil && len(e.Resource.Metadata.Artifacts) > 0 &&
len(e.Resource.ExtendedInfo) > 0 {
event := &n_event.Event{}
metaData := &metadata.ChartUploadMetaData{
ChartMetaData: metadata.ChartMetaData{
ProjectName: e.Resource.ExtendedInfo["projectName"].(string),
ChartName: e.Resource.ExtendedInfo["chartName"].(string),
Versions: e.Resource.Metadata.Vtags,
Versions: e.Resource.Metadata.Artifacts[0].Tags,
OccurAt: time.Now(),
Operator: e.Resource.ExtendedInfo["operator"].(string),
},

View File

@ -507,7 +507,11 @@ func (cra *ChartRepositoryAPI) addEventContext(files []formFile, request *http.R
"public": strconv.FormatBool(public),
},
},
Vtags: []string{chartDetails.Metadata.Version},
Artifacts: []*model.Artifact{
{
Tags: []string{chartDetails.Metadata.Version},
},
},
},
ExtendedInfo: extInfo,
},