Skip to content

Commit

Permalink
Set config creation time without mutating
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh committed Dec 6, 2021
1 parent 5640c33 commit 29a003a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions pkg/build/gobuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
History: v1.History{
Author: "ko",
CreatedBy: "ko build " + ref.String(),
Created: g.kodataCreationTime,
Comment: "kodata contents, at $KO_DATA_PATH",
},
})
Expand All @@ -672,7 +673,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
appPath := path.Join(appDir, appFilename(ref.Path()))

// Construct a tarball with the binary and produce a layer.
binaryLayerBuf, err := tarBinary(appPath, file, v1.Time{}, platform)
binaryLayerBuf, err := tarBinary(appPath, file, g.creationTime, platform)
if err != nil {
return nil, err
}
Expand All @@ -690,6 +691,7 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
Layer: binaryLayer,
History: v1.History{
Author: "ko",
Created: g.creationTime,
CreatedBy: "ko build " + ref.String(),
Comment: "go build output, at " + appPath,
},
Expand Down Expand Up @@ -727,19 +729,13 @@ func (g *gobuild) buildOne(ctx context.Context, refStr string, base v1.Image, pl
cfg.Config.Labels[k] = v
}

cfg.Created = g.creationTime

image, err := mutate.ConfigFile(withApp, cfg)
if err != nil {
return nil, err
}

empty := v1.Time{}
if g.creationTime != empty {
image, err = mutate.CreatedAt(image, g.creationTime)
if err != nil {
return nil, err
}
}

si := signed.Image(image)

if g.sbom != nil {
Expand Down

0 comments on commit 29a003a

Please sign in to comment.