Skip to content

[v13] fix: use errors.Is for all EOF comparisons#26017

Merged
nklaassen merged 1 commit intobranch/v13from
nklaassen/v13/errors-is-EOF
May 10, 2023
Merged

[v13] fix: use errors.Is for all EOF comparisons#26017
nklaassen merged 1 commit intobranch/v13from
nklaassen/v13/errors-is-EOF

Conversation

@nklaassen
Copy link
Copy Markdown
Contributor

Backport #26012 to branch/v13

This commit updates all err == io.EOF comparisons to use errors.Is(err, io.EOF). This is necessary when the error may have been wrapped and fixes at least one current breakage (in tsh request ls).

golang.org/x/tools/refactor/eg was very handy for this, I used the following template:

package teleport
import (
	"errors"
	"io"
)
func before(err error) bool { return err == io.EOF }
func after(err error) bool  { return errors.Is(err, io.EOF) }

Backport #26012 to branch/v13

This commit updates all `err == io.EOF` comparisons to use
`errors.Is(err, io.EOF)`. This is necessary when the error may have been
wrapped and fixes at least one current breakage (in `tsh request ls`).

`golang.org/x/tools/refactor/eg` was very handy for this, I used the
following template:

```go
package teleport
import (
	"errors"
	"io"
)
func before(err error) bool { return err == io.EOF }
func after(err error) bool  { return errors.Is(err, io.EOF) }
```
@github-actions github-actions Bot added audit-log Issues related to Teleports Audit Log backport kubernetes-access size/sm tctl tctl - Teleport admin tool labels May 10, 2023
@nklaassen nklaassen requested review from rosstimothy and zmb3 May 10, 2023 19:26
@nklaassen nklaassen enabled auto-merge May 10, 2023 19:47
@nklaassen nklaassen added this pull request to the merge queue May 10, 2023
Merged via the queue into branch/v13 with commit 08a0486 May 10, 2023
@nklaassen nklaassen deleted the nklaassen/v13/errors-is-EOF branch May 10, 2023 20:12
@r0mant r0mant mentioned this pull request Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit-log Issues related to Teleports Audit Log backport kubernetes-access size/sm tctl tctl - Teleport admin tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants