@@ -120,7 +120,7 @@ func gzipBytes(b []byte) ([]byte, error) {
120
120
}
121
121
122
122
// appendLayer appends an uncompressed blob to the image, preserving the invariants required across the config and manifest.
123
- func (m * MutableSource ) AppendLayer (content []byte ) error {
123
+ func (m * MutableSource ) AppendLayer (content []byte , author string ) error {
124
124
compressedBlob , err := gzipBytes (content )
125
125
if err != nil {
126
126
return err
@@ -142,12 +142,7 @@ func (m *MutableSource) AppendLayer(content []byte) error {
142
142
// Also add it to the config.
143
143
diffID := digest .FromBytes (content )
144
144
m .cfg .RootFS .DiffIDs = append (m .cfg .RootFS .DiffIDs , diffID )
145
- history := manifest.Schema2History {
146
- Created : time .Now (),
147
- Author : "container-diff" ,
148
- }
149
- m .cfg .History = append (m .cfg .History , history )
150
-
145
+ m .appendConfigHistory (author , false )
151
146
return nil
152
147
}
153
148
@@ -182,11 +177,30 @@ func (m *MutableSource) Env() map[string]string {
182
177
183
178
// SetEnv takes a map of environment variables, and converts them to an array of strings
184
179
// in the form KEY=VALUE, and then sets the image config
185
- func (m * MutableSource ) SetEnv (envMap map [string ]string ) {
180
+ func (m * MutableSource ) SetEnv (envMap map [string ]string , author string ) {
186
181
envArray := []string {}
187
182
for key , value := range envMap {
188
183
entry := key + "=" + value
189
184
envArray = append (envArray , entry )
190
185
}
191
186
m .cfg .Schema2V1Image .Config .Env = envArray
187
+ m .appendConfigHistory (author , true )
188
+ }
189
+
190
+ func (m * MutableSource ) Config () * manifest.Schema2Config {
191
+ return m .cfg .Schema2V1Image .Config
192
+ }
193
+
194
+ func (m * MutableSource ) SetConfig (config * manifest.Schema2Config , author string , emptyLayer bool ) {
195
+ m .cfg .Schema2V1Image .Config = config
196
+ m .appendConfigHistory (author , emptyLayer )
197
+ }
198
+
199
+ func (m * MutableSource ) appendConfigHistory (author string , emptyLayer bool ) {
200
+ history := manifest.Schema2History {
201
+ Created : time .Now (),
202
+ Author : author ,
203
+ EmptyLayer : emptyLayer ,
204
+ }
205
+ m .cfg .History = append (m .cfg .History , history )
192
206
}
0 commit comments