in container/go/pkg/compat/config.go [397:440]
func updateConfigLayers(overrideInfo *OverrideConfigOpts, layerDigests []string, creationTime time.Time) error {
// diffIDs are ordered from bottom-most to top-most.
diffIDs := []v1.Hash{}
if len(overrideInfo.ConfigFile.RootFS.DiffIDs) > 0 {
diffIDs = overrideInfo.ConfigFile.RootFS.DiffIDs
}
if len(overrideInfo.Layer) > 0 {
var diffIDToAdd v1.Hash
for _, diffID := range layerDigests {
if diffID != emptySHA256Digest() {
diffIDToAdd = v1.Hash{Algorithm: "sha256", Hex: diffID}
diffIDs = append(diffIDs, diffIDToAdd)
}
}
overrideInfo.ConfigFile.RootFS = v1.RootFS{Type: "layers", DiffIDs: diffIDs}
// length of history is expected to match the length of diff_ids.
history := []v1.History{}
if len(overrideInfo.ConfigFile.History) > 0 {
history = overrideInfo.ConfigFile.History
}
var historyToAdd v1.History
for _, l := range layerDigests {
if err := overrideInfo.validate(); err != nil {
return errors.Wrapf(err, "unable to create a new config because the given options to override the existing image config/generate new config failed validation")
}
historyToAdd = v1.History{
Author: overrideInfo.Author,
Created: v1.Time{creationTime},
CreatedBy: overrideInfo.CreatedBy,
}
if l == emptySHA256Digest() {
historyToAdd.EmptyLayer = true
}
// prepend to history list.
history = append([]v1.History{historyToAdd}, history...)
}
overrideInfo.ConfigFile.History = history
}
return nil
}