layers: add option to initialize layer Flags

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2023-09-18 16:44:15 +02:00
parent f424bfcf9f
commit 15ac716f16
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772
2 changed files with 12 additions and 1 deletions

View File

@ -76,6 +76,8 @@ type ApplyDiffOpts struct {
// ApplyDiffWithDifferOpts contains optional arguments for ApplyDiffWithDiffer methods.
type ApplyDiffWithDifferOpts struct {
ApplyDiffOpts
Flags map[string]interface{}
}
// InitFunc initializes the storage driver.

View File

@ -2411,10 +2411,11 @@ func (r *layerStore) ApplyDiffFromStagingDirectory(id, stagingDirectory string,
}
if options == nil {
options = &drivers.ApplyDiffWithDifferOpts{
drivers.ApplyDiffOpts{
ApplyDiffOpts: drivers.ApplyDiffOpts{
Mappings: r.layerMappings(layer),
MountLabel: layer.MountLabel,
},
Flags: nil,
}
}
@ -2430,6 +2431,14 @@ func (r *layerStore) ApplyDiffFromStagingDirectory(id, stagingDirectory string,
layer.TOCDigest = diffOutput.TOCDigest
layer.UncompressedSize = diffOutput.Size
layer.Metadata = diffOutput.Metadata
if options != nil && options.Flags != nil {
if layer.Flags == nil {
layer.Flags = make(map[string]interface{})
}
for k, v := range options.Flags {
layer.Flags[k] = v
}
}
if len(diffOutput.TarSplit) != 0 {
tsdata := bytes.Buffer{}
compressor, err := pgzip.NewWriterLevel(&tsdata, pgzip.BestSpeed)