22 lines
509 B
Go
22 lines
509 B
Go
package sshkey
|
|
|
|
import "context"
|
|
|
|
type PublicKeyResolver struct {
|
|
repository Repository
|
|
}
|
|
|
|
func NewPublicKeyResolver(repository Repository) PublicKeyResolver {
|
|
return PublicKeyResolver{repository: repository}
|
|
}
|
|
|
|
func (r PublicKeyResolver) GetPublicKey(ctx context.Context, profileID string, keyID string) (string, bool, error) {
|
|
key, found, err := r.repository.Get(ctx, profileID, keyID)
|
|
if err != nil {
|
|
return "", false, err
|
|
}
|
|
if !found {
|
|
return "", false, nil
|
|
}
|
|
return key.PublicKey, true, nil
|
|
} |