From 9501be51ffd54ecf35a407eeff4a533ba92066ae Mon Sep 17 00:00:00 2001 From: Huang Huang Date: Wed, 9 Mar 2022 08:58:43 +0800 Subject: [PATCH] test: Fix `BenchmarkModifySetMutator_Mutate` was broken (#1897) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sertaç Özercan <852750+sozercan@users.noreply.github.com> --- .../modify_set_mutator_benchmark_test.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pkg/mutation/mutators/modifyset/modify_set_mutator_benchmark_test.go b/pkg/mutation/mutators/modifyset/modify_set_mutator_benchmark_test.go index a18b1657f96..76c04dc9c52 100644 --- a/pkg/mutation/mutators/modifyset/modify_set_mutator_benchmark_test.go +++ b/pkg/mutation/mutators/modifyset/modify_set_mutator_benchmark_test.go @@ -1,7 +1,6 @@ package modifyset import ( - "encoding/json" "fmt" "strings" "testing" @@ -10,20 +9,8 @@ import ( "github.com/open-policy-agent/gatekeeper/pkg/mutation/match" "github.com/open-policy-agent/gatekeeper/pkg/mutation/path/tester" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" ) -func makeValue(v interface{}) runtime.RawExtension { - v2 := map[string]interface{}{ - "value": v, - } - j, err := json.Marshal(v2) - if err != nil { - panic(err) - } - return runtime.RawExtension{Raw: j} -} - func modifyset(value interface{}, location string) *unversioned.ModifySet { result := &unversioned.ModifySet{ Spec: unversioned.ModifySetSpec{ @@ -34,8 +21,9 @@ func modifyset(value interface{}, location string) *unversioned.ModifySet { }}, Location: location, Parameters: unversioned.ModifySetParameters{ + Operation: unversioned.MergeOp, Values: unversioned.Values{ - FromList: []interface{}{makeValue(value)}, + FromList: []interface{}{value}, }, }, },