mirror of https://github.com/status-im/consul.git
Hoists KV processing helper functions up as static functions.
This commit is contained in:
parent
17cd0ac4ec
commit
8a7428e508
|
@ -10,11 +10,8 @@ import (
|
||||||
"github.com/hashicorp/consul/consul/structs"
|
"github.com/hashicorp/consul/consul/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
// fixupKVOps takes the raw decoded JSON and base64 decodes values in KV ops,
|
// decodeValue decodes the value member of the given operation.
|
||||||
// replacing them with byte arrays.
|
func decodeValue(rawKV interface{}) error {
|
||||||
func fixupKVOps(raw interface{}) error {
|
|
||||||
// decodeValue decodes the value member of the given operation.
|
|
||||||
decodeValue := func(rawKV interface{}) error {
|
|
||||||
rawMap, ok := rawKV.(map[string]interface{})
|
rawMap, ok := rawKV.(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unexpected raw KV type: %T", rawKV)
|
return fmt.Errorf("unexpected raw KV type: %T", rawKV)
|
||||||
|
@ -42,11 +39,11 @@ func fixupKVOps(raw interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixupKVOp looks for non-nil KV operations and passes them on for
|
// fixupKVOp looks for non-nil KV operations and passes them on for
|
||||||
// value conversion.
|
// value conversion.
|
||||||
fixupKVOp := func(rawOp interface{}) error {
|
func fixupKVOp(rawOp interface{}) error {
|
||||||
rawMap, ok := rawOp.(map[string]interface{})
|
rawMap, ok := rawOp.(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unexpected raw op type: %T", rawOp)
|
return fmt.Errorf("unexpected raw op type: %T", rawOp)
|
||||||
|
@ -61,8 +58,11 @@ func fixupKVOps(raw interface{}) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fixupKVOps takes the raw decoded JSON and base64 decodes values in KV ops,
|
||||||
|
// replacing them with byte arrays.
|
||||||
|
func fixupKVOps(raw interface{}) error {
|
||||||
rawSlice, ok := raw.([]interface{})
|
rawSlice, ok := raw.([]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unexpected raw type: %t", raw)
|
return fmt.Errorf("unexpected raw type: %t", raw)
|
||||||
|
|
Loading…
Reference in New Issue