Skip to content

docs: document annotation-based dependent resource configuration #2809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions docs/content/en/docs/documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,33 @@ for this feature.

## DependentResource-level configuration

`DependentResource` implementations can implement the `DependentResourceConfigurator` interface
to pass information to the implementation. For example, the SDK
provides specific support for the `KubernetesDependentResource`, which can be configured via the
`@KubernetesDependent` annotation. This annotation is, in turn, converted into a
`KubernetesDependentResourceConfig` instance, which is then passed to the `configureWith` method
implementation.

TODO
It is possible to define custom annotations to configure custom `DependentResource` implementations. For example, the
SDK provides the `@KubernetesDependent` annotation which allows configuring `KubernetesDependentResource` instance.

In order to provide such a configuration mechanism for your own `DependentResource` implementations, they must be
annotated with the `@Configured` annotation. This annotation defines 3 fields that tie everything together:

- `by`, which specifies which annotation class will be used to configure your dependents,
- `with`, which specifies the class holding the configuration object for your dependents and
- `converter`, which specifies the `ConfigurationConverter` implementation in charge of converting the annotation
specified by the `by` field into objects of the class specified by the `with` field.

`ConfigurationConverter` instances implement a single `configFrom` method, which will receive, as expected, the
annotation instance annotating the dependent resource instance to be configured, but it can also extract information
from the `DependentResourceSpec` instance associated with the `DependentResource` class so that metadata from it can be
used in the configuration, as well as the parent `ControllerConfiguration`, if needed. The role of
`ConfigurationConverter` implementations is to extract the annotation information, augment it with metadata from the
`DependentResourceSpec` and the configuration from the parent controller on which the dependent is defined, to finally
create the configuration object that the `DependentResource` instances will use.

However, one last element is required to finish the configuration process: the target `DependentResource` class must
implement the `ConfiguredDependentResource` interface, parameterized with the annotation class defined by the
`@Configured` annotation `by` field. This interface is called by the framework to inject the configuration at the
appropriate time and retrieve the configuration, if it's available.

For more information on how to use this feature, we recommend looking at how this mechanism is implemented for
`KubernetesDependentResource` in the core framework, `SchemaDependentResource` in the samples or `CustomAnnotationDep`
in the `BaseConfigurationServiceTest` test class.

## EventSource-level configuration

Expand Down

This file was deleted.