Skip to content

docs: remove ConfigurationServiceProvider obsolete usage #2022

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
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 7 additions & 16 deletions docs/documentation/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permalink: /docs/configuration

# Configuration options

The Java Operator SDK (JOSDK for short) provides several abstractions that work great out of the
The Java Operator SDK (JOSDK) provides several abstractions that work great out of the
box. However, while we strive to cover the most common cases with the default behavior, we also
recognize that that default behavior is not always what any given user might want for their
operator. Numerous configuration options are therefore provided to help people tailor the
Expand All @@ -23,29 +23,20 @@ Configuration options act at several levels, depending on which behavior you wis
## Operator-level configuration

Configuration that impacts the whole operator is performed via the `ConfigurationService` class.
An instance is provided by the `ConfigurationServiceProvider.instance()` method. This is the
normal way for user-code to retrieve the current `ConfigurationService` instance. Sensible
defaults are provided but you can change the default behavior by overriding the current
configuration using `ConfigurationServiceProvider.overrideCurrent` method, providing a
`ConfigurationServiceOverrider` `Consumer` that will apply the modifications you wish to perform
on the configuration.
`ConfigurationService` is an abstract class, and the implementation can be different based
on which flavor of the framework is used. For example Quarkus Operator SDK replaces the
default implementation. Configurations are initialized with sensible defaults, but can
be changed during initialization.

For instance, if you wish to not validate that the CRDs are present on your cluster when the
operator starts and configure leader election, you would do something similar to:

```java
ConfigurationServiceProvider.overrideCurrent(o -> o.checkingCRDAndValidateLocalModel(false)
Operator operator = new Operator( override -> override
.checkingCRDAndValidateLocalModel(false)
.withLeaderElectionConfiguration(new LeaderElectionConfiguration("bar", "barNS")));
```

Note that you can also obtain the same result by passing the `ConfigurationServiceOverrider`
`Consumer` instance to the `Operator` constructor:

```java
new Operator(o -> o.checkingCRDAndValidateLocalModel(false)
.withLeaderElectionConfiguration(new LeaderElectionConfiguration("bar","barNS")));
```

## Reconciler-level configuration

While reconcilers are typically configured using the `@ControllerConfiguration` annotation, it
Expand Down
3 changes: 1 addition & 2 deletions docs/documentation/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ Furthermore, you may not be able to list CRDs at startup which is required when
is `true` (`false` by default). To disable, set it to `false` at [Operator-level configuration](./configuration.md#operator-level-configuration):

```java
ConfigurationServiceProvider.overrideCurrent(o -> o.checkingCRDAndValidateLocalModel(false));
Operator operator = new Operator( override -> override.checkingCRDAndValidateLocalModel(false));
```


### Q: How to fix `sun.security.provider.certpath.SunCertPathBuilderException` on Rancher Desktop and k3d/k3s Kubernetes

It's a common issue when using k3d and the fabric8 client tries to connect to the cluster an exception is thrown:
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ follows:

```java
Metrics metrics= …;
ConfigurationServiceProvider.overrideCurrent(overrider->overrider.withMetrics(metrics));
Operator operator = new Operator(client, o -> o.withMetrics());
```

### Micrometer implementation
Expand Down