-
Notifications
You must be signed in to change notification settings - Fork 26
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
We are investigating replacing our YAML based Compositions with Go based Functions. As part of that, we want to be able to add some additional labels dynamically to the Composite Resource. However, when we try to do that, we don't end up with any new labels. Here is an example of how we try to add the labels:
func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest) (*fnv1.RunFunctionResponse, error) {
rsp := response.To(req, response.DefaultTTL)
xr, err := request.GetObservedCompositeResource(req)
if err != nil {
response.Fatal(rsp, errors.Wrapf(err, "cannot get observed composite resource from %T", req))
return rsp, nil
}
... code that sets desired resources ...
// This works as expected
xr.Resource.SetString("status.hostname", fullHostname)
// This is how I think it should have worked even though it didn't.
origLabels := xr.Resource.GetLabels()
origLabels["controplane.com/anything-we-want"] = "a-new-and-special-value"
xr.Resource.SetLabels(origLabels)
response.SetDesiredCompositeResource(rsp, xr)
response.Normal(rsp, "Success")
return rsp, nil
}Please let me know if there is another way to set a label using the Go SDK.
How can we reproduce it?
What environment did it happen in?
Crossplane version: v2.1.1 (server)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working