From d30142f5f192f47771a574ff1b8451568205b49c Mon Sep 17 00:00:00 2001 From: Assil Ksiksi Date: Sun, 5 Nov 2023 22:47:34 -0500 Subject: [PATCH] sort DependsOn and ExtraOptions slices --- compose.go | 4 ++++ testdata/TestDocker_WithProject_out.nix | 24 ++++++++++++------------ testdata/TestDocker_out.nix | 24 ++++++++++++------------ testdata/TestPodman_WithProject_out.nix | 24 ++++++++++++------------ testdata/TestPodman_out.nix | 24 ++++++++++++------------ 5 files changed, 52 insertions(+), 48 deletions(-) diff --git a/compose.go b/compose.go index 5092564..21a0272 100644 --- a/compose.go +++ b/compose.go @@ -214,6 +214,10 @@ func (g *Generator) postProcessContainers(containers []*NixContainer) { // Drop the reference to the service at the end of post-processing. This allows GC to // kick in and free the service allocation. c.service = nil + + // Sort slices now that we're done with the container. + slices.Sort(c.DependsOn) + slices.Sort(c.ExtraOptions) } } diff --git a/testdata/TestDocker_WithProject_out.nix b/testdata/TestDocker_WithProject_out.nix index 3a39a27..b0b8c2c 100644 --- a/testdata/TestDocker_WithProject_out.nix +++ b/testdata/TestDocker_WithProject_out.nix @@ -31,11 +31,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network-alias=jellyseerr" "--dns=1.1.1.1" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=jellyseerr" "--network=container:myproject_sabnzbd" ]; }; @@ -68,11 +68,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=myproject_default" - "--network-alias=sabnzbd" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=sabnzbd" + "--network=myproject_default" ]; }; systemd.services."docker-myproject_sabnzbd" = { @@ -98,11 +98,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=myproject_default" - "--network-alias=photoprism-mariadb" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=photoprism-mariadb" + "--network=myproject_default" ]; }; systemd.services."docker-photoprism-mariadb" = { @@ -150,13 +150,13 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=myproject_default" - "--network-alias=transmission" - "--dns=8.8.8.8" - "--dns=8.8.4.4" - "--privileged" "--cap-add=NET_ADMIN" "--device=/dev/net/tun:/dev/net/tun" + "--dns=8.8.4.4" + "--dns=8.8.8.8" + "--network-alias=transmission" + "--network=myproject_default" + "--privileged" ]; }; systemd.services."docker-torrent-client" = { @@ -191,11 +191,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=myproject_default" - "--network-alias=traefik" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=traefik" + "--network=myproject_default" ]; }; systemd.services."docker-traefik" = { diff --git a/testdata/TestDocker_out.nix b/testdata/TestDocker_out.nix index f7930ea..fcb1383 100644 --- a/testdata/TestDocker_out.nix +++ b/testdata/TestDocker_out.nix @@ -31,11 +31,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network-alias=jellyseerr" "--dns=1.1.1.1" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=jellyseerr" "--network=container:sabnzbd" ]; }; @@ -61,11 +61,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=default" - "--network-alias=photoprism-mariadb" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=photoprism-mariadb" + "--network=default" ]; }; systemd.services."docker-photoprism-mariadb" = { @@ -97,11 +97,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=default" - "--network-alias=sabnzbd" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=sabnzbd" + "--network=default" ]; }; systemd.services."docker-sabnzbd" = { @@ -150,13 +150,13 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=default" - "--network-alias=transmission" - "--dns=8.8.8.8" - "--dns=8.8.4.4" - "--privileged" "--cap-add=NET_ADMIN" "--device=/dev/net/tun:/dev/net/tun" + "--dns=8.8.4.4" + "--dns=8.8.8.8" + "--network-alias=transmission" + "--network=default" + "--privileged" ]; }; systemd.services."docker-torrent-client" = { @@ -191,11 +191,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=default" - "--network-alias=traefik" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=traefik" + "--network=default" ]; }; systemd.services."docker-traefik" = { diff --git a/testdata/TestPodman_WithProject_out.nix b/testdata/TestPodman_WithProject_out.nix index 044387c..4fc7dab 100644 --- a/testdata/TestPodman_WithProject_out.nix +++ b/testdata/TestPodman_WithProject_out.nix @@ -36,11 +36,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network-alias=jellyseerr" "--dns=1.1.1.1" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=jellyseerr" "--network=container:myproject_sabnzbd" ]; }; @@ -73,11 +73,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=myproject_default" - "--network-alias=sabnzbd" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=sabnzbd" + "--network=myproject_default" ]; }; systemd.services."podman-myproject_sabnzbd" = { @@ -103,11 +103,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=myproject_default" - "--network-alias=photoprism-mariadb" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=photoprism-mariadb" + "--network=myproject_default" ]; }; systemd.services."podman-photoprism-mariadb" = { @@ -155,13 +155,13 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=myproject_default" - "--network-alias=transmission" - "--dns=8.8.8.8" - "--dns=8.8.4.4" - "--privileged" "--cap-add=NET_ADMIN" "--device=/dev/net/tun:/dev/net/tun" + "--dns=8.8.4.4" + "--dns=8.8.8.8" + "--network-alias=transmission" + "--network=myproject_default" + "--privileged" ]; }; systemd.services."podman-torrent-client" = { @@ -196,11 +196,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=myproject_default" - "--network-alias=traefik" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=traefik" + "--network=myproject_default" ]; }; systemd.services."podman-traefik" = { diff --git a/testdata/TestPodman_out.nix b/testdata/TestPodman_out.nix index f44ae5c..da69ab9 100644 --- a/testdata/TestPodman_out.nix +++ b/testdata/TestPodman_out.nix @@ -36,11 +36,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network-alias=jellyseerr" "--dns=1.1.1.1" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=jellyseerr" "--network=container:sabnzbd" ]; }; @@ -66,11 +66,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=default" - "--network-alias=photoprism-mariadb" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=photoprism-mariadb" + "--network=default" ]; }; systemd.services."podman-photoprism-mariadb" = { @@ -102,11 +102,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=default" - "--network-alias=sabnzbd" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=sabnzbd" + "--network=default" ]; }; systemd.services."podman-sabnzbd" = { @@ -155,13 +155,13 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=default" - "--network-alias=transmission" - "--dns=8.8.8.8" - "--dns=8.8.4.4" - "--privileged" "--cap-add=NET_ADMIN" "--device=/dev/net/tun:/dev/net/tun" + "--dns=8.8.4.4" + "--dns=8.8.8.8" + "--network-alias=transmission" + "--network=default" + "--privileged" ]; }; systemd.services."podman-torrent-client" = { @@ -196,11 +196,11 @@ logDriver = "journald"; autoStart = false; extraOptions = [ - "--network=default" - "--network-alias=traefik" "--log-opt=compress=true" "--log-opt=max-file=3" "--log-opt=max-size=10m" + "--network-alias=traefik" + "--network=default" ]; }; systemd.services."podman-traefik" = {