From 3874e1dc795c109048f6b8cc9d8c45d6a77f9a80 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 4 May 2017 14:09:39 +0200 Subject: [PATCH] Allow path to templates to be configured Signed-off-by: Knut Ahlers --- main.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index b60153f..37cd8cd 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "fmt" "io/ioutil" "os" + "path" "sort" "strings" "text/template" @@ -46,6 +47,7 @@ var ( CertTTL time.Duration `flag:"ttl" vardefault:"ttl" description:"Set the TTL for this certificate"` LogLevel string `flag:"log-level" vardefault:"log-level" description:"Log level to use (debug, info, warning, error)"` + TemplatePath string `flag:"template-path" vardefault:"template-path" description:"Path to read the client.conf / server.conf template from"` VersionAndExit bool `flag:"version" default:"false" description:"Prints current version and exits"` }{} @@ -55,6 +57,7 @@ var ( "auto-revoke": "true", "ttl": "8760h", "log-level": "info", + "template-path": ".", } version = "dev" @@ -281,7 +284,7 @@ func generateCertificateConfig(tplName, fqdn string) error { } func renderTemplate(tplName string, tplv *templateVars) error { - raw, err := ioutil.ReadFile(tplName) + raw, err := ioutil.ReadFile(path.Join(cfg.TemplatePath, tplName)) if err != nil { return err }