6
6
"os"
7
7
8
8
"github.com/docker/app/internal"
9
+ "github.com/docker/app/internal/image"
9
10
"github.com/docker/app/internal/log"
10
11
"github.com/docker/app/internal/packager"
11
- "github.com/docker/app/internal/relocated"
12
12
"github.com/docker/app/internal/store"
13
13
appstore "github.com/docker/app/internal/store"
14
14
"github.com/docker/cli/cli/command"
@@ -47,20 +47,20 @@ func getAppNameKind(name string) (string, nameKind) {
47
47
return name , nameKindReference
48
48
}
49
49
50
- func extractAndLoadAppBasedBundle (dockerCli command.Cli , name string ) (* relocated. Bundle , string , error ) {
50
+ func extractAndLoadAppBasedBundle (dockerCli command.Cli , name string ) (* image. AppImage , string , error ) {
51
51
app , err := packager .Extract (name )
52
52
if err != nil {
53
53
return nil , "" , err
54
54
}
55
55
defer app .Cleanup ()
56
56
bndl , err := packager .MakeBundleFromApp (dockerCli , app , nil )
57
- return relocated .FromBundle (bndl ), "" , err
57
+ return image .FromBundle (bndl ), "" , err
58
58
}
59
59
60
60
// ResolveBundle looks for a CNAB bundle which can be in a Docker App Package format or
61
61
// 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 ) {
64
64
// resolution logic:
65
65
// - if there is a docker-app package in working directory or if a directory is given use packager.Extract
66
66
// - 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
69
69
case nameKindDir :
70
70
return extractAndLoadAppBasedBundle (dockerCli , name )
71
71
case nameKindReference :
72
- bndl , tagRef , err := GetBundle (dockerCli , bundleStore , name )
72
+ bndl , tagRef , err := GetBundle (dockerCli , imageStore , name )
73
73
if err != nil {
74
74
return nil , "" , err
75
75
}
@@ -79,16 +79,16 @@ func ResolveBundle(dockerCli command.Cli, bundleStore appstore.BundleStore, name
79
79
}
80
80
81
81
// 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 )
84
84
if err != nil {
85
85
named , err := store .StringToNamedRef (name )
86
86
if err != nil {
87
87
return nil , nil , err
88
88
}
89
89
fmt .Fprintf (dockerCli .Err (), "Unable to find App image %q locally\n " , reference .FamiliarString (named ))
90
90
fmt .Fprintf (dockerCli .Out (), "Pulling from registry...\n " )
91
- bndl , err = PullBundle (dockerCli , bundleStore , named )
91
+ bndl , err = PullBundle (dockerCli , imageStore , named )
92
92
if err != nil {
93
93
return nil , nil , err
94
94
}
@@ -97,13 +97,13 @@ func GetBundle(dockerCli command.Cli, bundleStore appstore.BundleStore, name str
97
97
return bndl , ref , nil
98
98
}
99
99
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 )
102
102
if err != nil {
103
103
logrus .Debugf ("Unable to find reference %q in the bundle store" , name )
104
104
return nil , nil , err
105
105
}
106
- bndl , err := bundleStore .Read (ref )
106
+ bndl , err := imageStore .Read (ref )
107
107
if err != nil {
108
108
logrus .Debugf ("Unable to read bundle %q from store" , reference .FamiliarString (ref ))
109
109
return nil , nil , err
@@ -112,7 +112,7 @@ func getBundleFromStore(bundleStore appstore.BundleStore, name string) (*relocat
112
112
}
113
113
114
114
// 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 ) {
116
116
insecureRegistries , err := internal .InsecureRegistriesFromEngine (dockerCli )
117
117
if err != nil {
118
118
return nil , fmt .Errorf ("could not retrieve insecure registries: %v" , err )
@@ -122,8 +122,8 @@ func PullBundle(dockerCli command.Cli, bundleStore appstore.BundleStore, tagRef
122
122
if err != nil {
123
123
return nil , err
124
124
}
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 {
127
127
return nil , err
128
128
}
129
129
return relocatedBundle , nil
0 commit comments