Skip to content

fix: use errors.Is for all EOF comparisons#26012

Merged
nklaassen merged 1 commit intomasterfrom
nklaassen/errors-is-EOF
May 10, 2023
Merged

fix: use errors.Is for all EOF comparisons#26012
nklaassen merged 1 commit intomasterfrom
nklaassen/errors-is-EOF

Conversation

@nklaassen
Copy link
Copy Markdown
Contributor

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) }

I will backport manually by re-running eg

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 kubernetes-access size/sm tctl tctl - Teleport admin tool labels May 10, 2023
@nklaassen nklaassen requested review from rosstimothy and zmb3 May 10, 2023 18:37
@nklaassen
Copy link
Copy Markdown
Contributor Author

@zmb3 @rosstimothy I think this is probably the best quick fix for #25996. I can add test coverage for GetAccessRequests separately

@nklaassen nklaassen added this pull request to the merge queue May 10, 2023
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 10, 2023
nklaassen added a commit that referenced this pull request May 10, 2023
Backport #26012 to branch/v12

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) }
```
nklaassen added a commit that referenced this pull request May 10, 2023
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) }
```
nklaassen added a commit that referenced this pull request May 10, 2023
Backport #26012 to branch/v11

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) }
```
@nklaassen nklaassen added this pull request to the merge queue May 10, 2023
Merged via the queue into master with commit 2568bff May 10, 2023
@nklaassen nklaassen deleted the nklaassen/errors-is-EOF branch May 10, 2023 19:50
nklaassen added a commit that referenced this pull request May 10, 2023
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) }
```
nklaassen added a commit that referenced this pull request May 10, 2023
Backport #26012 to branch/v11

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) }
```
nklaassen added a commit that referenced this pull request May 10, 2023
Backport #26012 to branch/v12

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) }
```
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 kubernetes-access size/sm tctl tctl - Teleport admin tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants