From f7aec5a550e5d08bc0914d1990c7cfbb3d401013 Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Fri, 22 Mar 2024 08:09:23 +0000 Subject: [PATCH] Use GetByPrefix to find nodes when approving/rejecting them Rather than requiring an exact node id, we can accept a shortened version of it and use getbyprefix. This will complain appropriately if there is more than one node returned by the prefix. --- pkg/node/manager/node_manager.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/node/manager/node_manager.go b/pkg/node/manager/node_manager.go index 59d032afec..3d87f17a12 100644 --- a/pkg/node/manager/node_manager.go +++ b/pkg/node/manager/node_manager.go @@ -190,9 +190,9 @@ func (n *NodeManager) Delete(ctx context.Context, nodeID string) error { // reason for the approval (for audit). The return values denote success and any // failure of the operation as a human readable string. func (n *NodeManager) Approve(ctx context.Context, nodeID string, reason string) (bool, string) { - info, err := n.nodeInfo.Get(ctx, nodeID) + info, err := n.nodeInfo.GetByPrefix(ctx, nodeID) if err != nil { - return false, "node not found" + return false, err.Error() } if info.Approval == models.NodeApprovals.APPROVED { @@ -213,9 +213,9 @@ func (n *NodeManager) Approve(ctx context.Context, nodeID string, reason string) // reason for the rejection (for audit). The return values denote success and any // failure of the operation as a human readable string. func (n *NodeManager) Reject(ctx context.Context, nodeID string, reason string) (bool, string) { - info, err := n.nodeInfo.Get(ctx, nodeID) + info, err := n.nodeInfo.GetByPrefix(ctx, nodeID) if err != nil { - return false, "node not found" + return false, err.Error() } if info.Approval == models.NodeApprovals.REJECTED {