From f2ed3a3777c47450ca6ae994cabaa1f359e06ea1 Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" Date: Wed, 13 Feb 2019 09:16:30 -0600 Subject: [PATCH] clarify the ACL.PolicyDelete endpoint (#5337) There was an errant early-return in PolicyDelete() that bypassed the rest of the function. This was ok because the only caller of this function ignores the results. This removes the early-return making it structurally behave like TokenDelete() and for both PolicyDelete and TokenDelete clarify the lone callers to indicate that the return values are ignored. We may wish to avoid the entire return value as well, but this patch doesn't go that far. --- agent/acl_endpoint.go | 8 ++++---- agent/consul/acl_endpoint.go | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/agent/acl_endpoint.go b/agent/acl_endpoint.go index b4be17ce7f..64eaad0de8 100644 --- a/agent/acl_endpoint.go +++ b/agent/acl_endpoint.go @@ -328,8 +328,8 @@ func (s *HTTPServer) ACLPolicyDelete(resp http.ResponseWriter, req *http.Request } s.parseToken(req, &args.Token) - var out string - if err := s.agent.RPC("ACL.PolicyDelete", args, &out); err != nil { + var ignored string + if err := s.agent.RPC("ACL.PolicyDelete", args, &ignored); err != nil { return nil, err } @@ -497,8 +497,8 @@ func (s *HTTPServer) ACLTokenDelete(resp http.ResponseWriter, req *http.Request, } s.parseToken(req, &args.Token) - var out string - if err := s.agent.RPC("ACL.TokenDelete", args, &out); err != nil { + var ignored string + if err := s.agent.RPC("ACL.TokenDelete", args, &ignored); err != nil { return nil, err } return true, nil diff --git a/agent/consul/acl_endpoint.go b/agent/consul/acl_endpoint.go index 9d1e9e160d..138ff845ee 100644 --- a/agent/consul/acl_endpoint.go +++ b/agent/consul/acl_endpoint.go @@ -811,10 +811,6 @@ func (a *ACL) PolicyDelete(args *structs.ACLPolicyDeleteRequest, reply *string) a.srv.acls.cache.RemovePolicy(policy.ID) - if resp == nil { - return nil - } - if respErr, ok := resp.(error); ok { return respErr }