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

Add AccountService.Me() method #205

Merged
merged 5 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions pkg/secrethub/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var (

// AccountService handles operations on SecretHub accounts.
type AccountService interface {
// Me retrieves the account of the client.
Marton6 marked this conversation as resolved.
Show resolved Hide resolved
Me() (*api.Account, error)
// Get retrieves an account by name.
Get(name string) (*api.Account, error)
// Keys returns an account key service.
Expand All @@ -30,6 +32,11 @@ type accountService struct {
client *Client
}

// Me retrieves the authenticated account of the client.
func (s accountService) Me() (*api.Account, error) {
return s.client.getMyAccount()
}

// Get retrieves an account by name.
func (s accountService) Get(name string) (*api.Account, error) {
accountName, err := api.NewAccountName(name)
Expand Down
6 changes: 6 additions & 0 deletions pkg/secrethub/fakeclient/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

// AccountService is a mock of the AccountService interface.
type AccountService struct {
MeFunc func() (*api.Account, error)
GetFunc func(name string) (*api.Account, error)
AccountKeyService secrethub.AccountKeyService
}
Expand All @@ -21,3 +22,8 @@ func (s *AccountService) Keys() secrethub.AccountKeyService {
func (s *AccountService) Get(name string) (*api.Account, error) {
return s.GetFunc(name)
}

// Me implements the AccountService interface Me function.
func (s *AccountService) Me() (*api.Account, error) {
return s.MeFunc()
}