mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-24 07:10:20 +00:00
e72ed593be
Signed-off-by: Rakshith R <rar@redhat.com>
48 lines
962 B
Go
48 lines
962 B
Go
package kmip
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// 4.26
|
|
|
|
type DiscoverVersionsRequestPayload struct {
|
|
ProtocolVersion []ProtocolVersion
|
|
}
|
|
|
|
type DiscoverVersionsResponsePayload struct {
|
|
ProtocolVersion []ProtocolVersion
|
|
}
|
|
|
|
type DiscoverVersionsHandler struct {
|
|
SupportedVersions []ProtocolVersion
|
|
}
|
|
|
|
func (h *DiscoverVersionsHandler) HandleItem(ctx context.Context, req *Request) (item *ResponseBatchItem, err error) {
|
|
var payload DiscoverVersionsRequestPayload
|
|
|
|
err = req.DecodePayload(&payload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
var respPayload DiscoverVersionsResponsePayload
|
|
|
|
if len(payload.ProtocolVersion) == 0 {
|
|
respPayload.ProtocolVersion = h.SupportedVersions
|
|
} else {
|
|
for _, v := range h.SupportedVersions {
|
|
for _, cv := range payload.ProtocolVersion {
|
|
if cv == v {
|
|
respPayload.ProtocolVersion = append(respPayload.ProtocolVersion, v)
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return &ResponseBatchItem{
|
|
ResponsePayload: respPayload,
|
|
}, nil
|
|
}
|