diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70de62c..568c17c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ on: env: # Common versions GO_VERSION: '1.21.6' - GOLANGCI_VERSION: 'v1.55.2' + GOLANGCI_VERSION: 'v1.60.3' jobs: check-diff: diff --git a/Makefile b/Makefile index 93ad395..50c2832 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 ))) GO_LDFLAGS += -X $(GO_PROJECT)/pkg/version.Version=$(VERSION) GO_SUBDIRS += errors proto resource response request GO111MODULE = on -GOLANGCILINT_VERSION = 1.55.2 +GOLANGCILINT_VERSION = 1.60.3 GO_LINT_ARGS ?= "--fix" -include build/makelib/golang.mk diff --git a/errors/errors.go b/errors/errors.go index e3c2560..0af5f6b 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -117,7 +117,6 @@ func Cause(err error) error { } for err != nil { - //nolint:errorlint // We actually do want to check the outermost error. w, ok := err.(wrapped) if !ok { return err diff --git a/sdk_test.go b/sdk_test.go index d8994e0..41da162 100644 --- a/sdk_test.go +++ b/sdk_test.go @@ -79,13 +79,31 @@ func Example() { } // Set our updated desired composed resource in the response we'll return. - _ = response.SetDesiredComposedResources(rsp, desired) + if err := response.SetDesiredComposedResources(rsp, desired); err != nil { + // You can set a custom status condition on the claim. This allows you to + // communicate with the user. See the link below for status condition + // guidance. + // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties + 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; see the issue below for more information. + // https://github.com/crossplane/crossplane/issues/5802 + response.Warning(rsp, errors.New("something went wrong")). + TargetCompositeAndClaim() + } else { + response.ConditionTrue(rsp, "FunctionSuccess", "Success"). + TargetCompositeAndClaim() + } j, _ := protojson.Marshal(rsp) fmt.Println(string(j)) // Output: - // {"meta":{"ttl":"60s"},"desired":{"resources":{"new":{"resource":{"apiVersion":"example.org/v1","kind":"CoolResource","metadata":{"labels":{"coolness":"high"}},"spec":{"widgets":9001}}}}}} + // {"meta":{"ttl":"60s"},"desired":{"resources":{"new":{"resource":{"apiVersion":"example.org/v1","kind":"CoolResource","metadata":{"labels":{"coolness":"high"}},"spec":{"widgets":9001}}}}},"conditions":[{"type":"FunctionSuccess","status":"STATUS_CONDITION_TRUE","reason":"Success","target":"TARGET_COMPOSITE_AND_CLAIM"}]} } func TestBetaServer(t *testing.T) {