Skip to content

Commit

Permalink
autolint
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-maynard committed Nov 21, 2024
1 parent 65c3012 commit d9a1698
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ public static <T> Builder<T> builder() {
public static final PolarisConfiguration<Boolean> BOOTSTRAP_PRINT_CREDENTIALS =
PolarisConfiguration.<Boolean>builder()
.key("BOOTSTRAP_PRINT_CREDENTIALS")
.description(
"If set to true, credentials are printed to stdout by the bootstrap command")
.description("If set to true, credentials are printed to stdout by the bootstrap command")
.defaultValue(true)
.build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private void initializeForRealm(RealmContext realmContext) {
}

@Override
public final synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(List<String> realms) {
public final synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(
List<String> realms) {
Map<String, PrincipalSecretsResult> results = new HashMap<>();

for (String realm : realms) {
Expand All @@ -89,10 +90,11 @@ public final synchronized Map<String, PrincipalSecretsResult> bootstrapRealms(Li
PolarisCallContext polarisContext =
new PolarisCallContext(
sessionSupplierMap.get(realmContext.getRealmIdentifier()).get(), diagServices);
PrincipalSecretsResult secretsResult = bootstrapServiceAndCreatePolarisPrincipalForRealm(
realmContext,
metaStoreManagerMap.get(realmContext.getRealmIdentifier()),
polarisContext);
PrincipalSecretsResult secretsResult =
bootstrapServiceAndCreatePolarisPrincipalForRealm(
realmContext,
metaStoreManagerMap.get(realmContext.getRealmIdentifier()),
polarisContext);
results.put(realmContext.getRealmIdentifier(), secretsResult);
if (this.printCredentials(polarisContext)) {
String msg =
Expand Down Expand Up @@ -197,10 +199,12 @@ private PrincipalSecretsResult bootstrapServiceAndCreatePolarisPrincipalForRealm
// TODO rebase onto #422, call a method like PrincipalSecretsGenerator.hasEnvironmentVariables
boolean environmentVariableCredentials = false;
if (!this.printCredentials(polarisContext) && !environmentVariableCredentials) {
String failureMessage = String.format(
"It appears that environment variables were not provided for root credentials, and that printing " +
"the root credentials is disabled via %s. If bootstrapping were to proceed, there would be no way " +
"to recover the root credentials", PolarisConfiguration.BOOTSTRAP_PRINT_CREDENTIALS.key);
String failureMessage =
String.format(
"It appears that environment variables were not provided for root credentials, and that printing "
+ "the root credentials is disabled via %s. If bootstrapping were to proceed, there would be no way "
+ "to recover the root credentials",
PolarisConfiguration.BOOTSTRAP_PRINT_CREDENTIALS.key);
LOGGER.error("\n\n {} \n\n", failureMessage);
throw new IllegalArgumentException(failureMessage);
}
Expand Down Expand Up @@ -263,13 +267,10 @@ private void checkPolarisServiceBootstrappedForRealm(
}
}

/**
* Whether or not to print credentials after bootstrapping
*/
/** Whether or not to print credentials after bootstrapping */
protected boolean printCredentials(PolarisCallContext polarisCallContext) {
return polarisCallContext
.getConfigurationStore()
.getConfiguration(
polarisCallContext, PolarisConfiguration.BOOTSTRAP_PRINT_CREDENTIALS);
.getConfiguration(polarisCallContext, PolarisConfiguration.BOOTSTRAP_PRINT_CREDENTIALS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,12 @@
package org.apache.polaris.service.persistence;

import com.fasterxml.jackson.annotation.JsonTypeName;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;

import org.apache.polaris.core.PolarisCallContext;
import org.apache.polaris.core.PolarisConfiguration;
import org.apache.polaris.core.PolarisDiagnostics;
import org.apache.polaris.core.auth.PolarisSecretsManager.PrincipalSecretsResult;
import org.apache.polaris.core.context.RealmContext;
import org.apache.polaris.core.persistence.LocalPolarisMetaStoreManagerFactory;
import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
Expand Down

0 comments on commit d9a1698

Please sign in to comment.