本文整理汇总了Golang中github.com/containerops/wharf/models.Repository.Log方法的典型用法代码示例。如果您正苦于以下问题:Golang Repository.Log方法的具体用法?Golang Repository.Log怎么用?Golang Repository.Log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/containerops/wharf/models.Repository
的用法示例。
在下文中一共展示了Repository.Log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetRepositoryImages
func (this *RepoAPIV1Controller) GetRepositoryImages() {
namespace := string(this.Ctx.Input.Param(":namespace"))
repository := string(this.Ctx.Input.Param(":repo_name"))
repo := new(models.Repository)
if has, _, err := repo.Has(namespace, repository); err != nil {
this.JSONOut(http.StatusBadRequest, "Read repository json error", nil)
return
} else if has == false {
this.JSONOut(http.StatusBadRequest, "Read repository no found", nil)
return
}
repo.Download += 1
if err := repo.Save(); err != nil {
this.JSONOut(http.StatusBadRequest, err.Error(), nil)
}
memo, _ := json.Marshal(this.Ctx.Input.Header)
repo.Log(models.ACTION_GET_REPO, models.LEVELINFORMATIONAL, models.TYPE_APIV1, repo.Id, memo)
this.Ctx.Output.Context.Output.SetStatus(http.StatusOK)
this.Ctx.Output.Context.Output.Body([]byte(repo.JSON))
return
}
示例2: PutRepository
func (this *RepoAPIV1Controller) PutRepository() {
username, _, _ := utils.DecodeBasicAuth(this.Ctx.Input.Header("Authorization"))
namespace := string(this.Ctx.Input.Param(":namespace"))
repository := string(this.Ctx.Input.Param(":repo_name"))
repo := new(models.Repository)
if err := repo.Put(namespace, repository, string(this.Ctx.Input.CopyBody()), this.Ctx.Input.Header("User-Agent"), models.APIVERSION_V1); err != nil {
this.JSONOut(http.StatusForbidden, err.Error(), nil)
return
}
if this.Ctx.Input.Header("X-Docker-Token") == "true" {
token := string(utils.GeneralKey(username))
this.SetSession("token", token)
this.Ctx.Output.Context.ResponseWriter.Header().Set("X-Docker-Token", token)
this.Ctx.Output.Context.ResponseWriter.Header().Set("WWW-Authenticate", token)
}
user := new(models.User)
if _, _, err := user.Has(username); err != nil {
this.JSONOut(http.StatusForbidden, err.Error(), nil)
return
}
memo, _ := json.Marshal(this.Ctx.Input.Header)
user.Log(models.ACTION_UPDATE_REPO, models.LEVELINFORMATIONAL, models.TYPE_APIV1, repo.Id, memo)
repo.Log(models.ACTION_UPDATE_REPO, models.LEVELINFORMATIONAL, models.TYPE_APIV1, repo.Id, memo)
this.Ctx.Output.Context.ResponseWriter.Header().Set("X-Docker-Endpoints", beego.AppConfig.String("docker::Endpoints"))
this.Ctx.Output.Context.Output.SetStatus(http.StatusOK)
this.Ctx.Output.Context.Output.Body([]byte(""))
return
}
示例3: PutRepositoryImages
func (this *RepoAPIV1Controller) PutRepositoryImages() {
namespace := this.Ctx.Input.Param(":namespace")
repository := this.Ctx.Input.Param(":repo_name")
repo := new(models.Repository)
if err := repo.PutImages(namespace, repository); err != nil {
this.JSONOut(http.StatusBadRequest, "Update Uploaded flag error", nil)
return
}
memo, _ := json.Marshal(this.Ctx.Input.Header)
repo.Log(models.ACTION_PUT_REPO_IMAGES, models.LEVELINFORMATIONAL, models.TYPE_APIV1, repo.Id, memo)
org := new(models.Organization)
isOrg, _, err := org.Has(namespace)
if err != nil {
this.JSONOut(http.StatusBadRequest, "Search Organization Error", nil)
return
}
user := new(models.User)
authUsername, _, _ := utils.DecodeBasicAuth(this.Ctx.Input.Header("Authorization"))
isUser, _, err := user.Has(authUsername)
if err != nil {
this.JSONOut(http.StatusBadRequest, err.Error(), nil)
return
}
if !isUser && !isOrg {
this.JSONOut(http.StatusBadRequest, "Search Namespace Error", nil)
return
}
if isUser {
user.Repositories = append(user.Repositories, repo.Id)
user.Save()
}
if isOrg {
org.Repositories = append(org.Repositories, repo.Id)
org.Save()
}
this.Ctx.Output.Context.Output.SetStatus(http.StatusNoContent)
this.Ctx.Output.Context.Output.Body([]byte(""))
this.ServeJson()
return
}
示例4: PutTag
func (this *RepoAPIV1Controller) PutTag() {
namespace := this.Ctx.Input.Param(":namespace")
repository := this.Ctx.Input.Param(":repo_name")
tag := this.Ctx.Input.Param(":tag")
r, _ := regexp.Compile(`"([[:alnum:]]+)"`)
imageIds := r.FindStringSubmatch(string(this.Ctx.Input.CopyBody()))
repo := new(models.Repository)
if err := repo.PutTag(imageIds[1], namespace, repository, tag); err != nil {
this.JSONOut(http.StatusBadRequest, err.Error(), nil)
return
}
memo, _ := json.Marshal(this.Ctx.Input.Header)
repo.Log(models.ACTION_PUT_TAG, models.LEVELINFORMATIONAL, models.TYPE_APIV1, repo.Id, memo)
this.Ctx.Output.Context.Output.SetStatus(http.StatusOK)
this.Ctx.Output.Context.Output.Body([]byte(""))
return
}