Skip to content

Commit

Permalink
feat(frontend): check endpoint correspondence for trtype
Browse files Browse the repository at this point in the history
Signed-off-by: Artsiom Koltun <[email protected]>
  • Loading branch information
artek-koltun authored and glimchb committed Oct 2, 2023
1 parent 995c5d0 commit 189e64d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/frontend/nvme_controller_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
package frontend

import (
"errors"
"fmt"

"go.einride.tech/aip/fieldbehavior"
"go.einride.tech/aip/resourceid"
"go.einride.tech/aip/resourcename"
Expand All @@ -23,6 +26,22 @@ func (s *Server) validateCreateNvmeControllerRequest(in *pb.CreateNvmeController
return err
}
}

switch in.NvmeController.Spec.Trtype {
case pb.NvmeTransportType_NVME_TRANSPORT_PCIE:
if _, ok := in.NvmeController.Spec.Endpoint.(*pb.NvmeControllerSpec_PcieId); !ok {
return errors.New("invalid endpoint type passed for transport")
}
case pb.NvmeTransportType_NVME_TRANSPORT_TCP:
fallthrough
case pb.NvmeTransportType_NVME_TRANSPORT_RDMA:
if _, ok := in.NvmeController.Spec.Endpoint.(*pb.NvmeControllerSpec_FabricsId); !ok {
return errors.New("invalid endpoint type passed for transport")
}
default:
return fmt.Errorf("not supported transport type: %v", in.NvmeController.Spec.Trtype)
}

// Validate that a resource name conforms to the restrictions outlined in AIP-122.
return resourcename.Validate(in.Parent)
}
Expand Down

0 comments on commit 189e64d

Please sign in to comment.