mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-05-19 05:45:58 -04:00
Fixes
This commit is contained in:
@@ -19,6 +19,7 @@ public class ContainerStoreState extends ShellStoreState {
|
||||
|
||||
String imageName;
|
||||
String containerState;
|
||||
Boolean shellMissing;
|
||||
|
||||
@Override
|
||||
public DataStoreState mergeCopy(DataStoreState newer) {
|
||||
@@ -32,5 +33,6 @@ public class ContainerStoreState extends ShellStoreState {
|
||||
super.mergeBuilder(css, b);
|
||||
b.containerState(useNewer(containerState, css.getContainerState()));
|
||||
b.imageName(useNewer(imageName, css.getImageName()));
|
||||
b.shellMissing(useNewer(shellMissing, css.getShellMissing()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import lombok.Value;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Value
|
||||
public class ShellStoreFormat {
|
||||
@@ -35,7 +36,7 @@ public class ShellStoreFormat {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T extends ShellStoreState> ObservableValue<String> shellStore(
|
||||
StoreSection section, Function<T, String> f) {
|
||||
StoreSection section, Function<T, String[]> f) {
|
||||
return BindingsHelper.map(section.getWrapper().getPersistentState(), o -> {
|
||||
var s = (T) o;
|
||||
var info = f.apply(s);
|
||||
@@ -61,11 +62,11 @@ public class ShellStoreFormat {
|
||||
.format();
|
||||
}
|
||||
|
||||
var joined = Stream.concat(Stream.of(s.getTtyState() != null && s.getTtyState() != ShellTtyState.NONE ? "TTY" : null), Arrays.stream(info)).toArray(String[]::new);
|
||||
return new ShellStoreFormat(
|
||||
LicenseProvider.get().checkOsName(s.getOsName()),
|
||||
formattedOsName(s.getOsName()),
|
||||
s.getTtyState() != null && s.getTtyState() != ShellTtyState.NONE ? "TTY" : null,
|
||||
info)
|
||||
joined)
|
||||
.format();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -83,8 +83,9 @@ public class IncusContainerStoreProvider implements ShellStoreProvider {
|
||||
|
||||
@Override
|
||||
public ObservableValue<String> informationString(StoreSection section) {
|
||||
return ShellStoreFormat.shellStore(
|
||||
section, (ContainerStoreState s) -> DataStoreFormatter.capitalize(s.getContainerState()));
|
||||
var c = (ContainerStoreState) section.getWrapper().getPersistentState().getValue();
|
||||
var missing = c.getShellMissing() != null && c.getShellMissing() ? "No shell available" : null;
|
||||
return ShellStoreFormat.shellStore(section, (ContainerStoreState s) -> new String[] {missing, s.getContainerState()});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -80,8 +80,9 @@ public class LxdContainerStoreProvider implements ShellStoreProvider {
|
||||
|
||||
@Override
|
||||
public ObservableValue<String> informationString(StoreSection section) {
|
||||
return ShellStoreFormat.shellStore(
|
||||
section, (ContainerStoreState s) -> DataStoreFormatter.capitalize(s.getContainerState()));
|
||||
var c = (ContainerStoreState) section.getWrapper().getPersistentState().getValue();
|
||||
var missing = c.getShellMissing() != null && c.getShellMissing() ? "No shell available" : null;
|
||||
return ShellStoreFormat.shellStore(section, (ContainerStoreState s) -> new String[] {missing, s.getContainerState()});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -155,16 +155,13 @@ public class PodmanContainerStore
|
||||
return;
|
||||
}
|
||||
|
||||
var stateBuilder = getState().toBuilder();
|
||||
stateBuilder.running(false);
|
||||
var hasShell = throwable.getMessage() == null
|
||||
|| !throwable.getMessage().contains("OCI runtime exec failed");
|
||||
if (!hasShell) {
|
||||
stateBuilder.containerState("No shell available");
|
||||
} else {
|
||||
stateBuilder.containerState("Connection failed");
|
||||
var stateBuilder = getState().toBuilder();
|
||||
stateBuilder.shellMissing(true);
|
||||
setState(stateBuilder.build());
|
||||
}
|
||||
setState(stateBuilder.build());
|
||||
});
|
||||
return pc;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,9 @@ public class PodmanContainerStoreProvider implements ShellStoreProvider {
|
||||
|
||||
@Override
|
||||
public ObservableValue<String> informationString(StoreSection section) {
|
||||
return ShellStoreFormat.shellStore(section, (ContainerStoreState s) -> s.getContainerState());
|
||||
var c = (ContainerStoreState) section.getWrapper().getPersistentState().getValue();
|
||||
var missing = c.getShellMissing() != null && c.getShellMissing() ? "No shell available" : null;
|
||||
return ShellStoreFormat.shellStore(section, (ContainerStoreState s) -> new String[] {missing, s.getContainerState()});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user