mirror of
https://github.com/go-micro/go-micro.git
synced 2025-01-05 10:20:53 +02:00
43 lines
977 B
Go
43 lines
977 B
Go
package configmap
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go-micro.dev/v4/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)
|
|
}
|
|
}
|