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

fix: fixed image size not counting config and manifest sizes (#937)

Signed-off-by: Ana-Roberta Lisca <ana.kagome@yahoo.com>
This commit is contained in:
Lisca Ana-Roberta 2022-11-04 19:27:34 +02:00 committed by GitHub
parent 4170d2adbc
commit eb722905cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 12 deletions

View file

@ -290,6 +290,15 @@ func (p *requestsPool) doJob(ctx context.Context, job *manifestJob) {
) )
} }
size += uint64(job.manifestResp.Config.Size)
manifestSize, err := strconv.Atoi(header.Get("Content-Length"))
if err != nil {
p.outputCh <- stringResult{"", err}
}
size += uint64(manifestSize)
image := &imageStruct{} image := &imageStruct{}
image.verbose = *job.config.verbose image.verbose = *job.config.verbose
image.RepoName = job.imageName image.RepoName = job.imageName

View file

@ -1161,8 +1161,8 @@ func TestServerResponse(t *testing.T) {
str := space.ReplaceAllString(buff.String(), " ") str := space.ReplaceAllString(buff.String(), " ")
actual := strings.TrimSpace(str) actual := strings.TrimSpace(str)
So(actual, ShouldContainSubstring, "IMAGE NAME TAG DIGEST SIGNED SIZE") So(actual, ShouldContainSubstring, "IMAGE NAME TAG DIGEST SIGNED SIZE")
So(actual, ShouldContainSubstring, "repo7 test:2.0 883fc0c5 false 15B") So(actual, ShouldContainSubstring, "repo7 test:2.0 883fc0c5 false 492B")
So(actual, ShouldContainSubstring, "repo7 test:1.0 883fc0c5 false 15B") So(actual, ShouldContainSubstring, "repo7 test:1.0 883fc0c5 false 492B")
}) })
Convey("Test all images verbose", func() { Convey("Test all images verbose", func() {
@ -1181,13 +1181,13 @@ func TestServerResponse(t *testing.T) {
actual := strings.TrimSpace(str) actual := strings.TrimSpace(str)
// Actual cli output should be something similar to (order of images may differ): // Actual cli output should be something similar to (order of images may differ):
// IMAGE NAME TAG DIGEST CONFIG LAYERS SIZE // IMAGE NAME TAG DIGEST CONFIG LAYERS SIZE
// repo7 test:2.0 a0ca253b b8781e88 15B // repo7 test:2.0 a0ca253b b8781e88 492B
// b8781e88 15B // b8781e88 15B
// repo7 test:1.0 a0ca253b b8781e88 15B // repo7 test:1.0 a0ca253b b8781e88 492B
// b8781e88 15B // b8781e88 15B
So(actual, ShouldContainSubstring, "IMAGE NAME TAG DIGEST CONFIG SIGNED LAYERS SIZE") So(actual, ShouldContainSubstring, "IMAGE NAME TAG DIGEST CONFIG SIGNED LAYERS SIZE")
So(actual, ShouldContainSubstring, "repo7 test:2.0 883fc0c5 3a1d2d0c false 15B b8781e88 15B") So(actual, ShouldContainSubstring, "repo7 test:2.0 883fc0c5 3a1d2d0c false 492B b8781e88 15B")
So(actual, ShouldContainSubstring, "repo7 test:1.0 883fc0c5 3a1d2d0c false 15B b8781e88 15B") So(actual, ShouldContainSubstring, "repo7 test:1.0 883fc0c5 3a1d2d0c false 492B b8781e88 15B")
}) })
Convey("Test image by name", func() { Convey("Test image by name", func() {
@ -1205,8 +1205,8 @@ func TestServerResponse(t *testing.T) {
str := space.ReplaceAllString(buff.String(), " ") str := space.ReplaceAllString(buff.String(), " ")
actual := strings.TrimSpace(str) actual := strings.TrimSpace(str)
So(actual, ShouldContainSubstring, "IMAGE NAME TAG DIGEST SIGNED SIZE") So(actual, ShouldContainSubstring, "IMAGE NAME TAG DIGEST SIGNED SIZE")
So(actual, ShouldContainSubstring, "repo7 test:2.0 883fc0c5 false 15B") So(actual, ShouldContainSubstring, "repo7 test:2.0 883fc0c5 false 492B")
So(actual, ShouldContainSubstring, "repo7 test:1.0 883fc0c5 false 15B") So(actual, ShouldContainSubstring, "repo7 test:1.0 883fc0c5 false 492B")
}) })
Convey("Test image by digest", func() { Convey("Test image by digest", func() {
@ -1225,11 +1225,11 @@ func TestServerResponse(t *testing.T) {
actual := strings.TrimSpace(str) actual := strings.TrimSpace(str)
// Actual cli output should be something similar to (order of images may differ): // Actual cli output should be something similar to (order of images may differ):
// IMAGE NAME TAG DIGEST SIZE // IMAGE NAME TAG DIGEST SIZE
// repo7 test:2.0 a0ca253b 15B // repo7 test:2.0 a0ca253b 492B
// repo7 test:1.0 a0ca253b 15B // repo7 test:1.0 a0ca253b 492B
So(actual, ShouldContainSubstring, "IMAGE NAME TAG DIGEST SIGNED SIZE") So(actual, ShouldContainSubstring, "IMAGE NAME TAG DIGEST SIGNED SIZE")
So(actual, ShouldContainSubstring, "repo7 test:2.0 883fc0c5 false 15B") So(actual, ShouldContainSubstring, "repo7 test:2.0 883fc0c5 false 492B")
So(actual, ShouldContainSubstring, "repo7 test:1.0 883fc0c5 false 15B") So(actual, ShouldContainSubstring, "repo7 test:1.0 883fc0c5 false 492B")
Convey("nonexistent digest", func() { Convey("nonexistent digest", func() {
args := []string{"imagetest", "--digest", "d1g35t"} args := []string{"imagetest", "--digest", "d1g35t"}