Skip to content

Commit 53e8fc9

Browse files
authored
chore: add support for nilerr (#4061)
1 parent 2de0b33 commit 53e8fc9

File tree

8 files changed

+10
-6
lines changed

8 files changed

+10
-6
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ linters:
4545
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true]
4646
- musttag # enforce field tags in (un)marshaled structs [fast: false, auto-fix: false]
4747
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
48+
- nilerr # Finds the code that returns nil even if it checks that the error is not nil. [fast: false, auto-fix: false]
4849
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
4950
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. [fast: true, auto-fix: false]
5051
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [fast: false, auto-fix: false]

internal/namespaces/config/commands.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ func configDestroyCommand() *core.Command {
541541
configPath := core.ExtractConfigPath(ctx)
542542
err := os.Remove(configPath)
543543
if err != nil {
544-
return err, nil
544+
return nil, err
545545
}
546546
return &core.SuccessResult{
547547
Message: "successfully destroy config",

internal/namespaces/instance/v1/custom_server_rdp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func instanceServerGetRdpPasswordRun(ctx context.Context, argsI interface{}) (i
153153
func parsePrivateKey(ctx context.Context, key []byte) (any, error) {
154154
privateKey, err := ssh.ParseRawPrivateKey(key)
155155
if err == nil {
156-
return privateKey, err
156+
return privateKey, nil
157157
}
158158
// Key may need a passphrase
159159
missingPassphraseError := &ssh.PassphraseMissingError{}

internal/namespaces/instance/v1/custom_ssh_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ Do you want the include statement to be added at the beginning of your file ?`,
139139
logger.Warningf("Failed to prompt, skipping include\n")
140140
return &core.SuccessResult{
141141
Message: configFileGeneratedMessage + " " + configFilePath,
142-
}, nil
142+
}, err
143143
}
144144

145145
if shouldIncludeConfig {

internal/namespaces/object/v1/s3configfile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (c s3config) getConfigFile(tool s3tool) (core.RawResult, error) {
156156
}
157157
res, err := json.Marshal(m)
158158
if err != nil {
159-
return nil, nil
159+
return nil, err
160160
}
161161
return append(res, '\n'), nil
162162
default:

internal/namespaces/rdb/v1/custom_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func instanceGetBuilder(c *core.Command) *core.Command {
342342
InstanceID: args.InstanceID,
343343
}, scw.WithAllPages())
344344
if err != nil {
345-
return res, nil
345+
return nil, err
346346
}
347347

348348
return struct {

internal/namespaces/registry/v1/custom_image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func imageGetBuilder(c *core.Command) *core.Command {
4646
NamespaceID: image.NamespaceID,
4747
})
4848
if err != nil {
49-
return getImageResp, nil
49+
return getImageResp, err
5050
}
5151

5252
res := customImage{

internal/namespaces/registry/v1/custom_tag.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/scaleway/scaleway-cli/v2/internal/core"
99
"github.com/scaleway/scaleway-cli/v2/internal/human"
1010
"github.com/scaleway/scaleway-sdk-go/api/registry/v1"
11+
"github.com/scaleway/scaleway-sdk-go/logger"
1112
)
1213

1314
//
@@ -44,13 +45,15 @@ func tagGetBuilder(c *core.Command) *core.Command {
4445
ImageID: tag.ImageID,
4546
})
4647
if err != nil {
48+
logger.Warningf("cannot get image %s %s", tag.ImageID, err)
4749
return getTagResp, nil
4850
}
4951

5052
namespace, err := api.GetNamespace(&registry.GetNamespaceRequest{
5153
NamespaceID: image.NamespaceID,
5254
})
5355
if err != nil {
56+
logger.Warningf("cannot get namespace %s %s", image.NamespaceID, err)
5457
return getTagResp, nil
5558
}
5659

0 commit comments

Comments
 (0)