local-server/cmd/dkl-local-server/ws-cluster-passwords.go

33 lines
825 B
Go
Raw Normal View History

2023-02-12 10:58:26 +00:00
package main
import (
restful "github.com/emicklei/go-restful"
)
2023-12-17 16:29:08 +00:00
var seeds = newClusterSecretKV[[]byte]("seeds")
2023-02-12 10:58:26 +00:00
var clusterPasswords = newClusterSecretKV[string]("passwords")
func wsClusterPasswords(req *restful.Request, resp *restful.Response) {
clusterName := req.PathParameter("cluster-name")
clusterPasswords.WsList(resp, clusterName+"/")
}
func wsClusterPassword(req *restful.Request, resp *restful.Response) {
clusterName := req.PathParameter("cluster-name")
name := req.PathParameter("password-name")
clusterPasswords.WsGet(resp, clusterName+"/"+name)
}
func wsClusterSetPassword(req *restful.Request, resp *restful.Response) {
cluster := wsReadCluster(req, resp)
if cluster == nil {
return
}
name := req.PathParameter("password-name")
clusterPasswords.WsPut(req, resp, cluster.Name+"/"+name)
}