Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate zplugin.go correctly with third-party plugins #6692

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions directives_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down