Skip to content

Commit 1f2ff80

Browse files
fix: linting
1 parent d855d9d commit 1f2ff80

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

github/resource_github_user_ssh_key.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package github
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"net/http"
78
"strconv"
@@ -82,7 +83,8 @@ func resourceGithubUserSshKeyRead(ctx context.Context, d *schema.ResourceData, m
8283
keyID := d.Get("key_id").(int64)
8384
_, _, err := client.Users.GetKey(ctx, keyID)
8485
if err != nil {
85-
if ghErr, ok := err.(*github.ErrorResponse); ok {
86+
var ghErr *github.ErrorResponse
87+
if errors.As(err, &ghErr) {
8688
if ghErr.Response.StatusCode == http.StatusNotModified {
8789
return nil
8890
}
@@ -114,12 +116,13 @@ func resourceGithubUserSshKeyImport(ctx context.Context, d *schema.ResourceData,
114116

115117
keyID, err := strconv.ParseInt(d.Id(), 10, 64)
116118
if err != nil {
117-
return nil, fmt.Errorf("invalid SSH key ID format: %v", err)
119+
return nil, fmt.Errorf("invalid SSH key ID format: %w", err)
118120
}
119121

120122
key, resp, err := client.Users.GetKey(ctx, keyID)
121123
if err != nil {
122-
if ghErr, ok := err.(*github.ErrorResponse); ok {
124+
var ghErr *github.ErrorResponse
125+
if errors.As(err, &ghErr) {
123126
if ghErr.Response.StatusCode == http.StatusNotFound {
124127
return nil, fmt.Errorf("SSH key with ID %d not found", keyID)
125128
}

github/resource_github_user_ssh_signing_key.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package github
22

33
import (
44
"context"
5+
"errors"
56
"fmt"
67
"net/http"
78
"strconv"
@@ -82,7 +83,8 @@ func resourceGithubUserSshSigningKeyRead(ctx context.Context, d *schema.Resource
8283
keyID := d.Get("key_id").(int64)
8384
_, _, err := client.Users.GetSSHSigningKey(ctx, keyID)
8485
if err != nil {
85-
if ghErr, ok := err.(*github.ErrorResponse); ok {
86+
var ghErr *github.ErrorResponse
87+
if errors.As(err, &ghErr) {
8688
if ghErr.Response.StatusCode == http.StatusNotModified {
8789
return nil
8890
}
@@ -114,12 +116,13 @@ func resourceGithubUserSshSigningKeyImport(ctx context.Context, d *schema.Resour
114116

115117
keyID, err := strconv.ParseInt(d.Id(), 10, 64)
116118
if err != nil {
117-
return nil, fmt.Errorf("invalid SSH signing key ID format: %v", err)
119+
return nil, fmt.Errorf("invalid SSH signing key ID format: %w", err)
118120
}
119121

120122
key, resp, err := client.Users.GetSSHSigningKey(ctx, keyID)
121123
if err != nil {
122-
if ghErr, ok := err.(*github.ErrorResponse); ok {
124+
var ghErr *github.ErrorResponse
125+
if errors.As(err, &ghErr) {
123126
if ghErr.Response.StatusCode == http.StatusNotFound {
124127
return nil, fmt.Errorf("SSH signing key with ID %d not found", keyID)
125128
}

0 commit comments

Comments
 (0)