-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13498 from vsevel/vault_config_boostrap
Move VaultRuntimeConfig to BOOTSTRAP phase
- Loading branch information
Showing
14 changed files
with
92 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 21 additions & 4 deletions
25
extensions/vault/runtime/src/main/java/io/quarkus/vault/runtime/VaultRecorder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,43 @@ | ||
package io.quarkus.vault.runtime; | ||
|
||
import java.util.Collections; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigSource; | ||
import org.eclipse.microprofile.config.spi.ConfigSourceProvider; | ||
import org.jboss.logging.Logger; | ||
|
||
import io.quarkus.arc.Arc; | ||
import io.quarkus.runtime.RuntimeValue; | ||
import io.quarkus.runtime.TlsConfig; | ||
import io.quarkus.runtime.annotations.Recorder; | ||
import io.quarkus.vault.runtime.config.VaultBuildTimeConfig; | ||
import io.quarkus.vault.runtime.config.VaultConfigSourceProvider; | ||
import io.quarkus.vault.runtime.config.VaultRuntimeConfig; | ||
|
||
@Recorder | ||
public class VaultRecorder { | ||
|
||
private static final Logger log = Logger.getLogger(VaultRecorder.class); | ||
|
||
public void configureRuntimeProperties(VaultBuildTimeConfig vaultBuildTimeConfig, VaultRuntimeConfig vaultRuntimeConfig, | ||
public RuntimeValue<ConfigSourceProvider> configureRuntimeProperties(VaultBuildTimeConfig vaultBuildTimeConfig, | ||
VaultRuntimeConfig vaultRuntimeConfig, | ||
TlsConfig tlsConfig) { | ||
|
||
if (vaultRuntimeConfig.url.isPresent()) { | ||
VaultServiceProducer producer = Arc.container().instance(VaultServiceProducer.class).get(); | ||
producer.setVaultConfigs(vaultBuildTimeConfig, vaultRuntimeConfig, tlsConfig); | ||
VaultManager.init(vaultBuildTimeConfig, vaultRuntimeConfig, tlsConfig); | ||
return new RuntimeValue<>(new VaultConfigSourceProvider(vaultRuntimeConfig)); | ||
} else { | ||
return emptyRuntimeValue(); | ||
} | ||
} | ||
|
||
private RuntimeValue<ConfigSourceProvider> emptyRuntimeValue() { | ||
return new RuntimeValue<>(new EmptyConfigSourceProvider()); | ||
} | ||
|
||
private static class EmptyConfigSourceProvider implements ConfigSourceProvider { | ||
@Override | ||
public Iterable<ConfigSource> getConfigSources(ClassLoader forClassLoader) { | ||
return Collections.emptyList(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.