[25.11] coredns: 1.13.2 -> 1.14.3 (#521975)

This commit is contained in:
Thomas Gerbet
2026-05-29 08:57:48 +00:00
committed by GitHub
3 changed files with 112 additions and 55 deletions

View File

@@ -405,6 +405,7 @@ in
containers-tmpfs = runTest ./containers-tmpfs.nix;
containers-unified-hierarchy = runTest ./containers-unified-hierarchy.nix;
convos = runTest ./convos.nix;
coredns = runTest ./coredns.nix;
corerad = runTest ./corerad.nix;
corteza = runTest ./corteza.nix;
cosmic = runTest {

42
nixos/tests/coredns.nix Normal file
View File

@@ -0,0 +1,42 @@
{ pkgs, ... }:
{
name = "coredns";
meta = with pkgs.lib.maintainers; {
maintainers = [ johanot ];
};
nodes.machine =
{ pkgs, ... }:
{
environment.systemPackages = [ pkgs.dnsutils ];
services.coredns = {
enable = true;
config = ''
.:10053 {
ipecho {
domain test.nixos.org
ttl 2629800
}
}
'';
package = pkgs.coredns.override {
externalPlugins = [
{
name = "ipecho";
repo = "github.com/Eun/coredns-ipecho";
version = "224170ebca45cc59c6b071d280a18f42d1ff130c";
position = "start-of-file";
}
];
vendorHash = "sha256-66WNU+t/frHfbxexYdiXzgXKLxPyLnN6JuKnlG/kSQY=";
};
};
};
testScript = ''
machine.start()
machine.wait_for_unit("coredns.service")
machine.wait_for_open_port(10053)
machine.succeed("dig @127.0.0.1 -p 10053 127.0.0.2.test.nixos.org A +short | grep 127.0.0.2")
'';
}

View File

@@ -6,7 +6,7 @@
installShellFiles,
nixosTests,
externalPlugins ? [ ],
vendorHash ? "sha256-bnNpJgy54wvTST1Jtfbd1ldLJrIzTW62TL7wyHeqz28=",
vendorHash ? "sha256-9LLTgIjOOMvYx4nhy+6X9bEBvqlKeTx//39q+YWXeHw=",
}:
let
@@ -14,13 +14,13 @@ let
in
buildGoModule (finalAttrs: {
pname = "coredns";
version = "1.13.2";
version = "1.14.3";
src = fetchFromGitHub {
owner = "coredns";
repo = "coredns";
tag = "v${finalAttrs.version}";
hash = "sha256-9ggyFixdNy0t4UA8ZxU5oMUzA/8EB/k1jors4f8Q6YE=";
hash = "sha256-Uk4oWsUxaGdLQzX5JywYzi7pmQHGo06uQdLeOkP4U/s";
};
inherit vendorHash;
@@ -32,59 +32,61 @@ buildGoModule (finalAttrs: {
"man"
];
# Override the go-modules fetcher derivation to fetch plugins
modBuildPhase = ''
cp plugin.cfg plugin.cfg.orig
${
(lib.concatMapStringsSep "\n" (
plugin:
let
position = plugin.position or "end-of-file";
formatPlugin = { name, repo, ... }: "${name}:${repo}";
in
if position == "end-of-file" then
"echo '${formatPlugin plugin}' >> plugin.cfg"
else if position == "start-of-file" then
"sed -i '1i ${formatPlugin plugin}' plugin.cfg"
else if lib.hasAttrByPath [ "before" ] position then
''
if ! grep -q '^${position.before}:' plugin.cfg; then
echo 'Failed to insert ${plugin.name} before ${position.before} in plugin.cfg: ${position.before} is not in plugin.cfg'
exit 1
fi
sed -i '/^${position.before}:/i ${formatPlugin plugin}' plugin.cfg
''
else if lib.hasAttrByPath [ "after" ] position then
''
if ! grep -q '^${position.after}:' plugin.cfg; then
echo 'Failed to insert ${plugin.name} after ${position.after} in plugin.cfg: ${position.after} is not in plugin.cfg'
exit 1
fi
sed -i '/^${position.after}:/a ${formatPlugin plugin}' plugin.cfg
''
else
throw ''
Unsupported position value in externalPlugin:
${builtins.toJSON plugin}.
Valid values for position attr are:
- position = "end-of-file" (the default)
- position = "start-of-file"
- position.before = "{other plugin}"
- position.after = "{other plugin}"
''
) externalPlugins)
}
diff -u plugin.cfg.orig plugin.cfg || true
for src in ${toString (attrsToSources externalPlugins)}; do go get $src; done
CC= GOOS= GOARCH= go generate
go mod tidy
go mod vendor
'';
overrideModAttrs = {
# Add plugins before vendoring the modules.
preBuild = ''
cp plugin.cfg plugin.cfg.orig
${
(lib.concatMapStringsSep "\n" (
plugin:
let
position = plugin.position or "end-of-file";
formatPlugin = { name, repo, ... }: "${name}:${repo}";
in
if position == "end-of-file" then
"echo '${formatPlugin plugin}' >> plugin.cfg"
else if position == "start-of-file" then
"sed -i '1i ${formatPlugin plugin}' plugin.cfg"
else if lib.hasAttrByPath [ "before" ] position then
''
if ! grep -q '^${position.before}:' plugin.cfg; then
echo 'Failed to insert ${plugin.name} before ${position.before} in plugin.cfg: ${position.before} is not in plugin.cfg'
exit 1
fi
sed -i '/^${position.before}:/i ${formatPlugin plugin}' plugin.cfg
''
else if lib.hasAttrByPath [ "after" ] position then
''
if ! grep -q '^${position.after}:' plugin.cfg; then
echo 'Failed to insert ${plugin.name} after ${position.after} in plugin.cfg: ${position.after} is not in plugin.cfg'
exit 1
fi
sed -i '/^${position.after}:/a ${formatPlugin plugin}' plugin.cfg
''
else
throw ''
Unsupported position value in externalPlugin:
${builtins.toJSON plugin}.
Valid values for position attr are:
- position = "end-of-file" (the default)
- position = "start-of-file"
- position.before = "{other plugin}"
- position.after = "{other plugin}"
''
) externalPlugins)
}
diff -u plugin.cfg.orig plugin.cfg || true
for src in ${toString (attrsToSources externalPlugins)}; do go get $src; done
GOFLAGS=''${GOFLAGS//-mod=vendor/} CC= GOOS= GOARCH= go generate
go mod tidy
'';
modInstallPhase = ''
mv -t vendor go.mod go.sum plugin.cfg
cp -r --reflink=auto vendor "$out"
'';
# Move the modified `go.mod`, `go.sum`, and `plugin.cfg` files into the
# vendor directory so we can retrieve them later in the `preBuild` hook.
postBuild = ''
mv -t vendor go.mod go.sum plugin.cfg
'';
};
preBuild = ''
chmod -R u+w vendor
@@ -102,10 +104,21 @@ buildGoModule (finalAttrs: {
substituteInPlace test/readme_test.go \
--replace-fail "TestReadme" "SkipReadme"
substituteInPlace test/metrics_test.go \
--replace-fail "TestMetricsRewriteRequestSize" "SkipMetricsRewriteRequestSize"
substituteInPlace test/quic_test.go \
--replace-fail "TestQUICReloadDoesNotPanic" "SkipQUICReloadDoesNotPanic"
# this test fails if any external plugins were imported.
# it's a lint rather than a test of functionality, so it's safe to disable.
substituteInPlace test/presubmit_test.go \
--replace-fail "TestImportOrdering" "SkipImportOrdering"
substituteInPlace plugin/pkg/parse/transport_test.go \
--replace-fail \
"TestTransport" \
"SkipTransport"
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
# loopback interface is lo0 on macos
@@ -123,6 +136,7 @@ buildGoModule (finalAttrs: {
'';
passthru.tests = {
coredns-external-plugins = nixosTests.coredns;
kubernetes-single-node = nixosTests.kubernetes.dns-single-node;
kubernetes-multi-node = nixosTests.kubernetes.dns-multi-node;
};