Skip to content

Commit

Permalink
Merge pull request #14 from negz/resulting
Browse files Browse the repository at this point in the history
Add convenience functions for returning results
  • Loading branch information
negz authored Nov 22, 2023
2 parents 07a7b82 + 667a56d commit 09c6bb9
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions crossplane/function/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,33 @@ def to(
desired=req.desired,
context=req.context,
)


def normal(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
"""Add a normal result to the response."""
rsp.results.append(
fnv1beta1.Result(
severity=fnv1beta1.SEVERITY_NORMAL,
message=message,
)
)


def warning(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
"""Add a warning result to the response."""
rsp.results.append(
fnv1beta1.Result(
severity=fnv1beta1.SEVERITY_WARNING,
message=message,
)
)


def fatal(rsp: fnv1beta1.RunFunctionResponse, message: str) -> None:
"""Add a fatal result to the response."""
rsp.results.append(
fnv1beta1.Result(
severity=fnv1beta1.SEVERITY_FATAL,
message=message,
)
)

0 comments on commit 09c6bb9

Please sign in to comment.