Skip to content

Commit ea20e96

Browse files
committed
docs: document annotation-based dependent resource configuration
Fixes #2791 Signed-off-by: Chris Laprun <[email protected]>
1 parent 0aeb314 commit ea20e96

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

docs/content/en/docs/documentation/configuration.md

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,33 @@ for this feature.
113113

114114
## DependentResource-level configuration
115115

116-
`DependentResource` implementations can implement the `DependentResourceConfigurator` interface
117-
to pass information to the implementation. For example, the SDK
118-
provides specific support for the `KubernetesDependentResource`, which can be configured via the
119-
`@KubernetesDependent` annotation. This annotation is, in turn, converted into a
120-
`KubernetesDependentResourceConfig` instance, which is then passed to the `configureWith` method
121-
implementation.
122-
123-
TODO
116+
It is possible to define custom annotations to configure custom `DependentResource` implementations. For example, the
117+
SDK provides the `@KubernetesDependent` annotation which allows configuring `KubernetesDependentResource` instance.
118+
119+
In order to provide such a configuration mechanism for your own `DependentResource` implementations, they must be
120+
annotated with the `@Configured` annotation. This annotation defines 3 fields that tie everything together:
121+
122+
- `by`, which specifies which annotation class will be used to configure your dependents,
123+
- `with`, which specifies the class holding the configuration object for your dependents and
124+
- `converter`, which specifies the `ConfigurationConverter` implementation in charge of converting the annotation
125+
specified by the `by` field into objects of the class specified by the `with` field.
126+
127+
`ConfigurationConverter` instances implement a single `configFrom` method, which will receive, as expected, the
128+
annotation instance annotating the dependent resource instance to be configured, but it can also extract information
129+
from the `DependentResourceSpec` instance associated with the `DependentResource` class so that metadata from it can be
130+
used in the configuration, as well as the parent `ControllerConfiguration`, if needed. The role of
131+
`ConfigurationConverter` implementations is to extract the annotation information, augment it with metadata from the
132+
`DependentResourceSpec` and the configuration from the parent controller on which the dependent is defined, to finally
133+
create the configuration object that the `DependentResource` instances will use.
134+
135+
However, one last element is required to finish the configuration process: the target `DependentResource` class must
136+
implement the `ConfiguredDependentResource` interface, parameterized with the annotation class defined by the
137+
`@Configured` annotation `by` field. This interface is called by the framework to inject the configuration at the
138+
appropriate time and retrieve the configuration, if it's available.
139+
140+
For more information on how to use this feature, we recommend looking at how this mechanism is implemented for
141+
`KubernetesDependentResource` in the core framework, `SchemaDependentResource` in the samples or `CustomAnnotationDep`
142+
in the `BaseConfigurationServiceTest` test class.
124143

125144
## EventSource-level configuration
126145

0 commit comments

Comments
 (0)