Skip to content

Commit 72334df

Browse files
committed
docker: extract downloadConfigFile
Signed-off-by: Simarpreet Singh <[email protected]>
1 parent 72e5ec7 commit 72334df

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

extractor/docker/docker.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,18 @@ func (d DockerExtractor) Extract(ctx context.Context, imageName string, filename
214214
}
215215

216216
// download config file
217+
config, err := downloadConfigFile(err, r, ctx, image, m)
218+
if err != nil {
219+
return nil, err
220+
}
221+
222+
// special file for command analyzer
223+
fileMap["/config"] = config
224+
225+
return fileMap, nil
226+
}
227+
228+
func downloadConfigFile(err error, r *registry.Registry, ctx context.Context, image registry.Image, m *schema2.DeserializedManifest) ([]byte, error) {
217229
rc, err := r.DownloadLayer(ctx, image.Path, m.Manifest.Config.Digest)
218230
if err != nil {
219231
return nil, xerrors.Errorf("error in layer download: %w", err)
@@ -222,11 +234,7 @@ func (d DockerExtractor) Extract(ctx context.Context, imageName string, filename
222234
if err != nil {
223235
return nil, xerrors.Errorf("failed to decode config JSON: %w", err)
224236
}
225-
226-
// special file for command analyzer
227-
fileMap["/config"] = config
228-
229-
return fileMap, nil
237+
return config, nil
230238
}
231239

232240
func (d DockerExtractor) extractLayerFiles(layerCh chan layer, errCh chan error, ctx context.Context, filenames []string, filesInLayers map[string]extractor.FileMap, opqInLayers map[string]extractor.OPQDirs) error {

0 commit comments

Comments
 (0)