Search in sources :

Example 1 with KubernetesContext

use of org.infinispan.cli.impl.KubernetesContext in project infinispan by infinispan.

the class Version method exec.

@Override
public CommandResult exec(ContextAwareCommandInvocation invocation) {
    invocation.println(String.format("CLI: %s", org.infinispan.commons.util.Version.printVersion()));
    if (invocation.getContext().isConnected()) {
        invocation.println("Server: " + invocation.getContext().getConnection().getServerVersion());
    }
    if (invocation.getContext() instanceof KubernetesContext) {
        KubernetesClient client = ((KubernetesContext) invocation.getContext()).getKubernetesClient();
        invocation.printf("Kubernetes %s.%s\n", client.getVersion().getMajor(), client.getVersion().getMinor());
    }
    return CommandResult.SUCCESS;
}
Also used : KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) KubernetesContext(org.infinispan.cli.impl.KubernetesContext)

Example 2 with KubernetesContext

use of org.infinispan.cli.impl.KubernetesContext in project infinispan by infinispan.

the class CLI method initialCommandRuntimeBuilder.

private static AeshCommandRuntimeBuilder initialCommandRuntimeBuilder(Shell shell, Properties properties, boolean kube) throws CommandRegistryException {
    AeshCommandRegistryBuilder registryBuilder = AeshCommandRegistryBuilder.builder();
    Context context;
    if (kube) {
        context = new KubernetesContext(properties);
        registryBuilder.command(Kube.class);
    } else {
        context = new ContextImpl(properties);
        registryBuilder.command(CLI.class);
    }
    AeshCommandRuntimeBuilder runtimeBuilder = AeshCommandRuntimeBuilder.builder();
    runtimeBuilder.commandActivatorProvider(new ContextAwareCommandActivatorProvider(context)).commandInvocationProvider(new ContextAwareCommandInvocationProvider(context)).commandNotFoundHandler(new CliCommandNotFoundHandler()).completerInvocationProvider(new ContextAwareCompleterInvocationProvider(context)).shell(shell).aeshContext(context).commandRegistry(registryBuilder.create());
    return runtimeBuilder;
}
Also used : KubernetesContext(org.infinispan.cli.impl.KubernetesContext) Context(org.infinispan.cli.Context) AeshCommandRegistryBuilder(org.aesh.command.impl.registry.AeshCommandRegistryBuilder) AeshCommandRuntimeBuilder(org.aesh.command.AeshCommandRuntimeBuilder) CliCommandNotFoundHandler(org.infinispan.cli.impl.CliCommandNotFoundHandler) ContextAwareCompleterInvocationProvider(org.infinispan.cli.completers.ContextAwareCompleterInvocationProvider) ContextImpl(org.infinispan.cli.impl.ContextImpl) ContextAwareCommandActivatorProvider(org.infinispan.cli.activators.ContextAwareCommandActivatorProvider) KubernetesContext(org.infinispan.cli.impl.KubernetesContext) ContextAwareCommandInvocationProvider(org.infinispan.cli.impl.ContextAwareCommandInvocationProvider)

Aggregations

KubernetesContext (org.infinispan.cli.impl.KubernetesContext)2 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)1 AeshCommandRuntimeBuilder (org.aesh.command.AeshCommandRuntimeBuilder)1 AeshCommandRegistryBuilder (org.aesh.command.impl.registry.AeshCommandRegistryBuilder)1 Context (org.infinispan.cli.Context)1 ContextAwareCommandActivatorProvider (org.infinispan.cli.activators.ContextAwareCommandActivatorProvider)1 ContextAwareCompleterInvocationProvider (org.infinispan.cli.completers.ContextAwareCompleterInvocationProvider)1 CliCommandNotFoundHandler (org.infinispan.cli.impl.CliCommandNotFoundHandler)1 ContextAwareCommandInvocationProvider (org.infinispan.cli.impl.ContextAwareCommandInvocationProvider)1 ContextImpl (org.infinispan.cli.impl.ContextImpl)1