Skip to content

Commit

Permalink
GitHub: don't fail if a user has no SSH keys. (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Attila Oláh authored Jul 3, 2024
1 parent c75261a commit 6eece93
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/github/sshkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ func ResolveSSHKeys(ctx context.Context, usernames []string) (map[string][]strin
return nil, fmt.Errorf("failed to fetch SSH keys for GitHub user %q: %w", username, err)
}

if len(keys) == 0 {
zerolog.Ctx(ctx).Warn().Str("username", username).Dur("took", time.Since(t)).Msg("No keys found")
continue
}

m[username] = keys

zerolog.Ctx(ctx).Info().Str("username", username).Dur("took", time.Since(t)).Msg("Resolved keys")
Expand All @@ -47,7 +52,7 @@ func fetchKeys(username string) ([]string, error) {
}

var keys []string
for _, line := range strings.Split(strings.TrimSpace(string(contents)), "\n") {
for _, line := range strings.FieldsFunc(strings.TrimSpace(string(contents)), func(r rune) bool { return r == '\n' }) {
keys = append(keys, strings.TrimSpace(line))
}

Expand Down

0 comments on commit 6eece93

Please sign in to comment.