accept non string values in secret map

main
Jörg Thalheim 2 years ago
parent 06495a406e
commit ed9c3d275b

@ -117,7 +117,7 @@ func (s *server) serveConnection(conn *net.UnixConn) {
} }
val, ok := secretMap[*secret] val, ok := secretMap[*secret]
if ok { if ok {
if _, err = io.WriteString(conn, val); err != nil { if _, err = io.WriteString(conn, fmt.Sprint(val)); err != nil {
log.Printf("Failed to send secret: %v", err) log.Printf("Failed to send secret: %v", err)
} }
} else { } else {

@ -6,12 +6,12 @@ import (
"os" "os"
) )
func parseServiceSecrets(path string) (map[string]string, error) { func parseServiceSecrets(path string) (map[string]interface{}, error) {
content, err := os.ReadFile(path) content, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, fmt.Errorf("Cannot read json file '%s': %w", path, err) return nil, fmt.Errorf("Cannot read json file '%s': %w", path, err)
} }
var data map[string]string var data map[string]interface{}
err = json.Unmarshal(content, &data) err = json.Unmarshal(content, &data)
if err != nil { if err != nil {
return nil, fmt.Errorf("Cannot parse '%s' as json file: %w", path, err) return nil, fmt.Errorf("Cannot parse '%s' as json file: %w", path, err)

@ -134,7 +134,7 @@ func (s *server) watch(inotifyFd int) {
log.Printf("Secret map % has no value for key %s", fname, conn.key) log.Printf("Secret map % has no value for key %s", fname, conn.key)
continue continue
} }
_, err = io.WriteString(conn.connection, val) _, err = io.WriteString(conn.connection, fmt.Sprint(val))
if err == nil { if err == nil {
log.Printf("Served %s to %s", fname, conn.connection.RemoteAddr().String()) log.Printf("Served %s to %s", fname, conn.connection.RemoteAddr().String())
} else { } else {

Loading…
Cancel
Save