Commit da547b4
upstream: fix: use errors.Is for sentinel error checks in usergroup controller (goharbor/harbor#23636)
Replace direct error equality comparisons (==) with errors.Is() in the
usergroup controller. This ensures correct behavior when sentinel errors
are wrapped, following Go best practices introduced in Go 1.13.
The errors package from Harbor's lib/errors already re-exports
errors.Is, so no additional imports are needed.
Changes:
- err == ldap.ErrNotFound -> errors.Is(err, ldap.ErrNotFound)
- err == ldap.ErrDNSyntax -> errors.Is(err, ldap.ErrDNSyntax)
- err != nil && err == usergroup.ErrDupUserGroup -> errors.Is(err, usergroup.ErrDupUserGroup)
Signed-off-by: Norway-02 <anshulkhetade02@gmail.com>
Co-authored-by: Wang Yan <wangyan_0219@hotmail.com>
(cherry picked from commit 2020f8d)
Upstream-Commit: 2020f8d
Upstream-PR: goharbor/harbor#23636
Upstream-Author: @Norway-02
Cherry-Pick-Status: clean
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit ef9e319)
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>1 parent 4421c03 commit da547b4
1 file changed
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
| 97 | + | |
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
0 commit comments