Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit f7b4189

Browse files
committed
remove usage of image-map.json file
`cnab-go` adds two files to the invocation image: - `/cnab/bundle.json`: containing the whole `bundle.json` - `/cnab/app/image-map.json`: containing `Images` section of the bundle As this second file is only an extract of the Bundle it can safely be removed. The full removal needs to be done in `cnab-go`, here we only ignore it. Signed-off-by: Yves Brissaud <[email protected]>
1 parent bc0a6bf commit f7b4189

File tree

5 files changed

+23
-27
lines changed

5 files changed

+23
-27
lines changed

cmd/cnab-run/bundle.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package main
2+
3+
import (
4+
"github.com/deislabs/cnab-go/bundle"
5+
"github.com/docker/app/internal/relocated"
6+
)
7+
8+
const (
9+
// bundlePath is where the CNAB runtime will put the actual Bundle definition
10+
bundlePath = "/cnab/bundle.json"
11+
)
12+
13+
func getBundle() (*bundle.Bundle, error) {
14+
return relocated.BundleJSON(bundlePath)
15+
}

cmd/cnab-run/inspect.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ func inspectAction(instanceName string) error {
1515
}
1616
defer app.Cleanup()
1717

18-
imageMap, err := getBundleImageMap()
18+
bndl, err := getBundle()
1919
if err != nil {
2020
return err
2121
}
2222

2323
parameters := packager.ExtractCNABParametersValues(packager.ExtractCNABParameterMapping(app.Parameters()), os.Environ())
24-
return appinspect.ImageInspect(os.Stdout, app, parameters, imageMap)
24+
return appinspect.ImageInspect(os.Stdout, app, parameters, bndl.Images)
2525
}

cmd/cnab-run/install.go

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os"
77
"strconv"
88

9-
"github.com/deislabs/cnab-go/bundle"
109
"github.com/docker/app/internal"
1110
"github.com/docker/app/internal/packager"
1211
"github.com/docker/app/render"
@@ -19,12 +18,6 @@ import (
1918
"github.com/spf13/pflag"
2019
)
2120

22-
const (
23-
// imageMapFilePath is the path where the CNAB runtime will put the actual
24-
// service to image mapping to use
25-
imageMapFilePath = "/cnab/app/image-map.json"
26-
)
27-
2821
func installAction(instanceName string) error {
2922
cli, err := setupDockerContext()
3023
if err != nil {
@@ -42,12 +35,12 @@ func installAction(instanceName string) error {
4235
if err != nil {
4336
return err
4437
}
45-
imageMap, err := getBundleImageMap()
38+
bndl, err := getBundle()
4639
if err != nil {
4740
return err
4841
}
4942
parameters := packager.ExtractCNABParametersValues(packager.ExtractCNABParameterMapping(app.Parameters()), os.Environ())
50-
rendered, err := render.Render(app, parameters, imageMap)
43+
rendered, err := render.Render(app, parameters, bndl.Images)
5144
if err != nil {
5245
return err
5346
}
@@ -79,18 +72,6 @@ func getFlagset(orchestrator command.Orchestrator) *pflag.FlagSet {
7972
return result
8073
}
8174

82-
func getBundleImageMap() (map[string]bundle.Image, error) {
83-
mapJSON, err := ioutil.ReadFile(imageMapFilePath)
84-
if err != nil {
85-
return nil, err
86-
}
87-
var result map[string]bundle.Image
88-
if err := json.Unmarshal(mapJSON, &result); err != nil {
89-
return nil, err
90-
}
91-
return result, nil
92-
}
93-
9475
func addLabels(rendered *composetypes.Config) error {
9576
args, err := ioutil.ReadFile(internal.DockerArgsPath)
9677
if err != nil {

cmd/cnab-run/render.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func renderAction(instanceName string) error {
1919
}
2020
defer app.Cleanup()
2121

22-
imageMap, err := getBundleImageMap()
22+
bndl, err := getBundle()
2323
if err != nil {
2424
return err
2525
}
@@ -31,7 +31,7 @@ func renderAction(instanceName string) error {
3131

3232
parameters := packager.ExtractCNABParametersValues(packager.ExtractCNABParameterMapping(app.Parameters()), os.Environ())
3333

34-
rendered, err := render.Render(app, parameters, imageMap)
34+
rendered, err := render.Render(app, parameters, bndl.Images)
3535
if err != nil {
3636
return err
3737
}

internal/relocated/bundle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func FromBundle(bndl *bundle.Bundle) *Bundle {
3232

3333
// BundleFromFile creates a relocated bundle based on the bundle file and relocation map.
3434
func BundleFromFile(filename string) (*Bundle, error) {
35-
bndl, err := bundleJSON(filename)
35+
bndl, err := BundleJSON(filename)
3636
if err != nil {
3737
return nil, errors.Wrapf(err, "failed to read bundle")
3838
}
@@ -75,7 +75,7 @@ func (b *Bundle) Store(dir string) error {
7575
return nil
7676
}
7777

78-
func bundleJSON(bundlePath string) (*bundle.Bundle, error) {
78+
func BundleJSON(bundlePath string) (*bundle.Bundle, error) {
7979
data, err := ioutil.ReadFile(bundlePath)
8080
if err != nil {
8181
return nil, errors.Wrapf(err, "failed to read file %s", bundlePath)

0 commit comments

Comments
 (0)