Skip to content

Commit e2d77c2

Browse files
committed
Remove RenderJSON function
This function was copied from c/c but isn't needed here. RenderJSON tried to preserve metadata of the passed object (e.g. name and namespace), and checked that its GVK didn't change. In practice in this function the passed object will always be new and empty so we can just use json.Marshal directly. Signed-off-by: Nic Cope <nicc@rk0n.org>
1 parent 0d69580 commit e2d77c2

File tree

3 files changed

+2
-167
lines changed

3 files changed

+2
-167
lines changed

fn.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"google.golang.org/protobuf/types/known/structpb"
77
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
8+
"k8s.io/apimachinery/pkg/util/json"
89

910
"github.com/crossplane/crossplane-runtime/pkg/errors"
1011
"github.com/crossplane/crossplane-runtime/pkg/fieldpath"
@@ -154,7 +155,7 @@ func (f *Function) RunFunction(ctx context.Context, req *fnv1beta1.RunFunctionRe
154155
// We want to return this resource unmutated if rendering fails.
155156
dcd.Resource = cd.Resource.DeepCopy()
156157
default:
157-
if err := RenderFromJSON(dcd.Resource, t.Base.Raw); err != nil {
158+
if err := json.Unmarshal(t.Base.Raw, dcd.Resource); err != nil {
158159
response.Fatal(rsp, errors.Wrapf(err, "cannot parse base template of composed resource %q", t.Name))
159160
return rsp, nil
160161
}

render.go

Lines changed: 0 additions & 49 deletions
This file was deleted.

render_test.go

Lines changed: 0 additions & 117 deletions
This file was deleted.

0 commit comments

Comments
 (0)