1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-22 18:28:37 +00:00

Refactor container and UI (#34736)

This commit is contained in:
wxiaoguang
2025-06-16 16:27:01 +08:00
committed by GitHub
parent bbee652e29
commit 6b8b580218
10 changed files with 153 additions and 80 deletions

View File

@@ -4,6 +4,8 @@
package container
const (
ContentTypeDockerDistributionManifestV2 = "application/vnd.docker.distribution.manifest.v2+json"
ManifestFilename = "manifest.json"
UploadVersion = "_upload"
)

View File

@@ -25,6 +25,7 @@ type BlobSearchOptions struct {
Digest string
Tag string
IsManifest bool
OnlyLead bool
Repository string
}
@@ -45,6 +46,9 @@ func (opts *BlobSearchOptions) toConds() builder.Cond {
if opts.IsManifest {
cond = cond.And(builder.Eq{"package_file.lower_name": ManifestFilename})
}
if opts.OnlyLead {
cond = cond.And(builder.Eq{"package_file.is_lead": true})
}
if opts.Digest != "" {
var propsCond builder.Cond = builder.Eq{
"package_property.ref_type": packages.PropertyTypeFile,
@@ -73,11 +77,9 @@ func GetContainerBlob(ctx context.Context, opts *BlobSearchOptions) (*packages.P
pfds, err := getContainerBlobsLimit(ctx, opts, 1)
if err != nil {
return nil, err
}
if len(pfds) != 1 {
} else if len(pfds) == 0 {
return nil, ErrContainerBlobNotExist
}
return pfds[0], nil
}