Skip to content

Commit

Permalink
Use GetByPrefix to find nodes when approving/rejecting them (#3681)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rossjones authored Mar 23, 2024
1 parent 11181d3 commit 2768d7f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/node/manager/node_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit 2768d7f

Please sign in to comment.