github.com/docker/app@v0.9.1-beta3.0.20210611140623-a48f773ab002/cmd/cnab-run/bundle.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/deislabs/cnab-go/bundle"
     5  	"github.com/docker/app/internal/image"
     6  	"github.com/docker/cnab-to-oci/relocation"
     7  )
     8  
     9  const (
    10  	// bundlePath is where the CNAB runtime will put the actual AppImage definition
    11  	bundlePath = "/cnab/bundle.json"
    12  	// relocationMapPath is where the CNAB runtime will put the relocation map
    13  	// See https://github.com/cnabio/cnab-spec/blob/master/103-bundle-runtime.md#image-relocation
    14  	relocationMapPath = "/cnab/app/relocation-mapping.json"
    15  )
    16  
    17  func getBundle() (*bundle.Bundle, error) {
    18  	return image.BundleJSON(bundlePath)
    19  }
    20  
    21  func getRelocationMap() (relocation.ImageRelocationMap, error) {
    22  	return image.RelocationMapJSON(relocationMapPath)
    23  }
    24  
    25  func getRelocatedBundle() (*image.AppImage, error) {
    26  	bndl, err := getBundle()
    27  	if err != nil {
    28  		return nil, err
    29  	}
    30  
    31  	relocationMap, err := getRelocationMap()
    32  	if err != nil {
    33  		return nil, err
    34  	}
    35  
    36  	return &image.AppImage{
    37  		Bundle:        bndl,
    38  		RelocationMap: relocationMap,
    39  	}, nil
    40  }