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 @@ -18,9 +18,7 @@
*/
package org.apache.polaris.admintool;

import jakarta.inject.Inject;
import java.util.concurrent.Callable;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.Spec;

Expand All @@ -30,7 +28,5 @@ public abstract class BaseCommand implements Callable<Integer> {
public static final int EXIT_CODE_BOOTSTRAP_ERROR = 3;
public static final int EXIT_CODE_PURGE_ERROR = 4;

@Inject MetaStoreManagerFactory metaStoreManagerFactory;

@Spec CommandSpec spec;
@Spec protected CommandSpec spec;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.admintool;

import jakarta.inject.Inject;
import org.apache.polaris.core.persistence.MetaStoreManagerFactory;

public abstract class BaseMetaStoreCommand extends BaseCommand {
@Inject protected MetaStoreManagerFactory metaStoreManagerFactory;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
name = "bootstrap",
mixinStandardHelpOptions = true,
description = "Bootstraps realms and root principal credentials.")
public class BootstrapCommand extends BaseCommand {
public class BootstrapCommand extends BaseMetaStoreCommand {

@CommandLine.Mixin InputOptions inputOptions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
BootstrapCommand.class,
PurgeCommand.class,
})
public class PolarisAdminTool extends BaseCommand {
public class PolarisAdminTool extends BaseMetaStoreCommand {

@Override
public Integer call() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
name = "purge",
mixinStandardHelpOptions = true,
description = "Purge realms and all associated entities.")
public class PurgeCommand extends BaseCommand {
public class PurgeCommand extends BaseMetaStoreCommand {

@CommandLine.Option(
names = {"-r", "--realm"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@
import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
import org.apache.polaris.core.storage.PolarisStorageIntegration;
import org.apache.polaris.core.storage.PolarisStorageIntegrationProvider;
import org.eclipse.microprofile.config.inject.ConfigProperty;

public class AdminToolProducers {

@Produces
public MetaStoreManagerFactory metaStoreManagerFactory(
@ConfigProperty(name = "polaris.persistence.type") String persistenceType,
QuarkusPersistenceConfiguration persistenceConfiguration,
@Any Instance<MetaStoreManagerFactory> metaStoreManagerFactories) {
return metaStoreManagerFactories.select(Identifier.Literal.of(persistenceType)).get();
return metaStoreManagerFactories
.select(Identifier.Literal.of(persistenceConfiguration.type()))
.get();
}

@Produces
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.polaris.admintool.config;

import io.smallrye.config.ConfigMapping;

@ConfigMapping(prefix = "polaris.persistence")
public interface QuarkusPersistenceConfiguration {

/**
* The type of the persistence to use. Must be a registered {@link
* org.apache.polaris.core.persistence.MetaStoreManagerFactory} identifier.
*/
String type();
}