66 "os"
77
88 "github.com/docker/app/internal"
9+ "github.com/docker/app/internal/image"
910 "github.com/docker/app/internal/log"
1011 "github.com/docker/app/internal/packager"
11- "github.com/docker/app/internal/relocated"
1212 "github.com/docker/app/internal/store"
1313 appstore "github.com/docker/app/internal/store"
1414 "github.com/docker/cli/cli/command"
@@ -47,20 +47,20 @@ func getAppNameKind(name string) (string, nameKind) {
4747 return name , nameKindReference
4848}
4949
50- func extractAndLoadAppBasedBundle (dockerCli command.Cli , name string ) (* relocated. Bundle , string , error ) {
50+ func extractAndLoadAppBasedBundle (dockerCli command.Cli , name string ) (* image. AppImage , string , error ) {
5151 app , err := packager .Extract (name )
5252 if err != nil {
5353 return nil , "" , err
5454 }
5555 defer app .Cleanup ()
5656 bndl , err := packager .MakeBundleFromApp (dockerCli , app , nil )
57- return relocated .FromBundle (bndl ), "" , err
57+ return image .FromBundle (bndl ), "" , err
5858}
5959
6060// ResolveBundle looks for a CNAB bundle which can be in a Docker App Package format or
6161// a bundle stored locally or in the bundle store. It returns a built or found bundle,
62- // a reference to the bundle if it is found in the bundlestore , and an error.
63- func ResolveBundle (dockerCli command.Cli , bundleStore appstore.BundleStore , name string ) (* relocated. Bundle , string , error ) {
62+ // a reference to the bundle if it is found in the imageStore , and an error.
63+ func ResolveBundle (dockerCli command.Cli , imageStore appstore.ImageStore , name string ) (* image. AppImage , string , error ) {
6464 // resolution logic:
6565 // - if there is a docker-app package in working directory or if a directory is given use packager.Extract
6666 // - pull the bundle from the registry and add it to the bundle store
@@ -69,7 +69,7 @@ func ResolveBundle(dockerCli command.Cli, bundleStore appstore.BundleStore, name
6969 case nameKindDir :
7070 return extractAndLoadAppBasedBundle (dockerCli , name )
7171 case nameKindReference :
72- bndl , tagRef , err := GetBundle (dockerCli , bundleStore , name )
72+ bndl , tagRef , err := GetBundle (dockerCli , imageStore , name )
7373 if err != nil {
7474 return nil , "" , err
7575 }
@@ -79,16 +79,16 @@ func ResolveBundle(dockerCli command.Cli, bundleStore appstore.BundleStore, name
7979}
8080
8181// GetBundle searches for the bundle locally and tries to pull it if not found
82- func GetBundle (dockerCli command.Cli , bundleStore appstore.BundleStore , name string ) (* relocated. Bundle , reference.Reference , error ) {
83- bndl , ref , err := getBundleFromStore (bundleStore , name )
82+ func GetBundle (dockerCli command.Cli , imageStore appstore.ImageStore , name string ) (* image. AppImage , reference.Reference , error ) {
83+ bndl , ref , err := getBundleFromStore (imageStore , name )
8484 if err != nil {
8585 named , err := store .StringToNamedRef (name )
8686 if err != nil {
8787 return nil , nil , err
8888 }
8989 fmt .Fprintf (dockerCli .Err (), "Unable to find App image %q locally\n " , reference .FamiliarString (named ))
9090 fmt .Fprintf (dockerCli .Out (), "Pulling from registry...\n " )
91- bndl , err = PullBundle (dockerCli , bundleStore , named )
91+ bndl , err = PullBundle (dockerCli , imageStore , named )
9292 if err != nil {
9393 return nil , nil , err
9494 }
@@ -97,13 +97,13 @@ func GetBundle(dockerCli command.Cli, bundleStore appstore.BundleStore, name str
9797 return bndl , ref , nil
9898}
9999
100- func getBundleFromStore (bundleStore appstore.BundleStore , name string ) (* relocated. Bundle , reference.Reference , error ) {
101- ref , err := bundleStore .LookUp (name )
100+ func getBundleFromStore (imageStore appstore.ImageStore , name string ) (* image. AppImage , reference.Reference , error ) {
101+ ref , err := imageStore .LookUp (name )
102102 if err != nil {
103103 logrus .Debugf ("Unable to find reference %q in the bundle store" , name )
104104 return nil , nil , err
105105 }
106- bndl , err := bundleStore .Read (ref )
106+ bndl , err := imageStore .Read (ref )
107107 if err != nil {
108108 logrus .Debugf ("Unable to read bundle %q from store" , reference .FamiliarString (ref ))
109109 return nil , nil , err
@@ -112,7 +112,7 @@ func getBundleFromStore(bundleStore appstore.BundleStore, name string) (*relocat
112112}
113113
114114// PullBundle pulls the bundle and stores it into the bundle store
115- func PullBundle (dockerCli command.Cli , bundleStore appstore.BundleStore , tagRef reference.Named ) (* relocated. Bundle , error ) {
115+ func PullBundle (dockerCli command.Cli , imageStore appstore.ImageStore , tagRef reference.Named ) (* image. AppImage , error ) {
116116 insecureRegistries , err := internal .InsecureRegistriesFromEngine (dockerCli )
117117 if err != nil {
118118 return nil , fmt .Errorf ("could not retrieve insecure registries: %v" , err )
@@ -122,8 +122,8 @@ func PullBundle(dockerCli command.Cli, bundleStore appstore.BundleStore, tagRef
122122 if err != nil {
123123 return nil , err
124124 }
125- relocatedBundle := & relocated. Bundle {Bundle : bndl , RelocationMap : relocationMap }
126- if _ , err := bundleStore .Store (tagRef , relocatedBundle ); err != nil {
125+ relocatedBundle := & image. AppImage {Bundle : bndl , RelocationMap : relocationMap }
126+ if _ , err := imageStore .Store (tagRef , relocatedBundle ); err != nil {
127127 return nil , err
128128 }
129129 return relocatedBundle , nil
0 commit comments