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

ISPN-14040 CLI config reset #10243

Merged
merged 1 commit into from
Aug 1, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions cli/src/main/java/org/infinispan/cli/Context.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public interface Context extends AeshContext {

Properties getProperties();

void resetProperties();

void saveProperties();

void setSslContext(SSLContextSettings sslContext);
Expand Down
21 changes: 20 additions & 1 deletion cli/src/main/java/org/infinispan/cli/commands/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @since 11.0
**/
@MetaInfServices(Command.class)
@GroupCommandDefinition(name = "config", description = "Configuration operations", groupCommands = {Config.Set.class, Config.Get.class, Config.Convert.class})
@GroupCommandDefinition(name = "config", description = "Configuration operations", groupCommands = {Config.Set.class, Config.Get.class, Config.Reset.class, Config.Convert.class})
public class Config extends CliCommand {

@Option(shortName = 'h', hasValue = false, overrideRequired = true)
Expand Down Expand Up @@ -113,6 +113,25 @@ public CommandResult exec(ContextAwareCommandInvocation invocation) {
}
}

@CommandDefinition(name = "reset", description = "Resets all configuration properties to their default values")
public static class Reset extends CliCommand {
@Option(shortName = 'h', hasValue = false, overrideRequired = true)
protected boolean help;

@Override
public boolean isHelp() {
return help;
}

@Override
public CommandResult exec(ContextAwareCommandInvocation invocation) {
Context context = invocation.getContext();
context.resetProperties();
context.saveProperties();
return CommandResult.SUCCESS;
}
}

@CommandDefinition(name = "convert", description = "Converts configuration to different formats.", activator = ConfigConversionAvailable.class)
public static class Convert extends CliCommand {

Expand Down
5 changes: 5 additions & 0 deletions cli/src/main/java/org/infinispan/cli/impl/ContextImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ public Properties getProperties() {
return properties;
}

@Override
public void resetProperties() {
properties.clear();
}

@Override
public void saveProperties() {
Path configFile = configPath.resolve(CONFIG_FILE);
Expand Down
3 changes: 3 additions & 0 deletions cli/src/main/resources/help/config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Sets the value of a specific property. If you do not specify a value, the proper
*config get* 'name'::
Retrieves the value of a specific property.

*config reset*::
Resets all properties to their default values.

*config convert* --format=[xml|json|yaml] [-o outputFile] [inputFile]::
Converts a configuration file to a different format.

Expand Down