Ai
1 Star 0 Fork 0

SasukeBo/go-micro

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
options.go 1.48 KB
一键复制 编辑 原始数据 按行查看 历史
汪波 提交于 2023-02-23 10:27 +08:00 . fix: 替换包名
package vault
import (
"context"
"gitee.com/sasukebo/go-micro/v4/config/source"
)
type addressKey struct{}
type resourcePath struct{}
type nameSpace struct{}
type tokenKey struct{}
type secretName struct{}
// WithAddress sets the server address
func WithAddress(a string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, addressKey{}, a)
}
}
// WithResourcePath sets the resource that will be access
func WithResourcePath(p string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, resourcePath{}, p)
}
}
// WithNameSpace sets the namespace that its going to be access
func WithNameSpace(n string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, nameSpace{}, n)
}
}
// WithToken sets the key token to use
func WithToken(t string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, tokenKey{}, t)
}
}
// WithSecretName sets the name of the secret to wrap in on a map
func WithSecretName(t string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, secretName{}, t)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sasukebo/go-micro.git
git@gitee.com:sasukebo/go-micro.git
sasukebo
go-micro
go-micro
6e18eb58b836

搜索帮助