Skip to content

Commit

Permalink
refactor: Remove package name from github agent
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFantom committed Jan 23, 2023
1 parent a555046 commit 6fdd771
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/github/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ import (
"github.com/willfantom/sshare/keys"
)

// GitHubAgent holds a GitHub API client that has been given a user token.
type GitHubAgent struct {
// Agent holds a GitHub API client that has been given a user token.
type Agent struct {
client *gh.Client
}

// NewAgent creates a new SSH agent like entity, providing access to the
// authenticated user's public keys and titles of them.
func NewAgent(token string) *GitHubAgent {
func NewAgent(token string) *Agent {
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: token},
)
tc := oauth2.NewClient(ctx, ts)
return &GitHubAgent{
return &Agent{
client: gh.NewClient(tc),
}
}

// GetKeys returns the SSH keys of the authenticated GitHub user as
// authorized_key style items. If this failed for any reason, such as not being
// able to contact GitHub or the token not being valid, an error is returned.
func (gha *GitHubAgent) GetKeys() ([]*keys.Key, error) {
func (gha *Agent) GetKeys() ([]*keys.Key, error) {
ghKeys, _, err := gha.client.Users.ListKeys(context.Background(), "", &gh.ListOptions{})
if err != nil {
return nil, fmt.Errorf("failed to obtain users ssh keys from github: %w", err)
Expand Down

0 comments on commit 6fdd771

Please sign in to comment.