Skip to content

Commit

Permalink
feat(graphql): Add LastPullTimestamp and PushTimestamp in ImageSummar…
Browse files Browse the repository at this point in the history
…y resposne

Signed-off-by: Eusebiu Petu <petu.eusebiu@gmail.com>
  • Loading branch information
eusebiu-constantin-petu-dbk committed Oct 3, 2024
1 parent a31842b commit 66e629d
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 52 deletions.
65 changes: 34 additions & 31 deletions pkg/extensions/search/convert/metadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,19 +496,20 @@ func ImageIndex2ImageSummary(ctx context.Context, fullImageMeta mTypes.FullImage
func ImageManifest2ImageSummary(ctx context.Context, fullImageMeta mTypes.FullImageMeta,
) (*gql_generated.ImageSummary, map[BlobDigest]int64, error) {
manifest := fullImageMeta.Manifests[0]

var (

Check failure on line 499 in pkg/extensions/search/convert/metadb.go

View workflow job for this annotation

GitHub Actions / lint

declarations should never be cuddled (wsl)
repoName = fullImageMeta.Repo
tag = fullImageMeta.Tag
configDigest = manifest.Manifest.Config.Digest.String()
configSize = manifest.Manifest.Config.Size
manifestDigest = manifest.Digest.String()
manifestSize = manifest.Size
mediaType = manifest.Manifest.MediaType
artifactType = zcommon.GetManifestArtifactType(fullImageMeta.Manifests[0].Manifest)
platform = getPlatform(manifest.Config.Platform)
downloadCount = fullImageMeta.Statistics.DownloadCount
isSigned = isImageSigned(fullImageMeta.Signatures)
repoName = fullImageMeta.Repo
tag = fullImageMeta.Tag
configDigest = manifest.Manifest.Config.Digest.String()
configSize = manifest.Manifest.Config.Size
manifestDigest = manifest.Digest.String()
manifestSize = manifest.Size
mediaType = manifest.Manifest.MediaType
artifactType = zcommon.GetManifestArtifactType(fullImageMeta.Manifests[0].Manifest)
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,
Expand Down Expand Up @@ -551,25 +552,27 @@ func ImageManifest2ImageSummary(ctx context.Context, fullImageMeta mTypes.FullIm
}

imageSummary := gql_generated.ImageSummary{
RepoName: &repoName,
Tag: &tag,
Digest: &manifestDigest,
MediaType: &mediaType,
Manifests: []*gql_generated.ManifestSummary{&manifestSummary},
LastUpdated: imageLastUpdated,
IsSigned: &isSigned,
SignatureInfo: signaturesInfo,
Size: &imageSizeStr,
DownloadCount: &downloadCount,
Description: &annotations.Description,
Title: &annotations.Title,
Documentation: &annotations.Documentation,
Licenses: &annotations.Licenses,
Labels: &annotations.Labels,
Source: &annotations.Source,
Vendor: &annotations.Vendor,
Authors: &authors,
Referrers: manifestSummary.Referrers,
RepoName: &repoName,
Tag: &tag,
Digest: &manifestDigest,
MediaType: &mediaType,
Manifests: []*gql_generated.ManifestSummary{&manifestSummary},
LastUpdated: imageLastUpdated,
IsSigned: &isSigned,
SignatureInfo: signaturesInfo,
Size: &imageSizeStr,
DownloadCount: &downloadCount,
LastPullTimestamp: &lastPullTimestamp,
PushTimestamp: &pushTimestamp,
Description: &annotations.Description,
Title: &annotations.Title,
Documentation: &annotations.Documentation,
Licenses: &annotations.Licenses,
Labels: &annotations.Labels,
Source: &annotations.Source,
Vendor: &annotations.Vendor,
Authors: &authors,
Referrers: manifestSummary.Referrers,
}

return &imageSummary, imageBlobsMap, nil
Expand Down
172 changes: 151 additions & 21 deletions pkg/extensions/search/gql_generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/extensions/search/gql_generated/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions pkg/extensions/search/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 66e629d

Please sign in to comment.