fix image delete error
This commit is contained in:
+29
-24
@@ -48,47 +48,52 @@ func (svc *Service) Build() error {
|
|||||||
svc.rout.Use(router.NewCorsMiddleware())
|
svc.rout.Use(router.NewCorsMiddleware())
|
||||||
svc.rout.Use(svc.hand.AuthMiddleware)
|
svc.rout.Use(svc.hand.AuthMiddleware)
|
||||||
|
|
||||||
svc.rout.Head(`/v2/{name}/blobs/{digest}`, svc.hand.BlobExists)
|
|
||||||
|
|
||||||
svc.rout.Get(`/v3/api/service/hello`, svc.hand.SendHello)
|
svc.rout.Get(`/v3/api/service/hello`, svc.hand.SendHello)
|
||||||
|
|
||||||
svc.rout.Head(`/v3/api/file/{filepath}`, svc.hand.FileInfo)
|
filepathRe := `{filepath:[a-zA-Z0-9_\.*][/\-\.,a-zA-Z0-9_%=*\[\]:~\$]+}`
|
||||||
svc.rout.Put(`/v3/api/file/{filepath}`, svc.hand.PutFile)
|
svc.rout.Head(`/v3/api/file/`+filepathRe, svc.hand.FileInfo)
|
||||||
svc.rout.Get(`/v3/api/file/{filepath}`, svc.hand.GetFile)
|
svc.rout.Put(`/v3/api/file/`+filepathRe, svc.hand.PutFile)
|
||||||
svc.rout.Delete(`/v3/api/file/{filepath}`, svc.hand.DeleteFile)
|
svc.rout.Get(`/v3/api/file/`+filepathRe, svc.hand.GetFile)
|
||||||
|
svc.rout.Delete(`/v3/api/file/`+filepathRe, svc.hand.DeleteFile)
|
||||||
|
|
||||||
svc.rout.Get(`/v3/api/files/{filepath}`, svc.hand.ListFiles)
|
svc.rout.Get(`/v3/api/files/`+filepathRe, svc.hand.ListFiles)
|
||||||
svc.rout.Get(`/v3/api/files/`, svc.hand.ListFiles)
|
svc.rout.Get(`/v3/api/files/`, svc.hand.ListFiles)
|
||||||
|
|
||||||
svc.rout.Post(`/v3/api/checker/{filepath}`, svc.hand.CheckFiles)
|
svc.rout.Post(`/v3/api/checker/`+filepathRe, svc.hand.CheckFiles)
|
||||||
svc.rout.Post(`/v3/api/checker/`, svc.hand.CheckFiles)
|
svc.rout.Post(`/v3/api/checker/`, svc.hand.CheckFiles)
|
||||||
|
|
||||||
svc.rout.Get(`/v3/api/collections/{path}`, svc.hand.ListCollections)
|
pathRe := filepathRe
|
||||||
|
svc.rout.Get(`/v3/api/collections/`+pathRe, svc.hand.ListCollections)
|
||||||
svc.rout.Get(`/v3/api/collections/`, svc.hand.ListCollections)
|
svc.rout.Get(`/v3/api/collections/`, svc.hand.ListCollections)
|
||||||
|
|
||||||
svc.rout.Delete(`/v3/api/collection/{path}`, svc.hand.DeleteCollection)
|
svc.rout.Delete(`/v3/api/collection/`+pathRe, svc.hand.DeleteCollection)
|
||||||
svc.rout.Delete(`/v3/api/collection/`, svc.hand.DeleteCollection)
|
svc.rout.Delete(`/v3/api/collection/`, svc.hand.DeleteCollection)
|
||||||
|
|
||||||
svc.rout.Get(`/v2/`, svc.hand.GetVersion)
|
svc.rout.Get(`/v2/`, svc.hand.GetVersion)
|
||||||
|
|
||||||
svc.rout.Head(`/v2/{name}/manifests/{reference}`, svc.hand.ManifestExists)
|
nameRe := `{name:[a-zA-Z0-9_][a-zA-Z0-9_/\-.]+}`
|
||||||
svc.rout.Put(`/v2/{name}/manifests/{reference}`, svc.hand.PutManifest)
|
referenceRe := `{reference:[a-zA-Z0-9_][a-zA-Z0-9_\-.:=]+}`
|
||||||
svc.rout.Get(`/v2/{name}/manifests/{reference}`, svc.hand.GetManifest)
|
digestRe := `{digest:[a-zA-Z0-9_][a-zA-Z0-9_\-.:=]+}`
|
||||||
svc.rout.Delete(`/v2/{name}/manifests/{reference}`, svc.hand.DeleteManifest)
|
|
||||||
|
|
||||||
svc.rout.Post(`/v2/{name}/blobs/uploads/`, svc.hand.PostUpload)
|
svc.rout.Head(`/v2/`+nameRe+`/manifests/`+referenceRe, svc.hand.ManifestExists)
|
||||||
svc.rout.Patch(`/v2/{name}/blobs/uploads/{reference}`, svc.hand.PatchUpload)
|
svc.rout.Put(`/v2/`+nameRe+`/manifests/`+referenceRe, svc.hand.PutManifest)
|
||||||
svc.rout.Put(`/v2/{name}/blobs/uploads/{reference}`, svc.hand.PutUpload)
|
svc.rout.Get(`/v2/`+nameRe+`/manifests/`+referenceRe, svc.hand.GetManifest)
|
||||||
svc.rout.Put(`/v2/{name}/uploads/{reference}`, svc.hand.PutUpload)
|
svc.rout.Delete(`/v2/`+nameRe+`/manifests/`+referenceRe, svc.hand.DeleteManifest)
|
||||||
|
|
||||||
svc.rout.Get(`/v2/{name}/blobs/{digest}`, svc.hand.GetBlob)
|
svc.rout.Post(`/v2/`+nameRe+`/blobs/uploads/`, svc.hand.PostUpload)
|
||||||
svc.rout.Delete(`/v2/{name}/blobs/{digest}`, svc.hand.DeleteBlob)
|
svc.rout.Patch(`/v2/`+nameRe+`/blobs/uploads/`+referenceRe, svc.hand.PatchUpload)
|
||||||
|
svc.rout.Put(`/v2/`+nameRe+`/blobs/uploads/`+referenceRe, svc.hand.PutUpload)
|
||||||
|
svc.rout.Put(`/v2/`+nameRe+`/uploads/`+referenceRe, svc.hand.PutUpload)
|
||||||
|
|
||||||
svc.rout.Get(`/v2/{name}/tags/list`, svc.hand.GetTags)
|
svc.rout.Head(`/v2/`+nameRe+`/blobs/`+digestRe, svc.hand.BlobExists)
|
||||||
svc.rout.Get(`/v2/{name}/referrers/{digest}`, svc.hand.GetReferer)
|
svc.rout.Get(`/v2/`+nameRe+`/blobs/`+digestRe, svc.hand.GetBlob)
|
||||||
|
svc.rout.Delete(`/v2/`+nameRe+`/blobs/`+digestRe, svc.hand.DeleteBlob)
|
||||||
|
|
||||||
|
svc.rout.Get(`/v2/`+nameRe+`/tags/list`, svc.hand.GetTags)
|
||||||
|
svc.rout.Get(`/v2/`+nameRe+`/referrers/`+digestRe, svc.hand.GetReferer)
|
||||||
svc.rout.Get(`/v2/_catalog`, svc.hand.ListManifests)
|
svc.rout.Get(`/v2/_catalog`, svc.hand.ListManifests)
|
||||||
|
|
||||||
svc.rout.Post(`/v2/checker/{name}`, svc.hand.CheckImages)
|
svc.rout.Post(`/v2/checker/`+nameRe, svc.hand.CheckImages)
|
||||||
svc.rout.Post(`/v2/checker`, svc.hand.CheckImages)
|
svc.rout.Post(`/v2/checker`, svc.hand.CheckImages)
|
||||||
|
|
||||||
svc.rout.Post(`/v3/api/account/create`, svc.hand.CreateAccount)
|
svc.rout.Post(`/v3/api/account/create`, svc.hand.CreateAccount)
|
||||||
@@ -103,7 +108,7 @@ func (svc *Service) Build() error {
|
|||||||
svc.rout.Post(`/v3/api/grant/delete`, svc.hand.DeleteGrant)
|
svc.rout.Post(`/v3/api/grant/delete`, svc.hand.DeleteGrant)
|
||||||
svc.rout.Post(`/v3/api/grants/list`, svc.hand.ListGrants)
|
svc.rout.Post(`/v3/api/grants/list`, svc.hand.ListGrants)
|
||||||
|
|
||||||
svc.rout.Get(`/{filepath}`, svc.hand.GetFile)
|
svc.rout.Get(`/`+filepathRe, svc.hand.GetFile)
|
||||||
|
|
||||||
svc.rout.NotFound(svc.hand.NotFound)
|
svc.rout.NotFound(svc.hand.NotFound)
|
||||||
|
|
||||||
|
|||||||
@@ -13,13 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (cli *Client) DeleteImage(ctx context.Context, rawrepo string) (bool, error) {
|
func (cli *Client) DeleteImage(ctx context.Context, rawrepo string) (bool, error) {
|
||||||
var err error
|
return cli.DeleteManifest(ctx, rawrepo)
|
||||||
var exist bool
|
|
||||||
ref, err := NewReferer(rawrepo)
|
|
||||||
if err != nil {
|
|
||||||
return exist, err
|
|
||||||
}
|
|
||||||
return cli.DeleteManifest(ctx, ref.ManifestEP())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *Client) DeleteManifest(ctx context.Context, rawrepo string) (bool, error) {
|
func (cli *Client) DeleteManifest(ctx context.Context, rawrepo string) (bool, error) {
|
||||||
@@ -45,7 +39,7 @@ func (cli *Client) DeleteManifest(ctx context.Context, rawrepo string) (bool, er
|
|||||||
if resp.StatusCode == http.StatusNotFound {
|
if resp.StatusCode == http.StatusNotFound {
|
||||||
return exist, err
|
return exist, err
|
||||||
}
|
}
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusAccepted {
|
||||||
err := fmt.Errorf("Unxected response code %s", resp.Status)
|
err := fmt.Errorf("Unxected response code %s", resp.Status)
|
||||||
return exist, err
|
return exist, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user