mirror of
https://github.com/Luzifer/ots.git
synced 2024-12-18 12:04:35 -05:00
9c81f9223f
Signed-off-by: Knut Ahlers <knut@ahlers.me>
25 lines
429 B
Go
25 lines
429 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
var errSecretNotFound = errors.New("Secret not found")
|
|
|
|
type storage interface {
|
|
Create(secret string) (string, error)
|
|
ReadAndDestroy(id string) (string, error)
|
|
}
|
|
|
|
func getStorageByType(t string) (storage, error) {
|
|
switch t {
|
|
case "mem":
|
|
return newStorageMem(), nil
|
|
case "redis":
|
|
return newStorageRedis()
|
|
default:
|
|
return nil, fmt.Errorf("Storage type %q not found", t)
|
|
}
|
|
}
|