0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-16 21:56:37 -05:00

feat(graphql): Add LastPullTimestamp and PushTimestamp in ImageSummar… (#2699)

feat(graphql): Add LastPullTimestamp and PushTimestamp in ImageSummary resposne

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>
This commit is contained in:
peusebiu 2024-10-03 22:27:03 +03:00 committed by GitHub
parent cfbeeff7bb
commit e6624a29a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 197 additions and 51 deletions

View file

@ -509,6 +509,8 @@ func ImageManifest2ImageSummary(ctx context.Context, fullImageMeta mTypes.FullIm
platform = getPlatform(manifest.Config.Platform)
downloadCount = fullImageMeta.Statistics.DownloadCount
isSigned = isImageSigned(fullImageMeta.Signatures)
lastPullTimestamp = fullImageMeta.Statistics.LastPullTimestamp
pushTimestamp = fullImageMeta.Statistics.PushTimestamp
)
imageSize, imageBlobsMap := getImageBlobsInfo(manifestDigest, manifestSize, configDigest, configSize,
@ -561,6 +563,8 @@ func ImageManifest2ImageSummary(ctx context.Context, fullImageMeta mTypes.FullIm
SignatureInfo: signaturesInfo,
Size: &imageSizeStr,
DownloadCount: &downloadCount,
LastPullTimestamp: &lastPullTimestamp,
PushTimestamp: &pushTimestamp,
Description: &annotations.Description,
Title: &annotations.Title,
Documentation: &annotations.Documentation,

View file

@ -105,10 +105,12 @@ type ComplexityRoot struct {
IsDeletable func(childComplexity int) int
IsSigned func(childComplexity int) int
Labels func(childComplexity int) int
LastPullTimestamp func(childComplexity int) int
LastUpdated func(childComplexity int) int
Licenses func(childComplexity int) int
Manifests func(childComplexity int) int
MediaType func(childComplexity int) int
PushTimestamp func(childComplexity int) int
Referrers func(childComplexity int) int
RepoName func(childComplexity int) int
SignatureInfo func(childComplexity int) int
@ -538,6 +540,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.ImageSummary.Labels(childComplexity), true
case "ImageSummary.LastPullTimestamp":
if e.complexity.ImageSummary.LastPullTimestamp == nil {
break
}
return e.complexity.ImageSummary.LastPullTimestamp(childComplexity), true
case "ImageSummary.LastUpdated":
if e.complexity.ImageSummary.LastUpdated == nil {
break
@ -566,6 +575,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.ImageSummary.MediaType(childComplexity), true
case "ImageSummary.PushTimestamp":
if e.complexity.ImageSummary.PushTimestamp == nil {
break
}
return e.complexity.ImageSummary.PushTimestamp(childComplexity), true
case "ImageSummary.Referrers":
if e.complexity.ImageSummary.Referrers == nil {
break
@ -1509,6 +1525,14 @@ type ImageSummary {
"""
DownloadCount: Int
"""
Last time the image manifest was pulled
"""
LastPullTimestamp: Time
"""
Timestamp when the image was pushed to the registry
"""
PushTimestamp: Time
"""
Timestamp of the last modification done to the image (from config or the last updated layer)
"""
LastUpdated: Time
@ -4303,6 +4327,10 @@ func (ec *executionContext) fieldContext_GlobalSearchResult_Images(_ context.Con
return ec.fieldContext_ImageSummary_Size(ctx, field)
case "DownloadCount":
return ec.fieldContext_ImageSummary_DownloadCount(ctx, field)
case "LastPullTimestamp":
return ec.fieldContext_ImageSummary_LastPullTimestamp(ctx, field)
case "PushTimestamp":
return ec.fieldContext_ImageSummary_PushTimestamp(ctx, field)
case "LastUpdated":
return ec.fieldContext_ImageSummary_LastUpdated(ctx, field)
case "Description":
@ -5146,6 +5174,88 @@ func (ec *executionContext) fieldContext_ImageSummary_DownloadCount(_ context.Co
return fc, nil
}
func (ec *executionContext) _ImageSummary_LastPullTimestamp(ctx context.Context, field graphql.CollectedField, obj *ImageSummary) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_ImageSummary_LastPullTimestamp(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.LastPullTimestamp, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*time.Time)
fc.Result = res
return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_ImageSummary_LastPullTimestamp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ImageSummary",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Time does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _ImageSummary_PushTimestamp(ctx context.Context, field graphql.CollectedField, obj *ImageSummary) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_ImageSummary_PushTimestamp(ctx, field)
if err != nil {
return graphql.Null
}
ctx = graphql.WithFieldContext(ctx, fc)
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = graphql.Null
}
}()
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
return obj.PushTimestamp, nil
})
if err != nil {
ec.Error(ctx, err)
return graphql.Null
}
if resTmp == nil {
return graphql.Null
}
res := resTmp.(*time.Time)
fc.Result = res
return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res)
}
func (ec *executionContext) fieldContext_ImageSummary_PushTimestamp(_ context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) {
fc = &graphql.FieldContext{
Object: "ImageSummary",
Field: field,
IsMethod: false,
IsResolver: false,
Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) {
return nil, errors.New("field of type Time does not have child fields")
},
}
return fc, nil
}
func (ec *executionContext) _ImageSummary_LastUpdated(ctx context.Context, field graphql.CollectedField, obj *ImageSummary) (ret graphql.Marshaler) {
fc, err := ec.fieldContext_ImageSummary_LastUpdated(ctx, field)
if err != nil {
@ -7164,6 +7274,10 @@ func (ec *executionContext) fieldContext_PaginatedImagesResult_Results(_ context
return ec.fieldContext_ImageSummary_Size(ctx, field)
case "DownloadCount":
return ec.fieldContext_ImageSummary_DownloadCount(ctx, field)
case "LastPullTimestamp":
return ec.fieldContext_ImageSummary_LastPullTimestamp(ctx, field)
case "PushTimestamp":
return ec.fieldContext_ImageSummary_PushTimestamp(ctx, field)
case "LastUpdated":
return ec.fieldContext_ImageSummary_LastUpdated(ctx, field)
case "Description":
@ -8134,6 +8248,10 @@ func (ec *executionContext) fieldContext_Query_Image(ctx context.Context, field
return ec.fieldContext_ImageSummary_Size(ctx, field)
case "DownloadCount":
return ec.fieldContext_ImageSummary_DownloadCount(ctx, field)
case "LastPullTimestamp":
return ec.fieldContext_ImageSummary_LastPullTimestamp(ctx, field)
case "PushTimestamp":
return ec.fieldContext_ImageSummary_PushTimestamp(ctx, field)
case "LastUpdated":
return ec.fieldContext_ImageSummary_LastUpdated(ctx, field)
case "Description":
@ -8762,6 +8880,10 @@ func (ec *executionContext) fieldContext_RepoInfo_Images(_ context.Context, fiel
return ec.fieldContext_ImageSummary_Size(ctx, field)
case "DownloadCount":
return ec.fieldContext_ImageSummary_DownloadCount(ctx, field)
case "LastPullTimestamp":
return ec.fieldContext_ImageSummary_LastPullTimestamp(ctx, field)
case "PushTimestamp":
return ec.fieldContext_ImageSummary_PushTimestamp(ctx, field)
case "LastUpdated":
return ec.fieldContext_ImageSummary_LastUpdated(ctx, field)
case "Description":
@ -9123,6 +9245,10 @@ func (ec *executionContext) fieldContext_RepoSummary_NewestImage(_ context.Conte
return ec.fieldContext_ImageSummary_Size(ctx, field)
case "DownloadCount":
return ec.fieldContext_ImageSummary_DownloadCount(ctx, field)
case "LastPullTimestamp":
return ec.fieldContext_ImageSummary_LastPullTimestamp(ctx, field)
case "PushTimestamp":
return ec.fieldContext_ImageSummary_PushTimestamp(ctx, field)
case "LastUpdated":
return ec.fieldContext_ImageSummary_LastUpdated(ctx, field)
case "Description":
@ -11780,6 +11906,10 @@ func (ec *executionContext) _ImageSummary(ctx context.Context, sel ast.Selection
out.Values[i] = ec._ImageSummary_Size(ctx, field, obj)
case "DownloadCount":
out.Values[i] = ec._ImageSummary_DownloadCount(ctx, field, obj)
case "LastPullTimestamp":
out.Values[i] = ec._ImageSummary_LastPullTimestamp(ctx, field, obj)
case "PushTimestamp":
out.Values[i] = ec._ImageSummary_PushTimestamp(ctx, field, obj)
case "LastUpdated":
out.Values[i] = ec._ImageSummary_LastUpdated(ctx, field, obj)
case "Description":

View file

@ -147,6 +147,10 @@ type ImageSummary struct {
Size *string `json:"Size,omitempty"`
// Number of downloads of the manifest of this image
DownloadCount *int `json:"DownloadCount,omitempty"`
// Last time the image manifest was pulled
LastPullTimestamp *time.Time `json:"LastPullTimestamp,omitempty"`
// Timestamp when the image was pushed to the registry
PushTimestamp *time.Time `json:"PushTimestamp,omitempty"`
// Timestamp of the last modification done to the image (from config or the last updated layer)
LastUpdated *time.Time `json:"LastUpdated,omitempty"`
// Human-readable description of the software packaged in the image

View file

@ -205,6 +205,14 @@ type ImageSummary {
"""
DownloadCount: Int
"""
Last time the image manifest was pulled
"""
LastPullTimestamp: Time
"""
Timestamp when the image was pushed to the registry
"""
PushTimestamp: Time
"""
Timestamp of the last modification done to the image (from config or the last updated layer)
"""
LastUpdated: Time