Skip to content
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

[4.x] Follow-up items for OCI Global Config #7387

Merged
merged 2 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
1 change: 1 addition & 0 deletions integrations/oci/sdk/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-metadata</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.helidon.inject</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,23 +202,41 @@ public static Supplier<? extends AbstractAuthenticationDetailsProvider> ociAuthe
*
* @return the supplier for the raw config-backed by the OCI config source(s)
* @see #ociAuthenticationProvider()
* @see #configSupplier(Supplier)
*/
public static Supplier<io.helidon.common.config.Config> configSupplier() {
if (ociConfigSupplier == null) {
ociConfigSupplier = () -> {
configSupplier(() -> {
// we do it this way to allow for any system and env vars to be used for the auth-strategy definition
// (not advertised in the javadoc)
String ociConfigFile = ociConfigFilename();
return Config.create(
ConfigSources.classpath(ociConfigFile).optional(),
ConfigSources.file(ociConfigFile).optional());
};
});
}

return ociConfigSupplier;
}

static boolean isSufficientlyConfigured(io.helidon.common.config.Config config) {
/**
* Establishes the supplier for the raw config-backed by the OCI config source(s).
*
* @param configSupplier the config supplier
* @see #configSupplier()
*/
public static void configSupplier(Supplier<io.helidon.common.config.Config> configSupplier) {
ociConfigSupplier = configSupplier;
}

/**
* Returns {@code true} if the given config is sufficiently configured in order to identity an OCI authentication strategy.
* If {@code false} then {@link OciAuthenticationDetailsProvider.AuthStrategy#AUTO} will be applied.
*
* @param config the config
* @return true if the given config can be used to identify an OCI authentication strategy
*/
public static boolean isSufficientlyConfigured(io.helidon.common.config.Config config) {
return (config != null
&& (config.get(KEY_AUTH_STRATEGY).exists()
|| config.get(KEY_AUTH_STRATEGIES).exists()));
Expand Down
7 changes: 3 additions & 4 deletions integrations/oci/sdk/runtime/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
module io.helidon.integrations.oci.sdk.runtime {
requires static jakarta.inject;
requires static jakarta.annotation;
requires static io.helidon.config.metadata;

requires io.helidon.builder.api;
requires io.helidon.common;
requires io.helidon.config;
requires io.helidon.config.metadata;
requires transitive io.helidon.common;
requires transitive io.helidon.config;
requires transitive io.helidon.inject.runtime;
requires oci.java.sdk.common;
requires io.helidon.common.types;

exports io.helidon.integrations.oci.sdk.runtime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ void selectionWhenNoConfigIsSet() {
OciExtensionTest.basicTestingConfigSource());
resetWith(config);

assertThat(OciExtension.isSufficientlyConfigured(config),
is(false));

ServiceProvider<AbstractAuthenticationDetailsProvider> authServiceProvider =
services.lookupFirst(AbstractAuthenticationDetailsProvider.class, true).orElseThrow();
Objects.requireNonNull(authServiceProvider);
Expand Down