* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
28 lines
596 B
Go
28 lines
596 B
Go
/*
|
|
* Please refer to the LICENSE file in the root directory of the project.
|
|
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
|
|
*/
|
|
|
|
package josnpatchutil
|
|
|
|
import (
|
|
jsonpatch "github.com/evanphx/json-patch"
|
|
"github.com/mitchellh/mapstructure"
|
|
)
|
|
|
|
func Parse(raw []byte) (jsonpatch.Patch, error) {
|
|
return jsonpatch.DecodePatch(raw)
|
|
}
|
|
|
|
func GetValue(patch jsonpatch.Operation, value interface{}) error {
|
|
valueInterface, err := patch.ValueInterface()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if err := mapstructure.Decode(valueInterface, value); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|