Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Better variable name
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Oct 28, 2019
1 parent 85e0d36 commit 75deb14
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
5 changes: 2 additions & 3 deletions e2e/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,14 @@ func TestRenderFormatters(t *testing.T) {
cmd := info.configuredCmd

contextPath := filepath.Join("testdata", "simple")
appPath := filepath.Join(contextPath, "simple.dockerapp")
cmd.Command = dockerCli.Command("app", "build", "--tag", "a-simple-tag", "--no-resolve-image", contextPath)
icmd.RunCmd(cmd).Assert(t, icmd.Success)

cmd.Command = dockerCli.Command("app", "render", "--formatter", "json", appPath)
cmd.Command = dockerCli.Command("app", "render", "--formatter", "json", "a-simple-tag")
result := icmd.RunCmd(cmd).Assert(t, icmd.Success)
golden.Assert(t, result.Stdout(), "expected-json-render.golden")

cmd.Command = dockerCli.Command("app", "render", "--formatter", "yaml", appPath)
cmd.Command = dockerCli.Command("app", "render", "--formatter", "yaml", "a-simple-tag")
result = icmd.RunCmd(cmd).Assert(t, icmd.Success)
golden.Assert(t, result.Stdout(), "expected-yaml-render.golden")
})
Expand Down
6 changes: 3 additions & 3 deletions e2e/testdata/simple/simple.dockerapp/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
version: "3.6"
services:
api:
image: python:3.6@sha256:52f872eae9755743c9494e0e3cf02a47d34b42032cab1e5ab777b30c3665d5f1
image: python:3.6
networks:
back:
front:
aliases:
- api.example.com
- ${api_host}
web:
image: nginx:latest@sha256:922c815aa4df050d4df476e92daed4231f466acc8ee90e0e774951b0fd7195a4
image: nginx:latest
networks:
- front
volumes:
- static:/opt/${static_subdir}
ports:
- ${web_port}:80
db:
image: postgres:9.3@sha256:3cd40afb5803762170a1149ade6962fe24d405b3ccf2fe499ff1428635520a17
image: postgres:9.3
networks:
- back
networks:
Expand Down
8 changes: 4 additions & 4 deletions internal/commands/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func runBuild(dockerCli command.Cli, contextPath string, opt buildOptions) error
}

func buildImageUsingBuildx(app *types.App, contextPath string, opt buildOptions, dockerCli command.Cli) (*bundle.Bundle, error) {
buildopts, pulledImages, err := parseCompose(app, contextPath, opt)
buildopts, pulledServices, err := parseCompose(app, contextPath, opt)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -185,7 +185,7 @@ func buildImageUsingBuildx(app *types.App, contextPath string, opt buildOptions,
}

if !opt.noResolveImage {
err = fixServiceImageReferences(ctx, dockerCli, bundle, pulledImages)
err = fixServiceImageReferences(ctx, dockerCli, bundle, pulledServices)
if err != nil {
return nil, err
}
Expand All @@ -194,13 +194,13 @@ func buildImageUsingBuildx(app *types.App, contextPath string, opt buildOptions,
return bundle, nil
}

func fixServiceImageReferences(ctx context.Context, dockerCli command.Cli, bundle *bundle.Bundle, pulledImages []ServiceConfig) error {
func fixServiceImageReferences(ctx context.Context, dockerCli command.Cli, bundle *bundle.Bundle, pulledServices []ServiceConfig) error {
insecureRegistries, err := internal.InsecureRegistriesFromEngine(dockerCli)
if err != nil {
return errors2.Wrapf(err, "could not retrieve insecure registries")
}
resolver := remotes.CreateResolver(dockerCli.ConfigFile(), insecureRegistries...)
for _, service := range pulledImages {
for _, service := range pulledServices {
image := bundle.Images[service.Name]
ref, err := reference.ParseNormalizedNamed(*service.Image)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/commands/build/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ func parseCompose(app *types.App, contextPath string, options buildOptions) (map
return nil, nil, fmt.Errorf("Failed to parse compose file: %s", err)
}

pulledImages := []ServiceConfig{}
pulledServices := []ServiceConfig{}
opts := map[string]build.Options{}
for _, service := range services {
if service.Build == nil {
pulledImages = append(pulledImages, service)
pulledServices = append(pulledServices, service)
continue
}
var tags []string
Expand All @@ -49,7 +49,7 @@ func parseCompose(app *types.App, contextPath string, options buildOptions) (map
Tags: tags,
}
}
return opts, pulledImages, nil
return opts, pulledServices, nil
}

func flatten(in compose.MappingWithEquals) map[string]string {
Expand Down

0 comments on commit 75deb14

Please sign in to comment.