mirror of https://github.com/crossplane/docs.git
Adding examples of communicating with the user via events and conditions.
Signed-off-by: dalton hill <dalton.hill.0@protonmail.com>
This commit is contained in:
parent
22fb432c5c
commit
412094a45e
|
@ -298,6 +298,18 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
|
|||
// to add desired managed resources.
|
||||
xr, err := request.GetObservedCompositeResource(req)
|
||||
if err != nil {
|
||||
// You can set a custom status condition on the claim. This
|
||||
// allows you to communicate with the user.
|
||||
response.ConditionFalse(rsp, "FunctionSuccess", "InternalError").
|
||||
WithMessage("Something went wrong.").
|
||||
TargetCompositeAndClaim()
|
||||
|
||||
// You can emit an event regarding the claim. This allows you to
|
||||
// communicate with the user. Note that events should be used
|
||||
// sparingly and are subject to throttling
|
||||
response.Warning(rsp, errors.New("something went wrong")).
|
||||
TargetCompositeAndClaim()
|
||||
|
||||
// If the function can't read the XR, the request is malformed. This
|
||||
// should never happen. The function returns a fatal result. This tells
|
||||
// Crossplane to stop running functions and return an error.
|
||||
|
@ -388,6 +400,11 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
|
|||
// Kubernetes events associated with the XR it's operating on.
|
||||
log.Info("Added desired buckets", "region", region, "count", len(names))
|
||||
|
||||
// You can set a custom status condition on the claim. This allows you
|
||||
// to communicate with the user.
|
||||
response.ConditionTrue(rsp, "FunctionSuccess", "Success").
|
||||
TargetCompositeAndClaim()
|
||||
|
||||
return rsp, nil
|
||||
}
|
||||
```
|
||||
|
|
|
@ -298,6 +298,18 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
|
|||
// to add desired managed resources.
|
||||
xr, err := request.GetObservedCompositeResource(req)
|
||||
if err != nil {
|
||||
// You can set a custom status condition on the claim. This
|
||||
// allows you to communicate with the user.
|
||||
response.ConditionFalse(rsp, "FunctionSuccess", "InternalError").
|
||||
WithMessage("Something went wrong.").
|
||||
TargetCompositeAndClaim()
|
||||
|
||||
// You can emit an event regarding the claim. This allows you to
|
||||
// communicate with the user. Note that events should be used
|
||||
// sparingly and are subject to throttling
|
||||
response.Warning(rsp, errors.New("something went wrong")).
|
||||
TargetCompositeAndClaim()
|
||||
|
||||
// If the function can't read the XR, the request is malformed. This
|
||||
// should never happen. The function returns a fatal result. This tells
|
||||
// Crossplane to stop running functions and return an error.
|
||||
|
@ -388,6 +400,11 @@ func (f *Function) RunFunction(_ context.Context, req *fnv1.RunFunctionRequest)
|
|||
// Kubernetes events associated with the XR it's operating on.
|
||||
log.Info("Added desired buckets", "region", region, "count", len(names))
|
||||
|
||||
// You can set a custom status condition on the claim. This allows you
|
||||
// to communicate with the user.
|
||||
response.ConditionTrue(rsp, "FunctionSuccess", "Success").
|
||||
TargetCompositeAndClaim()
|
||||
|
||||
return rsp, nil
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in New Issue