Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public URI baseUri() {
@Override
public ClientPrincipal adminCredentials() {
// These credentials are injected via env. variables from build scripts.
// Cf. POLARIS_BOOTSTRAP_POLARIS_ROOT_CLIENT_ID
// Cf. POLARIS_BOOTSTRAP_CREDENTIALS in build.gradle.kts
return new ClientPrincipal("root", new ClientCredentials("test-admin", "test-secret"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.time.Clock;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
Expand Down Expand Up @@ -65,7 +65,7 @@ public InMemoryPolarisMetaStoreManagerFactory(
}

public void onStartup(RealmContextConfiguration realmContextConfiguration) {
bootstrapRealmAndPrintCredentials(realmContextConfiguration.defaultRealm());
bootstrapRealmsAndPrintCredentials(realmContextConfiguration.realms());
}

@Override
Expand All @@ -86,7 +86,7 @@ protected PolarisMetaStoreSession createMetaStoreSession(
@Override
public synchronized PolarisMetaStoreManager getOrCreateMetaStoreManager(RealmId realmId) {
if (!bootstrappedRealms.contains(realmId.id())) {
bootstrapRealmAndPrintCredentials(realmId.id());
bootstrapRealmsAndPrintCredentials(List.of(realmId.id()));
}
return super.getOrCreateMetaStoreManager(realmId);
}
Expand All @@ -95,25 +95,28 @@ public synchronized PolarisMetaStoreManager getOrCreateMetaStoreManager(RealmId
public synchronized Supplier<PolarisMetaStoreSession> getOrCreateSessionSupplier(
RealmId realmId) {
if (!bootstrappedRealms.contains(realmId.id())) {
bootstrapRealmAndPrintCredentials(realmId.id());
bootstrapRealmsAndPrintCredentials(List.of(realmId.id()));
}
return super.getOrCreateSessionSupplier(realmId);
}

private void bootstrapRealmAndPrintCredentials(String realmId) {
private void bootstrapRealmsAndPrintCredentials(List<String> realms) {
PolarisCredentialsBootstrap credentialsBootstrap =
PolarisCredentialsBootstrap.fromEnvironment();
Map<String, PrincipalSecretsResult> results =
this.bootstrapRealms(
Collections.singletonList(realmId), PolarisCredentialsBootstrap.fromEnvironment());
bootstrappedRealms.add(realmId);
this.bootstrapRealms(realms, credentialsBootstrap);
bootstrappedRealms.addAll(realms);

PrincipalSecretsResult principalSecrets = results.get(realmId);
for (String realmId : realms) {
PrincipalSecretsResult principalSecrets = results.get(realmId);

String msg =
String.format(
"realm: %1s root principal credentials: %2s:%3s",
realmId,
principalSecrets.getPrincipalSecrets().getPrincipalClientId(),
principalSecrets.getPrincipalSecrets().getMainSecret());
System.out.println(msg);
String msg =
String.format(
"realm: %1s root principal credentials: %2s:%3s",
realmId,
principalSecrets.getPrincipalSecrets().getPrincipalClientId(),
principalSecrets.getPrincipalSecrets().getMainSecret());
System.out.println(msg);
}
}
}
Loading