Skip to content
This repository was archived by the owner on Feb 16, 2023. It is now read-only.

Commit ddb13bf

Browse files
committed
Update CLI to use api.IsErrNotFound when checking for not found errors
1 parent d4a1f86 commit ddb13bf

2 files changed

Lines changed: 3 additions & 13 deletions

File tree

internals/secrethub/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (cmd *LsCommand) Run() error {
8585
dirFS, err := client.Dirs().GetTree(dirPath.Value(), 1, false)
8686
if api.IsErrNotFound(err) && dirPath.IsRepoPath() {
8787
return err
88-
} else if err != nil && !isErrNotFound(err) {
88+
} else if err != nil && !api.IsErrNotFound(err) {
8989
return err
9090
} else if err == nil {
9191
err = printDir(cmd.io.Stdout(), cmd.quiet, dirFS.RootDir, timeFormatter)

internals/secrethub/secret_reader.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package secrethub
22

33
import (
44
"github.com/secrethub/secrethub-cli/internals/secrethub/tpl"
5-
"github.com/secrethub/secrethub-go/internals/errio"
5+
"github.com/secrethub/secrethub-go/internals/api"
66
)
77

88
type secretReader struct {
@@ -76,18 +76,8 @@ func newIgnoreMissingSecretReader(sr tpl.SecretReader) *ignoreMissingSecretReade
7676
// errors for non-existing secrets. Instead, it returns the empty string.
7777
func (sr *ignoreMissingSecretReader) ReadSecret(path string) (string, error) {
7878
secret, err := sr.secretReader.ReadSecret(path)
79-
if isErrNotFound(err) {
79+
if api.IsErrNotFound(err) {
8080
return "", nil
8181
}
8282
return secret, err
8383
}
84-
85-
// isErrNotFound returns whether the given error is caused by a un-existing resource.
86-
// TODO: Replace this function with github.com/secrethub/secrethub-go/blob/develop/internals/api.IsErrNotFound once that is released.
87-
func isErrNotFound(err error) bool {
88-
statusError, ok := err.(errio.PublicStatusError)
89-
if !ok {
90-
return false
91-
}
92-
return statusError.StatusCode == 404
93-
}

0 commit comments

Comments
 (0)