Skip to content

Commit

Permalink
omit IPAM driver if set to "default"
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiksi committed Sep 28, 2024
1 parent 344eeda commit 6cb9e5f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,10 @@ func (g *Generator) buildNixNetworks(composeProject *types.Project) ([]*NixNetwo
// https://docs.docker.com/compose/compose-file/06-networks/#ipam
// https://docs.docker.com/reference/cli/docker/network/create/
// https://docs.podman.io/en/latest/markdown/podman-network-create.1.html
if network.Ipam.Driver != "" {

// If driver is set to "default", we'll omit it and fallback to the
// runtime.
if network.Ipam.Driver != "" && network.Ipam.Driver != "default" {
n.IpamDriver = network.Ipam.Driver
}
for _, ipamConfig := range network.Ipam.Config {
Expand Down
3 changes: 3 additions & 0 deletions testdata/TestNetworkSettings.compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ networks:
other:
ipam:
driver: dhcp
default:
ipam:
driver: default
13 changes: 13 additions & 0 deletions testdata/TestNetworkSettings.docker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
virtualisation.oci-containers.backend = "docker";

# Networks
systemd.services."docker-network-test_default" = {
path = [ pkgs.docker ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStop = "docker network rm -f test_default";
};
script = ''
docker network inspect test_default || docker network create test_default
'';
partOf = [ "docker-compose-test-root.target" ];
wantedBy = [ "docker-compose-test-root.target" ];
};
systemd.services."docker-network-test_nginx_net" = {
path = [ pkgs.docker ];
serviceConfig = {
Expand Down
13 changes: 13 additions & 0 deletions testdata/TestNetworkSettings.podman.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
virtualisation.oci-containers.backend = "podman";

# Networks
systemd.services."podman-network-test_default" = {
path = [ pkgs.podman ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStop = "podman network rm -f test_default";
};
script = ''
podman network inspect test_default || podman network create test_default
'';
partOf = [ "podman-compose-test-root.target" ];
wantedBy = [ "podman-compose-test-root.target" ];
};
systemd.services."podman-network-test_nginx_net" = {
path = [ pkgs.podman ];
serviceConfig = {
Expand Down

0 comments on commit 6cb9e5f

Please sign in to comment.