Skip to content

Commit

Permalink
Fix merge compose file's replicas error (#1446)
Browse files Browse the repository at this point in the history
  • Loading branch information
hangyan authored Oct 17, 2021
1 parent c7ba832 commit a87dd94
Show file tree
Hide file tree
Showing 30 changed files with 318 additions and 733 deletions.
5 changes: 5 additions & 0 deletions pkg/loader/compose/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,17 @@ func mergeComposeObject(oldCompose *types.Config, newCompose *types.Config) (*ty
if service.Deploy.Resources.Reservations != nil {
tmpOldService.Deploy.Resources.Reservations = service.Deploy.Resources.Reservations
}
if service.Deploy.Replicas != nil {
tmpOldService.Deploy.Replicas = service.Deploy.Replicas
}

if len(service.Devices) != 0 {
// merge the 2 sets of values
// TODO: need to merge the sets based on target values
// Not implemented yet as we don't convert devices to k8s anyway
tmpOldService.Devices = service.Devices
}

if len(service.DNS) != 0 {
// concat the 2 sets of values
tmpOldService.DNS = append(tmpOldService.DNS, service.DNS...)
Expand Down Expand Up @@ -791,6 +795,7 @@ func mergeComposeObject(oldCompose *types.Config, newCompose *types.Config) (*ty
if service.Image != "" {
tmpOldService.Image = service.Image
}

if service.Ipc != "" {
tmpOldService.Ipc = service.Ipc
}
Expand Down
10 changes: 9 additions & 1 deletion script/test/cmd/tests_new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,12 @@ convert::expect_success "$ocp_cmd" "$ocp_output"
# test service group by volume, not support openshift for now
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/service-group/compose.yaml convert --stdout -j --with-kompose-annotation=false --service-group-mode=volume"
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/service-group/output-k8s.json"
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"

# test merge multiple compose files
k8s_cmd="kompose -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/first.yaml -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/second.yaml convert --stdout -j --with-kompose-annotation=false"
ocp_cmd="kompose --provider=openshift -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/first.yaml -f $KOMPOSE_ROOT/script/test/fixtures/multiple-files/second.yaml convert --stdout -j --with-kompose-annotation=false"
k8s_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-k8s.json"
ocp_output="$KOMPOSE_ROOT/script/test/fixtures/multiple-files/output-ocp.json"
convert::expect_success_and_warning "$k8s_cmd" "$k8s_output"
convert::expect_success "$ocp_cmd" "$ocp_output"
27 changes: 0 additions & 27 deletions script/test/fixtures/multiple-compose-files/docker-k8s.yml

This file was deleted.

27 changes: 0 additions & 27 deletions script/test/fixtures/multiple-compose-files/docker-os.yml

This file was deleted.

299 changes: 0 additions & 299 deletions script/test/fixtures/multiple-compose-files/output-k8s-template.json

This file was deleted.

Loading

0 comments on commit a87dd94

Please sign in to comment.