2020-12-10 01:42:28 +03:00
|
|
|
package vault
|
|
|
|
|
|
|
|
import (
|
2022-02-16 14:59:35 +03:00
|
|
|
"net/http"
|
2021-03-10 01:04:58 +03:00
|
|
|
"time"
|
|
|
|
|
2020-12-10 01:42:28 +03:00
|
|
|
"github.com/hashicorp/vault/api"
|
2021-10-26 23:35:26 +03:00
|
|
|
"go.unistack.org/micro/v3/config"
|
2020-12-10 01:42:28 +03:00
|
|
|
)
|
|
|
|
|
2022-02-16 14:59:35 +03:00
|
|
|
type httpClientKey struct{}
|
|
|
|
|
|
|
|
func HTTPClient(c *http.Client) config.Option {
|
|
|
|
return config.SetOption(httpClientKey{}, c)
|
|
|
|
}
|
|
|
|
|
2020-12-10 01:42:28 +03:00
|
|
|
type configKey struct{}
|
|
|
|
|
|
|
|
func Config(cfg *api.Config) config.Option {
|
|
|
|
return config.SetOption(configKey{}, cfg)
|
|
|
|
}
|
|
|
|
|
|
|
|
type tokenKey struct{}
|
|
|
|
|
|
|
|
func Token(token string) config.Option {
|
|
|
|
return config.SetOption(tokenKey{}, token)
|
|
|
|
}
|
|
|
|
|
|
|
|
type addrKey struct{}
|
|
|
|
|
|
|
|
func Address(addr string) config.Option {
|
|
|
|
return config.SetOption(addrKey{}, addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
type pathKey struct{}
|
|
|
|
|
|
|
|
func Path(path string) config.Option {
|
|
|
|
return config.SetOption(pathKey{}, path)
|
|
|
|
}
|
|
|
|
|
2021-11-18 16:19:34 +03:00
|
|
|
func LoadPath(path string) config.LoadOption {
|
|
|
|
return config.SetLoadOption(pathKey{}, path)
|
|
|
|
}
|
|
|
|
|
|
|
|
func SavePath(path string) config.SaveOption {
|
|
|
|
return config.SetSaveOption(pathKey{}, path)
|
|
|
|
}
|
|
|
|
|
|
|
|
func WatchPath(path string) config.WatchOption {
|
|
|
|
return config.SetWatchOption(pathKey{}, path)
|
|
|
|
}
|
|
|
|
|
2020-12-10 01:42:28 +03:00
|
|
|
type roleIDKey struct{}
|
|
|
|
|
|
|
|
func RoleID(role string) config.Option {
|
|
|
|
return config.SetOption(roleIDKey{}, role)
|
|
|
|
}
|
|
|
|
|
|
|
|
type secretIDKey struct{}
|
|
|
|
|
|
|
|
func SecretID(secret string) config.Option {
|
|
|
|
return config.SetOption(secretIDKey{}, secret)
|
|
|
|
}
|
2021-03-10 01:04:58 +03:00
|
|
|
|
|
|
|
type timeoutKey struct{}
|
|
|
|
|
|
|
|
func Timeout(td time.Duration) config.Option {
|
|
|
|
return config.SetOption(timeoutKey{}, td)
|
|
|
|
}
|