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"
|
2023-08-15 07:47:34 +03:00
|
|
|
"go.unistack.org/micro/v4/options"
|
2020-12-10 01:42:28 +03:00
|
|
|
)
|
|
|
|
|
2022-02-16 14:59:35 +03:00
|
|
|
type httpClientKey struct{}
|
|
|
|
|
2023-08-15 07:47:34 +03:00
|
|
|
func HTTPClient(c *http.Client) options.Option {
|
|
|
|
return options.ContextOption(httpClientKey{}, c)
|
2022-02-16 14:59:35 +03:00
|
|
|
}
|
|
|
|
|
2020-12-10 01:42:28 +03:00
|
|
|
type configKey struct{}
|
|
|
|
|
2023-08-15 07:47:34 +03:00
|
|
|
func Config(cfg *api.Config) options.Option {
|
|
|
|
return options.ContextOption(configKey{}, cfg)
|
2020-12-10 01:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type tokenKey struct{}
|
|
|
|
|
2023-08-15 07:47:34 +03:00
|
|
|
func Token(token string) options.Option {
|
|
|
|
return options.ContextOption(tokenKey{}, token)
|
2020-12-10 01:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type addrKey struct{}
|
|
|
|
|
2023-08-15 07:47:34 +03:00
|
|
|
func Address(addr string) options.Option {
|
|
|
|
return options.ContextOption(addrKey{}, addr)
|
2020-12-10 01:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type pathKey struct{}
|
|
|
|
|
2023-08-15 07:47:34 +03:00
|
|
|
func Path(path string) options.Option {
|
|
|
|
return options.ContextOption(pathKey{}, path)
|
2021-11-18 16:19:34 +03:00
|
|
|
}
|
|
|
|
|
2020-12-10 01:42:28 +03:00
|
|
|
type roleIDKey struct{}
|
|
|
|
|
2023-08-15 07:47:34 +03:00
|
|
|
func RoleID(role string) options.Option {
|
|
|
|
return options.ContextOption(roleIDKey{}, role)
|
2020-12-10 01:42:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
type secretIDKey struct{}
|
|
|
|
|
2023-08-15 07:47:34 +03:00
|
|
|
func SecretID(secret string) options.Option {
|
|
|
|
return options.ContextOption(secretIDKey{}, secret)
|
2020-12-10 01:42:28 +03:00
|
|
|
}
|
2021-03-10 01:04:58 +03:00
|
|
|
|
|
|
|
type timeoutKey struct{}
|
|
|
|
|
2023-08-15 07:47:34 +03:00
|
|
|
func Timeout(td time.Duration) options.Option {
|
|
|
|
return options.ContextOption(timeoutKey{}, td)
|
2021-03-10 01:04:58 +03:00
|
|
|
}
|