diff --git a/Makefile b/Makefile index 6fcc2fb..e8a4e89 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +PLUGINDIR:=.coredns/plugin + all: hugo -d public/ cp _redirects public/ @@ -18,8 +20,8 @@ run: # Sync CoreDNS' plugin README.md's to coredns.io. Also sync the release notes from the notes directory. .PHONY: sync sync: - @GO111MODULE=on go run bin/sync.go - @cp -vu .coredns/notes/coredns-* content/blog + @GO111MODULE=on go run bin/sync.go -plugindir $(PLUGINDIR) + @cp -vu $(PLUGINDIR)/../notes/coredns-* content/blog # Scan all markdown files for Corefile snippets and check validity github.com/miekg/corecheck .PHONY: test diff --git a/bin/sync.go b/bin/sync.go index 76a33d7..8a86773 100644 --- a/bin/sync.go +++ b/bin/sync.go @@ -3,6 +3,7 @@ package main import ( "bufio" "bytes" + "flag" "io/ioutil" "log" "os" @@ -14,8 +15,7 @@ import ( ) const ( - pluginDir = ".coredns/plugin/" - pageDir = "content/plugins/" + pageDir = "content/plugins/" ) type page struct { @@ -32,7 +32,12 @@ type meta struct { Date string `toml:"date"` } +var ( + pluginDir = flag.String("plugindir", ".coredns/plugin", "directory where to find coredns") +) + func main() { + flag.Parse() // Current pages pages, err := getPages(pageDir) if err != nil { @@ -40,7 +45,7 @@ func main() { } // Incoming content - plugins, err := getContent(pluginDir) + plugins, err := getContent(*pluginDir) if err != nil { log.Fatalf("Failed getting all plugin contents: %s", err) } @@ -82,7 +87,7 @@ func main() { if err != nil { log.Fatalf("Error writing file: %s", err) } - log.Printf("Wrote content changes %s to %s", path.Join(pluginDir, p, "README.md"), filePath) + log.Printf("Wrote content changes %s to %s", path.Join(*pluginDir, p, "README.md"), filePath) } }