diff --git a/e2e-tests/resources/outputs/example-01-hello-output.txt b/e2e-tests/resources/outputs/example-01-hello-output.txt index 56558cb..7aed00b 100644 --- a/e2e-tests/resources/outputs/example-01-hello-output.txt +++ b/e2e-tests/resources/outputs/example-01-hello-output.txt @@ -1,5 +1,5 @@ services: - hello-world: + hello-world-hello: command: - -c - while true; do echo Hello World!; sleep 5; done diff --git a/e2e-tests/resources/outputs/example-02-environment-output.txt b/e2e-tests/resources/outputs/example-02-environment-output.txt index ea4e3d9..0637e57 100644 --- a/e2e-tests/resources/outputs/example-02-environment-output.txt +++ b/e2e-tests/resources/outputs/example-02-environment-output.txt @@ -1,5 +1,5 @@ services: - hello-world: + hello-world-hello: command: - -c - while true; do echo Hello $${FRIEND}!; sleep 5; done diff --git a/e2e-tests/resources/outputs/example-03-dependencies-service-a-output.txt b/e2e-tests/resources/outputs/example-03-dependencies-service-a-output.txt index 8425103..bd9cc26 100644 --- a/e2e-tests/resources/outputs/example-03-dependencies-service-a-output.txt +++ b/e2e-tests/resources/outputs/example-03-dependencies-service-a-output.txt @@ -1,5 +1,5 @@ services: - service-a: + service-a-service-a: command: - -c - 'while true; do echo service-a: Hello $${FRIEND}! Connecting to $${CONNECTION_STRING}...; sleep 10; done' diff --git a/e2e-tests/resources/outputs/example-03-dependencies-service-b-output.txt b/e2e-tests/resources/outputs/example-03-dependencies-service-b-output.txt index 168b5f7..657c736 100644 --- a/e2e-tests/resources/outputs/example-03-dependencies-service-b-output.txt +++ b/e2e-tests/resources/outputs/example-03-dependencies-service-b-output.txt @@ -1,5 +1,5 @@ services: - service-b: + service-b-service-b: command: - -c - 'while true; do echo service-b: Hello $${FRIEND}!; sleep 5; done' diff --git a/e2e-tests/resources/outputs/example-04-extras-output.txt b/e2e-tests/resources/outputs/example-04-extras-output.txt index 22a94f7..16b0820 100644 --- a/e2e-tests/resources/outputs/example-04-extras-output.txt +++ b/e2e-tests/resources/outputs/example-04-extras-output.txt @@ -1,5 +1,5 @@ services: - web-app: + web-app-hello: image: nginx ports: - target: 80 diff --git a/e2e-tests/resources/outputs/run -f example-score.yaml --build test-output.txt b/e2e-tests/resources/outputs/run -f example-score.yaml --build test-output.txt index 323fdad..e116804 100644 --- a/e2e-tests/resources/outputs/run -f example-score.yaml --build test-output.txt +++ b/e2e-tests/resources/outputs/run -f example-score.yaml --build test-output.txt @@ -1,5 +1,5 @@ services: - hello-world: + hello-world-hello: build: context: test command: diff --git a/e2e-tests/resources/outputs/run -f example-score.yaml --overrides overrides.yaml-output.txt b/e2e-tests/resources/outputs/run -f example-score.yaml --overrides overrides.yaml-output.txt index fb4a6fd..34080a7 100644 --- a/e2e-tests/resources/outputs/run -f example-score.yaml --overrides overrides.yaml-output.txt +++ b/e2e-tests/resources/outputs/run -f example-score.yaml --overrides overrides.yaml-output.txt @@ -1,5 +1,5 @@ services: - hello-world: + hello-world-hello: command: - -c - while true; do echo Hello World!; sleep 5; done diff --git a/e2e-tests/resources/outputs/run -f example-score.yaml -p containers.hello.image=hello:1.1-output.txt b/e2e-tests/resources/outputs/run -f example-score.yaml -p containers.hello.image=hello:1.1-output.txt index 0b4df55..d82f709 100644 --- a/e2e-tests/resources/outputs/run -f example-score.yaml -p containers.hello.image=hello:1.1-output.txt +++ b/e2e-tests/resources/outputs/run -f example-score.yaml -p containers.hello.image=hello:1.1-output.txt @@ -1,5 +1,5 @@ services: - hello-world: + hello-world-hello: command: - -c - while true; do echo Hello World!; sleep 5; done diff --git a/e2e-tests/resources/outputs/run -f example-score.yaml-output.txt b/e2e-tests/resources/outputs/run -f example-score.yaml-output.txt index 56558cb..7aed00b 100644 --- a/e2e-tests/resources/outputs/run -f example-score.yaml-output.txt +++ b/e2e-tests/resources/outputs/run -f example-score.yaml-output.txt @@ -1,5 +1,5 @@ services: - hello-world: + hello-world-hello: command: - -c - while true; do echo Hello World!; sleep 5; done diff --git a/internal/compose/convert.go b/internal/compose/convert.go index 10d3516..0db93a1 100644 --- a/internal/compose/convert.go +++ b/internal/compose/convert.go @@ -92,7 +92,7 @@ func ConvertSpec(spec *score.Workload) (*compose.Project, ExternalVariables, err // END (NOTE) var svc = compose.ServiceConfig{ - Name: spec.Metadata.Name, + Name: spec.Metadata.Name + "-" + containerName, Image: cSpec.Image, Entrypoint: cSpec.Command, Command: cSpec.Args, @@ -101,14 +101,10 @@ func ConvertSpec(spec *score.Workload) (*compose.Project, ExternalVariables, err Volumes: volumes, } - if len(spec.Containers) > 1 { - // if we have more than 1 container then namespace them with the container name - svc.Name += "-" + containerName - // if we are not the "first" service, then inherit the network from the first service - if len(project.Services) > 0 { - svc.Ports = nil - svc.NetworkMode = "service:" + project.Services[0].Name - } + // if we are not the "first" service, then inherit the network from the first service + if len(project.Services) > 0 { + svc.Ports = nil + svc.NetworkMode = "service:" + project.Services[0].Name } project.Services = append(project.Services, svc) diff --git a/internal/compose/convert_test.go b/internal/compose/convert_test.go index 44fd8a3..06acecc 100644 --- a/internal/compose/convert_test.go +++ b/internal/compose/convert_test.go @@ -67,7 +67,7 @@ func TestScoreConvert(t *testing.T) { Project: &compose.Project{ Services: compose.Services{ { - Name: "test", + Name: "test-backend", Image: "busybox", Entrypoint: compose.ShellCommand{ "/bin/sh", @@ -137,7 +137,7 @@ func TestScoreConvert(t *testing.T) { Project: &compose.Project{ Services: compose.Services{ { - Name: "test", + Name: "test-backend", Image: "busybox", Environment: compose.MappingWithEquals{ "DEBUG": stringPtr("${DEBUG}"),