INNER CODE UNIT · Go

unpack

container2wasm/container2wasm · cmd/create-spec/main.go:85

func unpack(ctx context.Context, imgDir string, platform *ocispec.Platform, rootfs string) (io.Reader, error) {
	fmt.Println("Trying to unpack image as an OCI image")
	if rootfs == "" {
		return nil, fmt.Errorf("specify rootfs")
	}
	idxR, err := os.Open(filepath.Join(imgDir, "index.json"))
	if err != nil {
		fmt.Println("Failed to unpack the image as an OCI image:", err)
		return unpackDocker(ctx, imgDir, platform, rootfs)
	}
	var idx ocispec.Index
	if err := json.NewDecoder(idxR).Decode(&idx); err != nil {
		return nil, err
	}
	var platformMC platforms.MatchComparer
	if platform != nil {
		platformMC = platforms.Only(*platform)
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…