allow to override Struct on Save
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
678b0ff069
commit
4030b1d131
@ -157,13 +157,18 @@ func (c *consulConfig) Save(ctx context.Context, opts ...config.SaveOption) erro
|
|||||||
|
|
||||||
path := c.path
|
path := c.path
|
||||||
|
|
||||||
|
dst := c.opts.Struct
|
||||||
|
if options.Struct != nil {
|
||||||
|
dst = options.Struct
|
||||||
|
}
|
||||||
|
|
||||||
if options.Context != nil {
|
if options.Context != nil {
|
||||||
if v, ok := options.Context.Value(pathKey{}).(string); ok && v != "" {
|
if v, ok := options.Context.Value(pathKey{}).(string); ok && v != "" {
|
||||||
path = v
|
path = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, err := c.opts.Codec.Marshal(c.opts.Struct)
|
buf, err := c.opts.Codec.Marshal(dst)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
_, err = c.cli.KV().Put(&api.KVPair{Key: path, Value: buf}, nil)
|
_, err = c.cli.KV().Put(&api.KVPair{Key: path, Value: buf}, nil)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user