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

Commit 44932b6

Browse files
authored
Merge pull request #719 from eunomie/relocation-push
Push local docker images and use relocation map
2 parents bff05c3 + 0f5dd8a commit 44932b6

File tree

209 files changed

+4632
-17805
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+4632
-17805
lines changed

Gopkg.lock

Lines changed: 13 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gopkg.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ required = ["github.com/wadey/gocovmerge"]
4242

4343
[[override]]
4444
name = "github.com/docker/cnab-to-oci"
45-
version = "v0.1.0-beta2"
45+
version = "v0.3.0-beta1"
4646

4747
[[override]]
4848
name = "github.com/containerd/containerd"
49-
branch = "master"
49+
version = "v1.3.0"
5050

5151
[[override]]
5252
name = "github.com/docker/cli"
5353
revision = "d83cd90464377d4164c8f70248d064b979e5ca98"
5454

5555
[[override]]
5656
name = "github.com/deislabs/cnab-go"
57-
version = "v0.3.2-beta1"
57+
version = "v0.7.1-beta1"
5858

5959
[[constraint]]
6060
name = "github.com/sirupsen/logrus"
@@ -82,7 +82,7 @@ required = ["github.com/wadey/gocovmerge"]
8282

8383
[[override]]
8484
name = "github.com/docker/distribution"
85-
revision = "0d3efadf0154c2b8a4e7b6621fff9809655cc580"
85+
revision = "0d3efadf0154c2b8a4e7b6621fff9809655cc580" # version needed by containerd v1.3.0
8686

8787
[[override]]
8888
name = "github.com/docker/swarmkit"

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,12 @@ coverage-test-e2e: coverage-bin
9393
@echo "Running e2e tests (coverage)..."
9494
@$(call mkdir,_build/cov)
9595
@$(call mkdir,$(TEST_RESULTS_DIR))
96-
DOCKERAPP_BINARY=../e2e/coverage-bin $(call GO_TESTSUM,e2e-coverage.xml) -v ./e2e
96+
DOCKERAPP_BINARY=../e2e/coverage-bin $(call GO_TESTSUM,e2e-coverage.xml) -v ./e2e $(INCLUDE_E2E)
9797

9898
coverage: coverage-test-unit coverage-test-e2e ## run tests with coverage
99+
@echo "Fixing coverage files..."
100+
find _build/cov/ -type f -name "*.out" -print0 | xargs -0 sed -i '/^coverage/d'
101+
grep coverage _build/cov/*.out || true
99102
go install ./vendor/github.com/wadey/gocovmerge/
100103
gocovmerge _build/cov/*.out > _build/cov/all.out
101104
go tool cover -func _build/cov/all.out
@@ -131,7 +134,7 @@ schemas: specification/bindata.go ## generate specification/bindata.go from json
131134
help: ## this help
132135
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
133136

134-
.PHONY: cross e2e-cross test check lint test-unit test-e2e coverage coverage-bin coverage-test-unit coverage-test-e2e clean vendor schemas help
137+
.PHONY: cross e2e-cross test check lint test-unit test-e2e coverage coverage-bin coverage-test-unit coverage-test-e2e clean vendor schemas help fix-coverage
135138
.DEFAULT: all
136139

137140

e2e/build_test.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"strings"
1010
"testing"
1111

12+
"github.com/docker/app/internal/relocated"
13+
1214
"gotest.tools/fs"
1315

1416
"github.com/docker/app/internal/store"
@@ -30,11 +32,8 @@ func TestBuild(t *testing.T) {
3032

3133
cfg := getDockerConfigDir(t, cmd)
3234

33-
f := path.Join(cfg, "app", "bundles", "docker.io", "library", "single", "_tags", "1.0.0", "bundle.json")
34-
data, err := ioutil.ReadFile(f)
35-
assert.NilError(t, err)
36-
var bndl bundle.Bundle
37-
err = json.Unmarshal(data, &bndl)
35+
f := path.Join(cfg, "app", "bundles", "docker.io", "library", "single", "_tags", "1.0.0", relocated.BundleFilename)
36+
bndl, err := relocated.BundleFromFile(f)
3837
assert.NilError(t, err)
3938

4039
built := []string{bndl.InvocationImages[0].Digest, bndl.Images["web"].Digest, bndl.Images["worker"].Digest}
@@ -53,7 +52,7 @@ func TestBuild(t *testing.T) {
5352
bytes, err := ioutil.ReadFile(iidfile)
5453
assert.NilError(t, err)
5554
iid := string(bytes)
56-
actualID, err := store.FromBundle(&bndl)
55+
actualID, err := store.FromBundle(bndl)
5756
assert.NilError(t, err)
5857
assert.Equal(t, iid, fmt.Sprintf("sha256:%s", actualID.String()))
5958
})
@@ -96,7 +95,7 @@ func TestBuildWithoutTag(t *testing.T) {
9695
assert.Equal(t, len(infos), 1)
9796
id := infos[0].Name()
9897

99-
f = path.Join(cfg, "app", "bundles", "_ids", id, "bundle.json")
98+
f = path.Join(cfg, "app", "bundles", "_ids", id, relocated.BundleFilename)
10099
data, err := ioutil.ReadFile(f)
101100
assert.NilError(t, err)
102101
var bndl bundle.Bundle
@@ -127,7 +126,7 @@ func TestBuildWithArgs(t *testing.T) {
127126
assert.Equal(t, len(infos), 1)
128127
id := infos[0].Name()
129128

130-
f = path.Join(cfg, "app", "bundles", "_ids", id, "bundle.json")
129+
f = path.Join(cfg, "app", "bundles", "_ids", id, relocated.BundleFilename)
131130
data, err := ioutil.ReadFile(f)
132131
assert.NilError(t, err)
133132
var bndl bundle.Bundle

e2e/cnab_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"path"
66
"testing"
77

8+
"github.com/docker/app/internal/relocated"
89
"gotest.tools/assert"
910
is "gotest.tools/assert/cmp"
1011
"gotest.tools/icmd"
@@ -50,7 +51,7 @@ func TestCallCustomStatusAction(t *testing.T) {
5051
icmd.RunCmd(cmd).Assert(t, icmd.Success)
5152

5253
// docker app install
53-
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", path.Join(testDir, "bundle.json"), "--name", testCase.name)
54+
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", path.Join(testDir, relocated.BundleFilename), "--name", testCase.name)
5455
icmd.RunCmd(cmd).Assert(t, icmd.Success)
5556

5657
// docker app uninstall
@@ -78,15 +79,13 @@ func TestCnabParameters(t *testing.T) {
7879
}()
7980

8081
// docker app install
81-
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", path.Join(testDir, "bundle.json"), "--name", "cnab-parameters",
82+
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", path.Join(testDir, relocated.BundleFilename), "--name", "cnab-parameters",
8283
"--set", "boolParam=true",
8384
"--set", "stringParam=value",
84-
"--set", "intParam=42",
85-
"--set", "floatParam=3.14")
85+
"--set", "intParam=42")
8686
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
8787
expectedOutput := `boolParam=true
8888
stringParam=value
89-
intParam=42
90-
floatParam=3.14`
89+
intParam=42`
9190
assert.Assert(t, is.Contains(result.Combined(), expectedOutput))
9291
}

e2e/commands_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/deislabs/cnab-go/credentials"
1414
"github.com/docker/app/internal"
15+
"github.com/docker/app/internal/relocated"
1516
"github.com/docker/app/internal/yaml"
1617
"gotest.tools/assert"
1718
is "gotest.tools/assert/cmp"
@@ -205,7 +206,7 @@ func TestRunOnlyOne(t *testing.T) {
205206
Err: `"docker app run" requires exactly 1 argument.`,
206207
})
207208

208-
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", "bundle.json", "myapp")
209+
cmd.Command = dockerCli.Command("app", "run", "--cnab-bundle-json", relocated.BundleFilename, "myapp")
209210
icmd.RunCmd(cmd).Assert(t, icmd.Expected{
210211
ExitCode: 1,
211212
Err: `"docker app run" cannot run a bundle and an App image`,
@@ -348,14 +349,14 @@ func TestCredentials(t *testing.T) {
348349
assert.NilError(t, err)
349350
bundleJSON := golden.Get(t, "credential-install-bundle.json")
350351
tmpDir := fs.NewDir(t, t.Name(),
351-
fs.WithFile("bundle.json", "", fs.WithBytes(bundleJSON)),
352+
fs.WithFile(relocated.BundleFilename, "", fs.WithBytes(bundleJSON)),
352353
fs.WithDir("local",
353354
fs.WithFile("test-creds.yaml", "", fs.WithBytes(buf)),
354355
),
355356
)
356357
defer tmpDir.Remove()
357358

358-
bundle := tmpDir.Join("bundle.json")
359+
bundle := tmpDir.Join(relocated.BundleFilename)
359360

360361
t.Run("missing", func(t *testing.T) {
361362
cmd.Command = dockerCli.Command(

e2e/coverage-bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $BUILD_DIR/docker-app.cov \
99
-test.coverprofile=$BUILD_DIR/cov/$(uuidgen).out \
1010
"$@" \
1111
| grep -vE '^PASS$' \
12-
| grep -vE '^coverage: [0-9]+\.[0-9]+% of statements in .+$' \
12+
| grep -vE '^coverage:.*$' \
1313
| grep -v '^=== RUN TestRunMain$'
1414

1515
exit ${PIPESTATUS[0]}

e2e/helper_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ func readFile(t *testing.T, path string) string {
2525
return strings.Replace(string(content), "\r", "", -1)
2626
}
2727

28+
type dindSwarmAndRegistryInfo struct {
29+
swarmAddress string
30+
registryAddress string
31+
configuredCmd icmd.Cmd
32+
stopRegistry func()
33+
registryLogs func() string
34+
}
35+
2836
func runWithDindSwarmAndRegistry(t *testing.T, todo func(dindSwarmAndRegistryInfo)) {
2937
cmd, cleanup := dockerCli.createTestCmd()
3038
defer cleanup()
@@ -83,6 +91,11 @@ func runWithDindSwarmAndRegistry(t *testing.T, todo func(dindSwarmAndRegistryInf
8391
todo(info)
8492
}
8593

94+
func build(t *testing.T, cmd icmd.Cmd, dockerCli dockerCliCommand, ref, path string) {
95+
cmd.Command = dockerCli.Command("app", "build", "-t", ref, path)
96+
icmd.RunCmd(cmd).Assert(t, icmd.Success)
97+
}
98+
8699
// Container represents a docker container
87100
type Container struct {
88101
image string

0 commit comments

Comments
 (0)