Skip to content

Commit 977d509

Browse files
committed
docs: expand KubernetesDependentResource example
Signed-off-by: Chris Laprun <[email protected]>
1 parent 261a698 commit 977d509

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

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

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,9 @@ for this feature.
113113

114114
## DependentResource-level configuration
115115

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:
116+
It is possible to define custom annotations to configure custom `DependentResource` implementations. In order to provide
117+
such a configuration mechanism for your own `DependentResource` implementations, they must be annotated with the
118+
`@Configured` annotation. This annotation defines 3 fields that tie everything together:
121119

122120
- `by`, which specifies which annotation class will be used to configure your dependents,
123121
- `with`, which specifies the class holding the configuration object for your dependents and
@@ -137,6 +135,28 @@ implement the `ConfiguredDependentResource` interface, parameterized with the an
137135
`@Configured` annotation `by` field. This interface is called by the framework to inject the configuration at the
138136
appropriate time and retrieve the configuration, if it's available.
139137

138+
For example, `KubernetesDependentResource`, a core implementation that the framework provides, can be configured via the
139+
`@KubernetesDependent` annotation. This set up is configured as follows:
140+
141+
```java
142+
143+
@Configured(
144+
by = KubernetesDependent.class,
145+
with = KubernetesDependentResourceConfig.class,
146+
converter = KubernetesDependentConverter.class)
147+
public abstract class KubernetesDependentResource<R extends HasMetadata, P extends HasMetadata>
148+
extends AbstractEventSourceHolderDependentResource<R, P, InformerEventSource<R, P>>
149+
implements ConfiguredDependentResource<KubernetesDependentResourceConfig<R>> {
150+
// code omitted
151+
}
152+
```
153+
154+
The `@Configured` annotation specifies that `KubernetesDependentResource` instances can be configured by using the
155+
`@KubernetesDependent` annotation, which gets converted into a `KubernetesDependentResourceConfig` object by a
156+
`KubernetesDependentConverter`. That configuration object is then injected by the framework in the
157+
`KubernetesDependentResource` instance, after it's been created, because the class implements the
158+
`ConfiguredDependentResource` interface, properly parameterized.
159+
140160
For more information on how to use this feature, we recommend looking at how this mechanism is implemented for
141161
`KubernetesDependentResource` in the core framework, `SchemaDependentResource` in the samples or `CustomAnnotationDep`
142162
in the `BaseConfigurationServiceTest` test class.

0 commit comments

Comments
 (0)