Skip to content

Commit

Permalink
sort DependsOn and ExtraOptions slices
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiksi committed Nov 6, 2023
1 parent 02c3b67 commit d30142f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 48 deletions.
4 changes: 4 additions & 0 deletions compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
24 changes: 12 additions & 12 deletions testdata/TestDocker_WithProject_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
};
Expand Down Expand Up @@ -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" = {
Expand All @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down
24 changes: 12 additions & 12 deletions testdata/TestDocker_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
};
Expand All @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down
24 changes: 12 additions & 12 deletions testdata/TestPodman_WithProject_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
};
Expand Down Expand Up @@ -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" = {
Expand All @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down
24 changes: 12 additions & 12 deletions testdata/TestPodman_out.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
];
};
Expand All @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down

0 comments on commit d30142f

Please sign in to comment.