goldwarden/ipc/messages/sshkeys.go
Bernd Schoolmann 21b1f0b219
Refactor ipc
2023-09-20 03:05:44 +02:00

57 lines
1.2 KiB
Go

package messages
import "encoding/json"
type CreateSSHKeyRequest struct {
Name string
}
type CreateSSHKeyResponse struct {
Digest string
}
type GetSSHKeysRequest struct {
}
type GetSSHKeysResponse struct {
Keys []string
}
func init() {
registerPayloadParser(func(payload []byte) (interface{}, error) {
var req CreateSSHKeyRequest
err := json.Unmarshal(payload, &req)
if err != nil {
panic("Unmarshal: " + err.Error())
}
return req, nil
}, CreateSSHKeyRequest{})
registerPayloadParser(func(payload []byte) (interface{}, error) {
var req CreateSSHKeyResponse
err := json.Unmarshal(payload, &req)
if err != nil {
panic("Unmarshal: " + err.Error())
}
return req, nil
}, CreateSSHKeyResponse{})
registerPayloadParser(func(payload []byte) (interface{}, error) {
var req GetSSHKeysRequest
err := json.Unmarshal(payload, &req)
if err != nil {
panic("Unmarshal: " + err.Error())
}
return req, nil
}, GetSSHKeysRequest{})
registerPayloadParser(func(payload []byte) (interface{}, error) {
var req GetSSHKeysResponse
err := json.Unmarshal(payload, &req)
if err != nil {
panic("Unmarshal: " + err.Error())
}
return req, nil
}, GetSSHKeysResponse{})
}