aboutsummaryrefslogtreecommitdiff
path: root/template.go
diff options
context:
space:
mode:
Diffstat (limited to 'template.go')
-rw-r--r--template.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/template.go b/template.go
index cb815a3..31d4358 100644
--- a/template.go
+++ b/template.go
@@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"path/filepath"
+ "runtime"
"strings"
"text/template"
@@ -12,6 +13,8 @@ import (
)
type TemplateData struct {
+ OS string
+ Arch string
Hostname string
Vars map[string]interface{}
}
@@ -37,13 +40,21 @@ func lookupPassword(name string) (string, error) {
}
func getTemplateData() (*TemplateData, error) {
- var data TemplateData
vars, err := readVars()
if err != nil {
return nil, err
}
- data.Vars = vars
- return &data, nil
+ data := &TemplateData{
+ OS: runtime.GOOS,
+ Arch: runtime.GOARCH,
+ Vars: vars,
+ }
+ if host, err := os.Hostname(); err != nil {
+ return nil, err
+ } else {
+ data.Hostname = host
+ }
+ return data, nil
}
func readVars() (map[string]interface{}, error) {