diff --git a/agent/consul/acl.go b/agent/consul/acl.go index 9161fd78e1..49b18d47c7 100644 --- a/agent/consul/acl.go +++ b/agent/consul/acl.go @@ -2143,7 +2143,7 @@ func vetNodeTxnOp(op *structs.TxnNodeOp, rule acl.Authorizer) error { var authzContext acl.AuthorizerContext op.FillAuthzContext(&authzContext) - if rule != nil && rule.NodeWrite(op.Node.Node, &authzContext) != acl.Allow { + if rule.NodeWrite(op.Node.Node, &authzContext) != acl.Allow { return acl.ErrPermissionDenied } diff --git a/agent/consul/acl_endpoint.go b/agent/consul/acl_endpoint.go index 11d29a8845..ccc9e1b2af 100644 --- a/agent/consul/acl_endpoint.go +++ b/agent/consul/acl_endpoint.go @@ -1225,9 +1225,7 @@ func (a *ACL) PolicyDelete(args *structs.ACLPolicyDeleteRequest, reply *string) return respErr } - if policy != nil { - *reply = policy.Name - } + *reply = policy.Name return nil } @@ -1692,9 +1690,7 @@ func (a *ACL) RoleDelete(args *structs.ACLRoleDeleteRequest, reply *string) erro return respErr } - if role != nil { - *reply = role.Name - } + *reply = role.Name return nil } @@ -2525,9 +2521,7 @@ func (a *ACL) Logout(args *structs.ACLLogoutRequest, reply *bool) error { } // Purge the identity from the cache to prevent using the previous definition of the identity - if token != nil { - a.srv.acls.cache.RemoveIdentity(tokenSecretCacheID(token.SecretID)) - } + a.srv.acls.cache.RemoveIdentity(tokenSecretCacheID(token.SecretID)) if respErr, ok := resp.(error); ok { return respErr diff --git a/agent/consul/acl_replication_types.go b/agent/consul/acl_replication_types.go index a238244cf5..c1e29d818a 100644 --- a/agent/consul/acl_replication_types.go +++ b/agent/consul/acl_replication_types.go @@ -229,7 +229,8 @@ func (r *aclPolicyReplicator) UpdateLocalBatch(ctx context.Context, srv *Server, if err != nil { return err } - if respErr, ok := resp.(error); ok && err != nil { + + if respErr, ok := resp.(error); ok { return respErr } @@ -336,9 +337,11 @@ func (r *aclRoleReplicator) DeleteLocalBatch(srv *Server, batch []string) error if err != nil { return err } - if respErr, ok := resp.(error); ok && err != nil { + + if respErr, ok := resp.(error); ok { return respErr } + return nil } @@ -364,7 +367,8 @@ func (r *aclRoleReplicator) UpdateLocalBatch(ctx context.Context, srv *Server, s if err != nil { return err } - if respErr, ok := resp.(error); ok && err != nil { + + if respErr, ok := resp.(error); ok { return respErr } diff --git a/agent/consul/config_replication.go b/agent/consul/config_replication.go index 691bcc4309..3562859b10 100644 --- a/agent/consul/config_replication.go +++ b/agent/consul/config_replication.go @@ -79,7 +79,8 @@ func (s *Server) reconcileLocalConfig(ctx context.Context, configs []structs.Con if err != nil { return false, fmt.Errorf("Failed to apply config %s: %v", op, err) } - if respErr, ok := resp.(error); ok && err != nil { + + if respErr, ok := resp.(error); ok { return false, fmt.Errorf("Failed to apply config %s: %v", op, respErr) } diff --git a/agent/consul/federation_state_replication.go b/agent/consul/federation_state_replication.go index ac6bc640ec..52af2f5dca 100644 --- a/agent/consul/federation_state_replication.go +++ b/agent/consul/federation_state_replication.go @@ -158,7 +158,8 @@ func (r *FederationStateReplicator) PerformDeletions(ctx context.Context, deleti if err != nil { return false, err } - if respErr, ok := resp.(error); ok && err != nil { + + if respErr, ok := resp.(error); ok { return false, respErr } @@ -202,7 +203,8 @@ func (r *FederationStateReplicator) PerformUpdates(ctx context.Context, updatesR if err != nil { return false, err } - if respErr, ok := resp.(error); ok && err != nil { + + if respErr, ok := resp.(error); ok { return false, respErr } diff --git a/agent/consul/leader_federation_state_ae.go b/agent/consul/leader_federation_state_ae.go index 4254e61a35..4e5a8a45b2 100644 --- a/agent/consul/leader_federation_state_ae.go +++ b/agent/consul/leader_federation_state_ae.go @@ -219,7 +219,7 @@ func (s *Server) pruneStaleFederationStates() error { if err != nil { return fmt.Errorf("Failed to delete federation state %s: %v", dc, err) } - if respErr, ok := resp.(error); ok && err != nil { + if respErr, ok := resp.(error); ok { return fmt.Errorf("Failed to delete federation state %s: %v", dc, respErr) } }