33 lines
692 B
Go
33 lines
692 B
Go
package secretstore
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
const DefaultAccountKey = "default"
|
|
|
|
type Credential struct {
|
|
Host string `json:"host"`
|
|
Username string `json:"username"`
|
|
Password string `json:"password"`
|
|
}
|
|
|
|
func (c Credential) Validate() error {
|
|
if strings.TrimSpace(c.Host) == "" {
|
|
return fmt.Errorf("imap host is required")
|
|
}
|
|
if strings.TrimSpace(c.Username) == "" {
|
|
return fmt.Errorf("username is required")
|
|
}
|
|
if strings.TrimSpace(c.Password) == "" {
|
|
return fmt.Errorf("password is required")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type Store interface {
|
|
Save(ctx context.Context, key string, cred Credential) error
|
|
Load(ctx context.Context, key string) (Credential, error)
|
|
}
|