@@ -35,20 +35,24 @@ func WithDepotSave(buildOpts map[string]buildx.Options, opts SaveOptions) map[st
35
35
}
36
36
}
37
37
38
+ exports := deepCloneExports (buildOpt .Exports )
39
+
38
40
for _ , i := range imageExportIndices {
39
- _ , ok := buildOpt . Exports [i ].Attrs ["push" ]
41
+ _ , ok := exports [i ].Attrs ["push" ]
40
42
hadPush = hadPush || ok
41
- buildOpt . Exports [i ].Attrs ["push" ] = "true"
43
+ exports [i ].Attrs ["push" ] = "true"
42
44
}
43
45
44
46
if len (imageExportIndices ) == 0 {
45
47
exportImage := client.ExportEntry {
46
48
Type : "image" ,
47
49
Attrs : map [string ]string {"push" : "true" },
48
50
}
49
- buildOpt . Exports = append (buildOpt . Exports , exportImage )
51
+ exports = append (exports , exportImage )
50
52
}
51
53
54
+ buildOpt .Exports = exports
55
+
52
56
additionalTags := slices .Clone (opts .AdditionalTags )
53
57
for i , tag := range additionalTags {
54
58
if opts .AddTargetSuffix {
@@ -68,3 +72,23 @@ func WithDepotSave(buildOpts map[string]buildx.Options, opts SaveOptions) map[st
68
72
69
73
return buildOpts
70
74
}
75
+
76
+ func deepCloneExports (original []client.ExportEntry ) []client.ExportEntry {
77
+ if original == nil {
78
+ return nil
79
+ }
80
+
81
+ exports := make ([]client.ExportEntry , len (original ))
82
+ for i := range original {
83
+ clone := original [i ]
84
+ // Attrs is the only field with references
85
+ clone .Attrs = make (map [string ]string , len (original [i ].Attrs ))
86
+ for k , v := range original [i ].Attrs {
87
+ clone .Attrs [k ] = v
88
+ }
89
+
90
+ exports [i ] = clone
91
+ }
92
+
93
+ return exports
94
+ }
0 commit comments