dls: password support

This commit is contained in:
Mikaël Cluseau
2019-04-13 10:36:58 +01:00
parent 6a0cd6da02
commit 456722a616
5 changed files with 107 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import (
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
@ -135,6 +136,14 @@ func (ctx *renderContext) templateFuncs() map[string]interface{} {
}
return map[string]interface{}{
"password": func(cluster, name string) (password string, err error) {
password = secretData.Password(cluster, name)
if len(password) == 0 {
err = fmt.Errorf("password %q not defined for cluster %q", name, cluster)
}
return
},
"token": func(cluster, name string) (s string, err error) {
return secretData.Token(cluster, name)
},