Docker: Show create command line to user

Change-Id: I740d2647e2033c841fe6926b273b06ce45ecb0e7
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-09-19 13:21:35 +02:00
parent 493d1873d2
commit d3f060a754
3 changed files with 51 additions and 24 deletions

View File

@@ -278,6 +278,8 @@ public:
~DockerDevicePrivate() { stopCurrentContainer(); }
CommandLine createCommandLine();
RunResult runInShell(const CommandLine &cmd, const QByteArray &stdInData = {});
bool updateContainerAccess();
@@ -501,6 +503,11 @@ void DockerProcessImpl::sendControlSignal(ControlSignal controlSignal)
}
}
CommandLine DockerDevice::createCommandLine() const
{
return d->createCommandLine();
}
IDeviceWidget *DockerDevice::createWidget()
{
return new DockerDeviceWidget(sharedFromThis());
@@ -783,11 +790,8 @@ bool DockerDevicePrivate::isImageAvailable() const
return false;
}
expected_str<QString> DockerDevicePrivate::createContainer()
CommandLine DockerDevicePrivate::createCommandLine()
{
if (!isImageAvailable())
return make_unexpected(Tr::tr("Image \"%1\" is not available.").arg(repoAndTag()));
const QString display = HostOsInfo::isLinuxHost() ? QString(":0")
: QString("host.docker.internal:0");
CommandLine dockerCreate{settings().dockerBinaryPath(),
@@ -822,9 +826,19 @@ expected_str<QString> DockerDevicePrivate::createContainer()
dockerCreate.addArg(deviceSettings->repoAndTag());
qCDebug(dockerDeviceLog).noquote() << "RUNNING: " << dockerCreate.toUserOutput();
return dockerCreate;
}
expected_str<QString> DockerDevicePrivate::createContainer()
{
if (!isImageAvailable())
return make_unexpected(Tr::tr("Image \"%1\" is not available.").arg(repoAndTag()));
const CommandLine cmdLine = createCommandLine();
qCDebug(dockerDeviceLog).noquote() << "RUNNING: " << cmdLine.toUserOutput();
Process createProcess;
createProcess.setCommand(dockerCreate);
createProcess.setCommand(cmdLine);
createProcess.runBlocking();
if (createProcess.result() != ProcessResult::FinishedWithSuccess) {