fix(config/consul):Config from consul skip empty key (#1830)

* feat(config/consul):skip empty key

* feat(config/consul):delete empty blank
pull/1831/head
Casper-Mars 3 years ago committed by GitHub
parent 6ec695064b
commit c1e98e41de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      contrib/config/consul/config.go

@ -18,7 +18,7 @@ type options struct {
path string
}
// WithContext with registry context.
// WithContext with registry context.
func WithContext(ctx context.Context) Option {
return Option(func(o *options) {
o.ctx = ctx
@ -71,6 +71,9 @@ func (s *source) Load() ([]*config.KeyValue, error) {
kvs := make([]*config.KeyValue, 0)
for _, item := range kv {
k := strings.TrimPrefix(item.Key, pathPrefix)
if k == "" {
continue
}
kvs = append(kvs, &config.KeyValue{
Key: k,
Value: item.Value,

Loading…
Cancel
Save