RunFunction runs the Function.
(_ context.Context, req *fnv1.RunFunctionRequest)
| 21 | |
| 22 | // RunFunction runs the Function. |
| 23 | func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest) (*fnv1.RunFunctionResponse, error) { |
| 24 | f.log.Info("Running function", "tag", req.GetMeta().GetTag()) |
| 25 | |
| 26 | rsp := response.To(req, response.DefaultTTL) |
| 27 | |
| 28 | in := &v1beta1.Input{} |
| 29 | if err := request.GetInput(req, in); err != nil { |
| 30 | // You can set a custom status condition on the claim. This allows you to |
| 31 | // communicate with the user. See the link below for status condition |
| 32 | // guidance. |
| 33 | // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties |
| 34 | response.ConditionFalse(rsp, "FunctionSuccess", "InternalError"). |
| 35 | WithMessage("Something went wrong."). |
| 36 | TargetCompositeAndClaim() |
| 37 | |
| 38 | // You can emit an event regarding the claim. This allows you to communicate |
| 39 | // with the user. Note that events should be used sparingly and are subject |
| 40 | // to throttling; see the issue below for more information. |
| 41 | // https://github.com/crossplane/crossplane/issues/5802 |
| 42 | response.Warning(rsp, errors.New("something went wrong")). |
| 43 | TargetCompositeAndClaim() |
| 44 | |
| 45 | response.Fatal(rsp, errors.Wrapf(err, "cannot get Function input from %T", req)) |
| 46 | return rsp, nil |
| 47 | } |
| 48 | |
| 49 | // TODO: Add your Function logic here! |
| 50 | response.Normalf(rsp, "I was run with input %q!", in.Example) |
| 51 | f.log.Info("I was run!", "input", in.Example) |
| 52 | |
| 53 | // You can set a custom status condition on the claim. This allows you to |
| 54 | // communicate with the user. See the link below for status condition |
| 55 | // guidance. |
| 56 | // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties |
| 57 | response.ConditionTrue(rsp, "FunctionSuccess", "Success"). |
| 58 | TargetCompositeAndClaim() |
| 59 | |
| 60 | return rsp, nil |
| 61 | } |
no outgoing calls