Skip to content

Commit 0aa305c

Browse files
committed
crane: Add timestamp to flatten layer
1 parent b8e87ed commit 0aa305c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cmd/crane/cmd/flatten.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"encoding/json"
2020
"fmt"
2121
"log"
22+
"time"
2223

2324
"github.com/google/go-containerregistry/pkg/crane"
2425
"github.com/google/go-containerregistry/pkg/logs"
@@ -221,6 +222,7 @@ func flattenImage(old v1.Image, repo name.Repository, use string, o crane.Option
221222
// Clear layer-specific config file information.
222223
cf.RootFS.DiffIDs = []v1.Hash{}
223224
cf.History = []v1.History{}
225+
cf.Created = v1.Time{Time: time.Now().UTC()}
224226

225227
img, err := mutate.ConfigFile(empty.Image, cf)
226228
if err != nil {
@@ -236,6 +238,7 @@ func flattenImage(old v1.Image, repo name.Repository, use string, o crane.Option
236238
img, err = mutate.Append(img, mutate.Addendum{
237239
Layer: layer,
238240
History: v1.History{
241+
Created: cf.Created,
239242
CreatedBy: fmt.Sprintf("%s flatten %s", use, digest),
240243
Comment: string(oldHistory),
241244
},

0 commit comments

Comments
 (0)