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

Use api.IsErrNotFound instead of checking for errors directly #167

Merged
merged 3 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/secrethub/account_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (s accountKeyService) Create(verifier credentials.Verifier, encrypter crede
// Exists returns whether an account key exists for the client's credential.
func (s accountKeyService) Exists() (bool, error) {
_, err := s.client.getAccountKey()
if err == api.ErrAccountKeyNotFound || err == api.ErrCredentialNotKeyed {
SimonBarendse marked this conversation as resolved.
Show resolved Hide resolved
if api.IsErrNotFound(err) {
return false, nil
}
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/secrethub/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (s accessRuleService) Set(path string, permission string, accountName strin
_, err = s.Get(path, accountName)
if err != nil && err != api.ErrAccessRuleNotFound {
return nil, errio.Error(err)
} else if err == api.ErrAccessRuleNotFound {
} else if api.IsErrNotFound(err) {
return s.create(p, perm, an)
}
return s.update(p, perm, an)
Expand Down
2 changes: 1 addition & 1 deletion pkg/secrethub/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s dirService) Create(path string) (*api.Dir, error) {
// Exists returns whether a directory where you have access to exists at a given path.
func (s dirService) Exists(path string) (bool, error) {
_, err := s.GetTree(path, 0, false)
if err == api.ErrDirNotFound || err == api.ErrRepoNotFound {
if api.IsErrNotFound(err) {
return false, nil
} else if err != nil {
return false, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/secrethub/repo_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (s repoUserService) Invite(path string, username string) (*api.RepoMember,
}

account, err := s.client.httpClient.GetAccount(accountName)
if err == api.ErrAccountNotFound {
if api.IsErrNotFound(err) {
// return a more context specific error
return nil, api.ErrUserNotFound
} else if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/secrethub/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (s secretService) Exists(path string) (bool, error) {
}

_, err = s.client.httpClient.GetSecret(blindName)
if err == api.ErrSecretNotFound {
if api.IsErrNotFound(err) {
return false, nil
} else if err != nil {
return false, err
Expand Down