forked from docker/app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
save relocation map from cnab-to-oci
When a relocation map is generated from `cnab-to-oci` save it within the same directory as the `bundle.json` file. More information about reloaction map can be found in corresponding `cnab-to-oci` issue: cnabio/cnab-to-oci#58 The `bundle.Bundle` struct is now wrapped in a `relocated.Bundle` that will also contain the relocation map. Methods to fetch `bundle.json` and `relocation-map.json` as well as en entire bundle with the relocation map at once are moved to a `fetch` package to avoid dependency cycle. Signed-off-by: Yves Brissaud <[email protected]>
- Loading branch information
Showing
19 changed files
with
281 additions
and
113 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package e2e | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
"testing" | ||
|
||
"gotest.tools/assert" | ||
"gotest.tools/icmd" | ||
) | ||
|
||
func TestRelocationMapCreatedOnPush(t *testing.T) { | ||
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) { | ||
cmd := info.configuredCmd | ||
cfg := getDockerConfigDir(t, cmd) | ||
|
||
path := filepath.Join("testdata", "local") | ||
ref := info.registryAddress + "/test/local:a-tag" | ||
bundlePath := filepath.Join(cfg, "app", "bundles", strings.Replace(info.registryAddress, ":", "_", 1), "test", "local", "_tags", "a-tag") | ||
|
||
// Given a locally built application | ||
build(t, cmd, dockerCli, ref, path) | ||
|
||
// When pushing to a registry | ||
cmd.Command = dockerCli.Command("app", "push", ref) | ||
icmd.RunCmd(cmd).Assert(t, icmd.Success) | ||
|
||
// Then the relocation map should exist | ||
_, err := os.Stat(filepath.Join(bundlePath, "relocation-map.json")) | ||
assert.NilError(t, err) | ||
}) | ||
} | ||
|
||
func TestRelocationMapCreatedOnPull(t *testing.T) { | ||
runWithDindSwarmAndRegistry(t, func(info dindSwarmAndRegistryInfo) { | ||
cmd := info.configuredCmd | ||
cfg := getDockerConfigDir(t, cmd) | ||
|
||
path := filepath.Join("testdata", "local") | ||
ref := info.registryAddress + "/test/local:a-tag" | ||
bundlePath := filepath.Join(cfg, "app", "bundles", strings.Replace(info.registryAddress, ":", "_", 1), "test", "local", "_tags", "a-tag") | ||
|
||
// Given a pushed application | ||
build(t, cmd, dockerCli, ref, path) | ||
cmd.Command = dockerCli.Command("app", "push", ref) | ||
icmd.RunCmd(cmd).Assert(t, icmd.Success) | ||
// And given application files are remove | ||
assert.NilError(t, os.RemoveAll(bundlePath)) | ||
_, err := os.Stat(filepath.Join(bundlePath, "bundle.json")) | ||
assert.Assert(t, os.IsNotExist(err)) | ||
|
||
// When application is pulled | ||
cmd.Command = dockerCli.Command("app", "pull", ref) | ||
icmd.RunCmd(cmd).Assert(t, icmd.Success) | ||
|
||
// Then the relocation map should exist | ||
_, err = os.Stat(filepath.Join(bundlePath, "relocation-map.json")) | ||
assert.NilError(t, err) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.