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

Commit 6dda104

Browse files
authored
Merge pull request #252 from secrethub/feature/update-is-err-not-found
Use api.IsErrNotFound
2 parents 1d29286 + b156174 commit 6dda104

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 {
@@ -82,18 +82,8 @@ func newIgnoreMissingSecretReader(sr tpl.SecretReader) *ignoreMissingSecretReade
8282
// errors for non-existing secrets. Instead, it returns the empty string.
8383
func (sr *ignoreMissingSecretReader) ReadSecret(path string) (string, error) {
8484
secret, err := sr.secretReader.ReadSecret(path)
85-
if isErrNotFound(err) {
85+
if api.IsErrNotFound(err) {
8686
return "", nil
8787
}
8888
return secret, err
8989
}
90-
91-
// isErrNotFound returns whether the given error is caused by a un-existing resource.
92-
// TODO: Replace this function with github.com/secrethub/secrethub-go/blob/develop/internals/api.IsErrNotFound once that is released.
93-
func isErrNotFound(err error) bool {
94-
statusError, ok := err.(errio.PublicStatusError)
95-
if !ok {
96-
return false
97-
}
98-
return statusError.StatusCode == 404
99-
}

0 commit comments

Comments
 (0)