aboutsummaryrefslogtreecommitdiff
path: root/directives_generate.go
diff options
context:
space:
mode:
authorGravatar Grant Spence <gspence@redhat.com> 2024-05-29 15:41:09 -0400
committerGravatar GitHub <noreply@github.com> 2024-05-29 15:41:09 -0400
commit0ed689e2d0401bc91b0876f3c0f41c89bbf83b34 (patch)
tree08ceabbfbbb593be48dabebccf14d2834175a721 /directives_generate.go
parent621ffde538e57772783f9e4a0df590d2f0d71beb (diff)
downloadcoredns-0ed689e2d0401bc91b0876f3c0f41c89bbf83b34.tar.gz
coredns-0ed689e2d0401bc91b0876f3c0f41c89bbf83b34.tar.zst
coredns-0ed689e2d0401bc91b0876f3c0f41c89bbf83b34.zip
Generate zplugin.go correctly with third-party plugins (#6692)
Previously, the generation of zplugin.go would not separate third-party external plugins from CoreDNS plugins in the go import block. This leads to the TestImportOrdering unit test failing, as it requires that third-party imports paths to be in a separate import block. While this issue does not affect the main CoreDNS repo, it can cause unit test failures in forks of CoreDNS that include external third-party plugins. Signed-off-by: Grant Spence <gspence@redhat.com>
Diffstat (limited to '')
-rw-r--r--directives_generate.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/directives_generate.go b/directives_generate.go
index ccfd43e43..5192bf16e 100644
--- a/directives_generate.go
+++ b/directives_generate.go
@@ -58,10 +58,22 @@ func genImports(file, pack string, mi map[string]string) {
outs += "\n"
}
+ coreDnsImports := ""
+ thirdPartyImports := ""
+
outs += "// Include all plugins.\n"
for _, v := range mi {
- outs += `_ "` + v + `"` + "\n"
+ if strings.HasPrefix(v, githubOrg) {
+ coreDnsImports += `_ "` + v + `"` + "\n"
+ } else {
+ thirdPartyImports += `_ "` + v + `"` + "\n"
+ }
}
+ outs += coreDnsImports
+ if thirdPartyImports != "" {
+ outs += "\n" + thirdPartyImports
+ }
+
outs += ")\n"
if err := formatAndWrite(file, outs); err != nil {
@@ -107,7 +119,8 @@ func formatAndWrite(file string, data string) error {
}
const (
- pluginPath = "github.com/coredns/coredns/plugin/"
+ githubOrg = "github.com/coredns"
+ pluginPath = githubOrg + "/coredns/plugin/"
pluginFile = "plugin.cfg"
pluginFSPath = "plugin/" // Where the plugins are located on the file system
header = "// generated by directives_generate.go; DO NOT EDIT\n\n"