// getLayerData downloads/opens a layer archive and extracts it into memory. func getLayerData(path string, imageFormat string) (data map[string][]byte, err error) { data, err = detectors.DetectData(path, imageFormat, append(detectors.GetRequiredFilesPackages(), detectors.GetRequiredFilesOS()...), maxFileSize) if err != nil { return nil, err } return }
// getLayerData downloads/opens a layer archive and extracts it into memory. func getLayerData(path string) (data map[string][]byte, err error) { var layerReader io.ReadCloser if strings.HasPrefix(path, "http://") || strings.HasPrefix(path, "https://") { r, err := http.Get(path) if err != nil { return nil, cerrors.ErrCouldNotDownload } layerReader = r.Body } else { layerReader, err = os.Open(path) if err != nil { return nil, cerrors.ErrNotFound } } defer layerReader.Close() data, err = utils.SelectivelyExtractArchive(layerReader, append(detectors.GetRequiredFilesPackages(), detectors.GetRequiredFilesOS()...), maxFileSize) if err != nil { return nil, err } return }