1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-05-19 21:23:04 +02:00

43 lines
990 B
Go
Raw Normal View History

2020-12-26 15:32:45 +00:00
package configmap
import (
"context"
"github.com/micro/go-micro/v2/config/source"
)
type configPathKey struct{}
type prefixKey struct{}
type nameKey struct{}
type namespaceKey struct{}
// WithNamespace is an option to add namespace of configmap
func WithNamespace(s string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, namespaceKey{}, s)
}
}
// WithName is an option to add name of configmap
func WithName(s string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, nameKey{}, s)
}
}
// WithConfigPath option for setting a custom path to kubeconfig
func WithConfigPath(s string) source.Option {
return func(o *source.Options) {
if o.Context == nil {
o.Context = context.Background()
}
o.Context = context.WithValue(o.Context, configPathKey{}, s)
}
}