MCPcopy Create free account
hub / github.com/KDE/kdevelop / setEnabled

Method setEnabled

plugins/docker/dockerruntime.cpp:82–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82void DockerRuntime::setEnabled(bool enable)
83{
84 if (enable) {
85 m_userMergedDir = KDevelop::Path(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QLatin1String("/docker-") + QString(m_tag).replace(QLatin1Char('/'), QLatin1Char('_')));
86 QDir().mkpath(m_userMergedDir.toLocalFile());
87
88 QProcess pCreateContainer;
89 pCreateContainer.start(QStringLiteral("docker"), {QStringLiteral("run"), QStringLiteral("-d"), m_tag, QStringLiteral("tail"), QStringLiteral("-f"), QStringLiteral("/dev/null")});
90 pCreateContainer.waitForFinished();
91 if (pCreateContainer.exitCode()) {
92 qCWarning(DOCKER) << "could not create the container" << pCreateContainer.readAll();
93 }
94 m_container = QString::fromUtf8(pCreateContainer.readAll().trimmed());
95
96 inspectContainer();
97
98 const QStringList cmd = {QStringLiteral("pkexec"), QStringLiteral("bindfs"), QLatin1String("--map=root/")+KUser().loginName(), m_mergedDir.toLocalFile(), m_userMergedDir.toLocalFile() };
99 QProcess p;
100 p.start(cmd.first(), cmd.mid(1));
101 p.waitForFinished();
102 if (p.exitCode()) {
103 qCDebug(DOCKER) << "bindfs returned" << cmd << p.exitCode() << p.readAll();
104 }
105 } else {
106 int codeContainer = QProcess::execute(QStringLiteral("docker"), {QStringLiteral("kill"), m_container});
107 qCDebug(DOCKER) << "docker kill returned" << codeContainer;
108
109 int code = QProcess::execute(QStringLiteral("pkexec"), {QStringLiteral("umount"), m_userMergedDir.toLocalFile()});
110 qCDebug(DOCKER) << "umount returned" << code;
111
112 m_container.clear();
113 }
114}
115
116static QString ensureEndsSlash(const QString &string)
117{

Callers 14

OutReceivedMethod · 0.45
debuggerStateChangedMethod · 0.45
updateOkStateMethod · 0.45
DisassembleWindowMethod · 0.45
contextMenuEventMethod · 0.45
enableControlsMethod · 0.45
selectionChangedMethod · 0.45
validateSelectionMethod · 0.45
enableActionsMethod · 0.45

Calls 10

executeFunction · 0.85
toLocalFileMethod · 0.80
midMethod · 0.80
PathClass · 0.50
QStringClass · 0.50
QDirClass · 0.50
replaceMethod · 0.45
startMethod · 0.45
firstMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected