Minor change to comply with CI requirements

This commit is contained in:
hmwenchen 2016-04-22 20:26:28 +08:00
parent dc96ded36a
commit 957df50958
3 changed files with 10 additions and 8 deletions

View File

@ -96,7 +96,7 @@ func GetAccessLogs(accessLog models.AccessLog) ([]models.AccessLog, error) {
return accessLogList, nil return accessLogList, nil
} }
// AccessLog, invoked in service/notification.go // AccessLog ...
func AccessLog(username, projectName, repoName, repoTag, action string) error { func AccessLog(username, projectName, repoName, repoTag, action string) error {
o := orm.NewOrm() o := orm.NewOrm()
sql := "insert into access_log (user_id, project_id, repo_name, repo_tag, operation, op_time) " + sql := "insert into access_log (user_id, project_id, repo_name, repo_tag, operation, op_time) " +

View File

@ -43,6 +43,7 @@ type Tag struct {
ImageID string `json:"image_id"` ImageID string `json:"image_id"`
} }
// Manifest ...
type Manifest struct { type Manifest struct {
SchemaVersion int `json:"schemaVersion"` SchemaVersion int `json:"schemaVersion"`
Name string `json:"name"` Name string `json:"name"`
@ -60,6 +61,7 @@ type blobSumItem struct {
BlobSum string `json:"blobSum"` BlobSum string `json:"blobSum"`
} }
// ManifestDigest ...
type ManifestDigest struct { type ManifestDigest struct {
MediaType string `json:"mediaType"` MediaType string `json:"mediaType"`
SchemaVersion int `json:"schemaVersion"` SchemaVersion int `json:"schemaVersion"`

View File

@ -52,7 +52,7 @@ func (n *NotificationHandler) Post() {
log.Errorf("error while decoding json: %v", err) log.Errorf("error while decoding json: %v", err)
return 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 matched bool
var client *http.Client var client *http.Client
for _, e := range notification.Events { for _, e := range notification.Events {
@ -65,7 +65,7 @@ func (n *NotificationHandler) Post() {
username = e.Actor.Name username = e.Actor.Name
action = e.Action action = e.Action
repo = e.Target.Repository repo = e.Target.Repository
tag_url = e.Target.URL tagURL = e.Target.URL
digest = e.Target.Digest digest = e.Target.Digest
client = registry.NewClientUsernameAuthHandlerEmbeded(username) client = registry.NewClientUsernameAuthHandlerEmbeded(username)
@ -81,14 +81,14 @@ func (n *NotificationHandler) Post() {
_, _, payload, err2 := n.registry.PullManifest(repo, digest, registry.ManifestVersion1) _, _, payload, err2 := n.registry.PullManifest(repo, digest, registry.ManifestVersion1)
if err2 != nil { 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 return
} }
maniDig := models.ManifestDigest{} maniDig := models.ManifestDigest{}
err = json.Unmarshal(payload, &maniDig) err = json.Unmarshal(payload, &maniDig)
if err != nil { 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 return
} }
@ -136,7 +136,7 @@ func (n *NotificationHandler) Post() {
sort.Strings(tagLayers) sort.Strings(tagLayers)
eq := compStringArray(digestLayers, tagLayers) eq := compStringArray(digestLayers, tagLayers)
if eq { if eq {
repo_tag = tag repoTag = tag
break break
} }
@ -148,8 +148,8 @@ func (n *NotificationHandler) Post() {
if username == "" { if username == "" {
username = "anonymous" username = "anonymous"
} }
log.Debugf("repo tag is : %v ", repo_tag) log.Debugf("repo tag is : %v ", repoTag)
go dao.AccessLog(username, project, repo, repo_tag, action) go dao.AccessLog(username, project, repo, repoTag, action)
if action == "push" { if action == "push" {
go func() { go func() {
err2 := svc_utils.RefreshCatalogCache() err2 := svc_utils.RefreshCatalogCache()