Skip to content

v0.3.0

Latest

Choose a tag to compare

@stevendborrelli stevendborrelli released this 23 Mar 16:06
fa28064

Release v0.3.0

Overview

This release adds support for annotations-based protection, the ability
to set custom reasons, replay deletion support, typed Usage generation,
updated examples for Crossplane v2, and multiple dependency updates.

Key Features

Annotations Support (#32)

The function now defaults to using annotations for enabling
deletion protection and other settings.

metadata:
  annotations:
    protection.fn.crossplane.io/block-deletion: "true"

The protection.fn.crossplane.io/block-deletion label is still
supported for backwards compatibility. In the case of a conflict
between the annotation and label, the annotation will take
precedence.

All other settings like custom reasons and replay deletion
are only supported via annotations.

metadata:
  labels:
    protection.fn.crossplane.io/block-deletion: "true"

Custom Reason Messages

You can now specify custom reason messages that appear in the Usage and deletion rejection messages using the protection.fn.crossplane.io/reason annotation:

metadata:
  annotations:
    protection.fn.crossplane.io/block-deletion: "true"
    protection.fn.crossplane.io/reason: "in use by production workload - do not delete"

Custom reasons help provide context-specific information about why a resource is protected, making it clearer to operators why deletion is blocked.

Replay Deletion

The function now supports the replayDeletion feature for Usages via the protection.fn.crossplane.io/replay-deletion annotation. When enabled, deletion attempts will be logged and tracked:

metadata:
  annotations:
    protection.fn.crossplane.io/block-deletion: "true"
    protection.fn.crossplane.io/replay-deletion: "true"

Replay deletion can speed up deletion of nested resources that
have been blocked by the Usage webhook. However, it will attempt
to delete a resource if the Usage is removed.

See comment 6140#issuecomment-2538629314. For
a discussion of possible downsides.

Typed Usage Generation (#35)

The function now uses Go types to generate Usage objects instead of unstructured data.

Before: Usage objects were created as map[string]any with manual field construction:

usage := map[string]any{
    "apiVersion": ProtectionGroupVersion,
    "kind":       usageType,
    "metadata":   usageMeta,
    "spec": map[string]any{
        "of": map[string]any{
            "apiVersion": u.GetAPIVersion(),
            // ...
        },
    },
}

In release v0.3.0, they are created as Go structs:

usage := protectionv1beta1.Usage{
    ObjectMeta: v1.ObjectMeta{
        Name:      GenerateName(name, UsageNameSuffix),
        Namespace: u.GetNamespace(),
    },
    Spec: protectionv1beta1.UsageSpec{
        Of: protectionv1beta1.NamespacedResource{
            APIVersion: u.GetAPIVersion(),
            Kind:       u.GetKind(),
            ResourceRef: &protectionv1beta1.NamespacedResourceRef{
                Name: u.GetName(),
            },
        },
        Reason:         &uo.Reason,
        ReplayDeletion: &uo.ReplayDeletion,
    },
}
return composed.From(&usage)

Updated Examples for Crossplane v2 (#37)

All examples have been updated to align with Crossplane v2 APIs and conventions:

  • Updated API versions from v1beta1 to v1 for Function packages
  • Updated composition examples with v2-compatible resources
  • Fixed indentation and package version references
  • Updated example documentation to reflect v2 changes

Technical Improvements

Dependency Updates

  • Updated github.com/crossplane/function-sdk-go to v0.6.2 (#36, #22)
  • Updated google.golang.org/protobuf to v1.36.11 (#17)
  • Updated module dependencies (#34)
  • Pin dependencies for reproducible builds (#33)

CI/CD Updates

  • Updated docker/build-push-action to v7 (#30)
  • Updated docker/setup-buildx-action to v4 (#29)
  • Updated docker/setup-qemu-action to v4 (#28)
  • Updated docker/login-action to v4 (#27)
  • Updated golangci/golangci-lint-action to v9 (#26)
  • Updated actions/checkout to v6.0.2 (#16)
  • Updated GitHub artifact actions (#25)

Installation

Install via Crossplane package specification:

apiVersion: pkg.crossplane.io/v1
kind: Function
metadata:
  name: crossplane-contrib-function-deletion-protection
spec:
  package: xpkg.upbound.io/crossplane-contrib/function-deletion-protection:v0.3.0

Compatibility

  • Crossplane 2.x: Full support for all features including Operations
  • Crossplane 1.x: Composition pipeline support available with v1 mode
  • Breaking Changes: None - fully backward compatible with v0.2.x

What's Changed

Full Changelog: v0.2.0...v0.3.0