Skip to content

Commit

Permalink
chore: add support for nilerr (#4061)
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone authored Aug 22, 2024
1 parent 2de0b33 commit 53e8fc9
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ linters:
- misspell # Finds commonly misspelled English words in comments [fast: true, auto-fix: true]
- musttag # enforce field tags in (un)marshaled structs [fast: false, auto-fix: false]
- nakedret # Finds naked returns in functions greater than a specified function length [fast: true, auto-fix: false]
- nilerr # Finds the code that returns nil even if it checks that the error is not nil. [fast: false, auto-fix: false]
- nolintlint # Reports ill-formed or insufficient nolint directives [fast: true, auto-fix: false]
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL. [fast: true, auto-fix: false]
- perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. [fast: false, auto-fix: false]
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/config/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ func configDestroyCommand() *core.Command {
configPath := core.ExtractConfigPath(ctx)
err := os.Remove(configPath)
if err != nil {
return err, nil
return nil, err
}
return &core.SuccessResult{
Message: "successfully destroy config",
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/instance/v1/custom_server_rdp.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func instanceServerGetRdpPasswordRun(ctx context.Context, argsI interface{}) (i
func parsePrivateKey(ctx context.Context, key []byte) (any, error) {
privateKey, err := ssh.ParseRawPrivateKey(key)
if err == nil {
return privateKey, err
return privateKey, nil
}
// Key may need a passphrase
missingPassphraseError := &ssh.PassphraseMissingError{}
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/instance/v1/custom_ssh_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Do you want the include statement to be added at the beginning of your file ?`,
logger.Warningf("Failed to prompt, skipping include\n")
return &core.SuccessResult{
Message: configFileGeneratedMessage + " " + configFilePath,
}, nil
}, err
}

if shouldIncludeConfig {
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/object/v1/s3configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (c s3config) getConfigFile(tool s3tool) (core.RawResult, error) {
}
res, err := json.Marshal(m)
if err != nil {
return nil, nil
return nil, err
}
return append(res, '\n'), nil
default:
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/rdb/v1/custom_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func instanceGetBuilder(c *core.Command) *core.Command {
InstanceID: args.InstanceID,
}, scw.WithAllPages())
if err != nil {
return res, nil
return nil, err
}

return struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/namespaces/registry/v1/custom_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func imageGetBuilder(c *core.Command) *core.Command {
NamespaceID: image.NamespaceID,
})
if err != nil {
return getImageResp, nil
return getImageResp, err
}

res := customImage{
Expand Down
3 changes: 3 additions & 0 deletions internal/namespaces/registry/v1/custom_tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/scaleway/scaleway-cli/v2/internal/core"
"github.com/scaleway/scaleway-cli/v2/internal/human"
"github.com/scaleway/scaleway-sdk-go/api/registry/v1"
"github.com/scaleway/scaleway-sdk-go/logger"
)

//
Expand Down Expand Up @@ -44,13 +45,15 @@ func tagGetBuilder(c *core.Command) *core.Command {
ImageID: tag.ImageID,
})
if err != nil {
logger.Warningf("cannot get image %s %s", tag.ImageID, err)
return getTagResp, nil
}

namespace, err := api.GetNamespace(&registry.GetNamespaceRequest{
NamespaceID: image.NamespaceID,
})
if err != nil {
logger.Warningf("cannot get namespace %s %s", image.NamespaceID, err)
return getTagResp, nil
}

Expand Down

0 comments on commit 53e8fc9

Please sign in to comment.