Skip to content

Commit bd8b9a7

Browse files
committed
Another attempt to fix .spec.resourceRefs[0].uid: field not declared in schema
Signed-off-by: Yury Tsarev <yury@upbound.io>
1 parent 819fbe3 commit bd8b9a7

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

fn.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,22 @@ func (f *Function) handleApprovedChanges(req *fnv1.RunFunctionRequest, in *v1bet
152152
return err
153153
}
154154

155-
// When approved, we just pass through the desired state from the request
156-
// without any modifications - this preserves the exact output from previous functions
157-
rsp.Desired = req.GetDesired()
155+
// When approved, we need to carefully handle the resourceRefs field
156+
// Get the desired composite resource to update properties properly
157+
dxr, err := request.GetDesiredCompositeResource(req)
158+
if err != nil {
159+
response.Fatal(rsp, errors.Wrap(err, "cannot get desired composite resource"))
160+
return err
161+
}
162+
163+
// Save the desired XR in the response
164+
if err := response.SetDesiredCompositeResource(rsp, dxr); err != nil {
165+
response.Fatal(rsp, errors.Wrapf(err, "cannot set desired composite resource in %T", rsp))
166+
return err
167+
}
168+
169+
// For composed resources, we can pass through from the request
170+
rsp.Desired.Resources = req.GetDesired().GetResources()
158171

159172
// Set success condition
160173
response.ConditionTrue(rsp, "FunctionSuccess", "Success").

0 commit comments

Comments
 (0)