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

Commit 39c87cb

Browse files
committed
use relocation map to pull invocation image
Invocation image can be relocated. The relocation map about services is now applied at runtime by `cnab-run`, when running inside the invocation image. This change updates the invocation image definition in the `driver.Operation` using the relocation map if exists. So that the image can be pulled and run. Signed-off-by: Yves Brissaud <[email protected]>
1 parent 5361689 commit 39c87cb

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

internal/cnab/driver.go

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,28 @@ func SetupDriver(installation *store.Installation, dockerCli command.Cli, opts *
137137

138138
func WithRelocationMap(installation *store.Installation) func(op *driver.Operation) error {
139139
return func(op *driver.Operation) error {
140-
data, err := json.Marshal(installation.RelocationMap)
141-
if err != nil {
142-
return errors.Wrap(err, "could not marshal relocation map")
140+
if err := addRelocationMapToFiles(op, installation); err != nil {
141+
return err
143142
}
144-
op.Files["/cnab/app/relocation-mapping.json"] = string(data)
143+
relocateInvocationImage(op, installation)
145144
return nil
146145
}
147146
}
147+
148+
func addRelocationMapToFiles(op *driver.Operation, installation *store.Installation) error {
149+
data, err := json.Marshal(installation.RelocationMap)
150+
if err != nil {
151+
return errors.Wrap(err, "could not marshal relocation map")
152+
}
153+
op.Files["/cnab/app/relocation-mapping.json"] = string(data)
154+
155+
return nil
156+
}
157+
158+
func relocateInvocationImage(op *driver.Operation, installation *store.Installation) {
159+
invocImage := op.Image
160+
if relocatedImage, ok := installation.RelocationMap[invocImage.Image]; ok {
161+
invocImage.Image = relocatedImage
162+
op.Image = invocImage
163+
}
164+
}

0 commit comments

Comments
 (0)