Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Commit 05135ca

Browse files
committed
dockerfile-optimizer: improves PR message
Signed-off-by: Sam Alba <216487+samalba@users.noreply.github.com>
1 parent c3d2fcc commit 05135ca

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

dockerfile-optimizer/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ require (
2626

2727
require (
2828
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
29+
github.com/dustin/go-humanize v1.0.1 // indirect
2930
github.com/go-logr/logr v1.4.2 // indirect
3031
github.com/go-logr/stdr v1.2.2 // indirect
3132
github.com/google/uuid v1.6.0 // indirect

dockerfile-optimizer/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK3
88
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
99
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1010
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
11+
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
12+
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
1113
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
1214
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
1315
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=

dockerfile-optimizer/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323

2424
"dagger/dockerfile-optimizer/internal/dagger"
2525

26+
"github.com/dustin/go-humanize"
2627
"github.com/google/uuid"
2728
)
2829

@@ -181,8 +182,8 @@ func (m *DockerfileOptimizer) OptimizeDockerfile(ctx context.Context, githubToke
181182
}
182183

183184
answer += "\n\nImage info:\n"
184-
answer += fmt.Sprintf("- The original image has %d layers and is %d bytes in size.\n", originalImgInfo[0], originalImgInfo[1])
185-
answer += fmt.Sprintf("- The optimized image has %d layers and is %d bytes in size.\n", lastImgInfo[0], lastImgInfo[1])
185+
answer += fmt.Sprintf("- The original image has %d layers and is %s in size.\n", originalImgInfo[0], humanize.Bytes(uint64(originalImgInfo[1])))
186+
answer += fmt.Sprintf("- The optimized image has %d layers and is %s in size.\n", lastImgInfo[0], humanize.Bytes(uint64(lastImgInfo[1])))
186187

187188
return createPR(ctx, githubToken, repoURL, lastState, dockerfile, answer)
188189
}

0 commit comments

Comments
 (0)