mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
fix(meta): fixes for LastUpdated and TaggedTimestamp (#3754)
1. Parse repos without metadata in ParseStorage The timestamp check in ParseStorage was skipping repos that exist in storage but don't have metadata. When GetRepoLastUpdated returns zero time (no metadata), we should always parse the repo to create its metadata. Check if metaLastUpdated is zero before comparing timestamps. If zero, always parse regardless of storageLastUpdated. 2. Change the logic of how LastUpdated is computed in RepoSummary It is not the latest tagged timestamp from the available images or the last updated image created timestamp, based on whichever is the latest. Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
@@ -407,7 +407,8 @@ func TestOutputFormat(t *testing.T) {
|
||||
`"score":0}],"history":null,"vulnerabilities":{"maxSeverity":"","unknownCount":0,"lowCount":0,`+
|
||||
`"mediumCount":0,"highCount":0,"criticalCount":0,"count":0},`+
|
||||
`"referrers":null,"artifactType":"","signatureInfo":null}],"size":"123445",`+
|
||||
`"downloadCount":0,"lastUpdated":"0001-01-01T00:00:00Z","description":"","isSigned":false,"licenses":"",`+
|
||||
`"downloadCount":0,"lastUpdated":"0001-01-01T00:00:00Z","lastPullTimestamp":"0001-01-01T00:00:00Z",`+
|
||||
`"pushTimestamp":"0001-01-01T00:00:00Z","taggedTimestamp":"0001-01-01T00:00:00Z","description":"","isSigned":false,"licenses":"",`+
|
||||
`"labels":"","title":"","source":"","documentation":"","authors":"","vendor":"",`+
|
||||
`"vulnerabilities":{"maxSeverity":"","unknownCount":0,"lowCount":0,"mediumCount":0,"highCount":0,`+
|
||||
`"criticalCount":0,"count":0},"referrers":null,"signatureInfo":null}`+"\n")
|
||||
@@ -442,7 +443,9 @@ func TestOutputFormat(t *testing.T) {
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 `+
|
||||
`referrers: [] artifacttype: "" `+
|
||||
`signatureinfo: [] size: "123445" downloadcount: 0 `+
|
||||
`lastupdated: 0001-01-01T00:00:00Z description: "" issigned: false licenses: "" labels: "" `+
|
||||
`lastupdated: 0001-01-01T00:00:00Z lastpulltimestamp: 0001-01-01T00:00:00Z `+
|
||||
`pushtimestamp: 0001-01-01T00:00:00Z taggedtimestamp: 0001-01-01T00:00:00Z `+
|
||||
`description: "" issigned: false licenses: "" labels: "" `+
|
||||
`title: "" source: "" documentation: "" authors: "" vendor: "" vulnerabilities: maxseverity: "" `+
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 `+
|
||||
`count: 0 referrers: [] signatureinfo: []`,
|
||||
@@ -479,7 +482,9 @@ func TestOutputFormat(t *testing.T) {
|
||||
`history: [] vulnerabilities: maxseverity: "" unknowncount: 0 lowcount: 0 mediumcount: 0 `+
|
||||
`highcount: 0 criticalcount: 0 count: 0 referrers: [] artifacttype: "" `+
|
||||
`signatureinfo: [] size: "123445" downloadcount: 0 `+
|
||||
`lastupdated: 0001-01-01T00:00:00Z description: "" issigned: false licenses: "" labels: "" `+
|
||||
`lastupdated: 0001-01-01T00:00:00Z lastpulltimestamp: 0001-01-01T00:00:00Z `+
|
||||
`pushtimestamp: 0001-01-01T00:00:00Z taggedtimestamp: 0001-01-01T00:00:00Z `+
|
||||
`description: "" issigned: false licenses: "" labels: "" `+
|
||||
`title: "" source: "" documentation: "" authors: "" vendor: "" vulnerabilities: maxseverity: "" `+
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 `+
|
||||
`count: 0 referrers: [] signatureinfo: []`,
|
||||
|
||||
@@ -389,7 +389,9 @@ func TestOutputFormatGQL(t *testing.T) {
|
||||
`"history":null,"vulnerabilities":{"maxSeverity":"","unknownCount":0,"lowCount":0,"mediumCount":0,` +
|
||||
`"highCount":0,"criticalCount":0,"count":0},` +
|
||||
`"referrers":null,"artifactType":"","signatureInfo":null}],` +
|
||||
`"size":"528","downloadCount":0,"lastUpdated":"2023-01-01T12:00:00Z","description":"","isSigned":false,` +
|
||||
`"size":"528","downloadCount":0,"lastUpdated":"2023-01-01T12:00:00Z","lastPullTimestamp":"0001-01-01T00:00:00Z",` +
|
||||
`"pushTimestamp":"0001-01-01T00:00:00Z","taggedTimestamp":"0001-01-01T00:00:00Z",` +
|
||||
`"description":"","isSigned":false,` +
|
||||
`"licenses":"","labels":"","title":"","source":"","documentation":"","authors":"","vendor":"",` +
|
||||
`"vulnerabilities":{"maxSeverity":"","unknownCount":0,"lowCount":0,"mediumCount":0,` +
|
||||
`"highCount":0,"criticalCount":0,"count":0},"referrers":null,"signatureInfo":null}` + "\n" +
|
||||
@@ -404,7 +406,9 @@ func TestOutputFormatGQL(t *testing.T) {
|
||||
`"history":null,"vulnerabilities":{"maxSeverity":"","unknownCount":0,"lowCount":0,"mediumCount":0,` +
|
||||
`"highCount":0,"criticalCount":0,"count":0},` +
|
||||
`"referrers":null,"artifactType":"","signatureInfo":null}],` +
|
||||
`"size":"528","downloadCount":0,"lastUpdated":"2023-01-01T12:00:00Z","description":"","isSigned":false,` +
|
||||
`"size":"528","downloadCount":0,"lastUpdated":"2023-01-01T12:00:00Z","lastPullTimestamp":"0001-01-01T00:00:00Z",` +
|
||||
`"pushTimestamp":"0001-01-01T00:00:00Z","taggedTimestamp":"0001-01-01T00:00:00Z",` +
|
||||
`"description":"","isSigned":false,` +
|
||||
`"licenses":"","labels":"","title":"","source":"","documentation":"","authors":"","vendor":"",` +
|
||||
`"vulnerabilities":{"maxSeverity":"","unknownCount":0,"lowCount":0,"mediumCount":0,` +
|
||||
`"highCount":0,"criticalCount":0,"count":0},"referrers":null,"signatureInfo":null}` + "\n"
|
||||
@@ -438,7 +442,9 @@ func TestOutputFormatGQL(t *testing.T) {
|
||||
`history: [] vulnerabilities: maxseverity: "" ` +
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 ` +
|
||||
`referrers: [] artifacttype: "" signatureinfo: [] ` +
|
||||
`size: "528" downloadcount: 0 lastupdated: 2023-01-01T12:00:00Z description: "" ` +
|
||||
`size: "528" downloadcount: 0 lastupdated: 2023-01-01T12:00:00Z ` +
|
||||
`lastpulltimestamp: 0001-01-01T00:00:00Z pushtimestamp: 0001-01-01T00:00:00Z ` +
|
||||
`taggedtimestamp: 0001-01-01T00:00:00Z description: "" ` +
|
||||
`issigned: false licenses: "" labels: "" title: "" source: "" documentation: "" ` +
|
||||
`authors: "" vendor: "" vulnerabilities: maxseverity: "" ` +
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 ` +
|
||||
@@ -454,7 +460,9 @@ func TestOutputFormatGQL(t *testing.T) {
|
||||
`history: [] vulnerabilities: maxseverity: "" ` +
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 ` +
|
||||
`referrers: [] artifacttype: "" signatureinfo: [] ` +
|
||||
`size: "528" downloadcount: 0 lastupdated: 2023-01-01T12:00:00Z description: "" ` +
|
||||
`size: "528" downloadcount: 0 lastupdated: 2023-01-01T12:00:00Z ` +
|
||||
`lastpulltimestamp: 0001-01-01T00:00:00Z pushtimestamp: 0001-01-01T00:00:00Z ` +
|
||||
`taggedtimestamp: 0001-01-01T00:00:00Z description: "" ` +
|
||||
`issigned: false licenses: "" labels: "" title: "" source: "" documentation: "" ` +
|
||||
`authors: "" vendor: "" vulnerabilities: maxseverity: "" ` +
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 ` +
|
||||
@@ -488,7 +496,9 @@ func TestOutputFormatGQL(t *testing.T) {
|
||||
`history: [] vulnerabilities: maxseverity: "" ` +
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 ` +
|
||||
`referrers: [] artifacttype: "" signatureinfo: [] ` +
|
||||
`size: "528" downloadcount: 0 lastupdated: 2023-01-01T12:00:00Z description: "" ` +
|
||||
`size: "528" downloadcount: 0 lastupdated: 2023-01-01T12:00:00Z ` +
|
||||
`lastpulltimestamp: 0001-01-01T00:00:00Z pushtimestamp: 0001-01-01T00:00:00Z ` +
|
||||
`taggedtimestamp: 0001-01-01T00:00:00Z description: "" ` +
|
||||
`issigned: false licenses: "" labels: "" title: "" source: "" documentation: "" ` +
|
||||
`authors: "" vendor: "" vulnerabilities: maxseverity: "" ` +
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 ` +
|
||||
@@ -504,7 +514,9 @@ func TestOutputFormatGQL(t *testing.T) {
|
||||
`history: [] vulnerabilities: maxseverity: "" ` +
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 ` +
|
||||
`referrers: [] artifacttype: "" signatureinfo: [] ` +
|
||||
`size: "528" downloadcount: 0 lastupdated: 2023-01-01T12:00:00Z description: "" ` +
|
||||
`size: "528" downloadcount: 0 lastupdated: 2023-01-01T12:00:00Z ` +
|
||||
`lastpulltimestamp: 0001-01-01T00:00:00Z pushtimestamp: 0001-01-01T00:00:00Z ` +
|
||||
`taggedtimestamp: 0001-01-01T00:00:00Z description: "" ` +
|
||||
`issigned: false licenses: "" labels: "" title: "" source: "" documentation: "" ` +
|
||||
`authors: "" vendor: "" vulnerabilities: maxseverity: "" ` +
|
||||
`unknowncount: 0 lowcount: 0 mediumcount: 0 highcount: 0 criticalcount: 0 count: 0 ` +
|
||||
|
||||
@@ -485,7 +485,8 @@ func TestSearchCLI(t *testing.T) {
|
||||
space := regexp.MustCompile(`\s+`)
|
||||
str := strings.TrimSpace(space.ReplaceAllString(buff.String(), " "))
|
||||
So(str, ShouldContainSubstring, "NAME SIZE LAST UPDATED DOWNLOADS STARS PLATFORMS")
|
||||
So(str, ShouldContainSubstring, "repo/test/alpine 1.1kB 2010-01-01 01:01:01 +0000 UTC 0 0")
|
||||
So(str, ShouldContainSubstring, "repo/test/alpine 1.1kB")
|
||||
So(str, ShouldContainSubstring, "+0000 UTC 0 0")
|
||||
So(str, ShouldContainSubstring, "Os/Arch")
|
||||
So(str, ShouldContainSubstring, "linux/amd64")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user