mirror of
https://github.com/moby/buildkit.git
synced 2026-08-04 14:50:21 +00:00
exporter: avoid modifying exporter inputs
Co-authored-by: fahed dorgaa <fahed.dorgaa@gmail.com> Co-authored-by: a-palchikov <deemok@gmail.com> Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
@@ -188,6 +188,7 @@ func (e *imageExporterInstance) Config() *exporter.Config {
|
||||
}
|
||||
|
||||
func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source, sessionID string) (_ map[string]string, descref exporter.DescriptorReference, err error) {
|
||||
src = src.Clone()
|
||||
if src.Metadata == nil {
|
||||
src.Metadata = make(map[string][]byte)
|
||||
}
|
||||
|
||||
@@ -117,6 +117,7 @@ func (e *imageExporterInstance) Export(ctx context.Context, src *exporter.Source
|
||||
return nil, nil, errors.Errorf("docker exporter does not currently support exporting manifest lists")
|
||||
}
|
||||
|
||||
src = src.Clone()
|
||||
if src.Metadata == nil {
|
||||
src.Metadata = make(map[string][]byte)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package result
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"sync"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
@@ -14,6 +15,15 @@ type Result[T comparable] struct {
|
||||
Attestations map[string][]Attestation[T]
|
||||
}
|
||||
|
||||
func (r *Result[T]) Clone() *Result[T] {
|
||||
return &Result[T]{
|
||||
Ref: r.Ref,
|
||||
Refs: maps.Clone(r.Refs),
|
||||
Metadata: maps.Clone(r.Metadata),
|
||||
Attestations: maps.Clone(r.Attestations),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Result[T]) AddMeta(k string, v []byte) {
|
||||
r.mu.Lock()
|
||||
if r.Metadata == nil {
|
||||
|
||||
Reference in New Issue
Block a user