2021-03-29 09:11:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2021 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/devicesupport/idevice.h>
|
|
|
|
|
#include <projectexplorer/devicesupport/idevicefactory.h>
|
|
|
|
|
#include <projectexplorer/devicesupport/sshdeviceprocess.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/aspects.h>
|
|
|
|
|
|
|
|
|
|
namespace Docker {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class DockerDeviceData
|
|
|
|
|
{
|
|
|
|
|
public:
|
2022-02-24 10:14:25 +01:00
|
|
|
// Used for "docker run"
|
|
|
|
|
QString repoAndTag() const;
|
2021-05-31 13:01:49 +02:00
|
|
|
|
2021-03-29 09:11:36 +02:00
|
|
|
QString imageId;
|
|
|
|
|
QString repo;
|
|
|
|
|
QString tag;
|
|
|
|
|
QString size;
|
2021-06-29 10:47:48 +02:00
|
|
|
bool useLocalUidGid = true;
|
2022-01-11 14:40:03 +01:00
|
|
|
bool useFilePathMapping = false;
|
2021-07-09 13:45:19 +02:00
|
|
|
QStringList mounts;
|
2021-03-29 09:11:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class DockerDevice : public ProjectExplorer::IDevice
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(Docker::Internal::DockerDevice)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
using Ptr = QSharedPointer<DockerDevice>;
|
|
|
|
|
using ConstPtr = QSharedPointer<const DockerDevice>;
|
|
|
|
|
|
2021-04-29 07:36:34 +02:00
|
|
|
explicit DockerDevice(const DockerDeviceData &data);
|
2021-03-29 09:11:36 +02:00
|
|
|
~DockerDevice();
|
2021-04-29 07:36:34 +02:00
|
|
|
|
2021-03-29 09:11:36 +02:00
|
|
|
static Ptr create(const DockerDeviceData &data) { return Ptr(new DockerDevice(data)); }
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::IDeviceWidget *createWidget() override;
|
2022-01-26 13:02:49 +01:00
|
|
|
QList<ProjectExplorer::Task> validate() const override;
|
2021-03-29 09:11:36 +02:00
|
|
|
|
|
|
|
|
bool canCreateProcess() const override { return true; }
|
|
|
|
|
ProjectExplorer::DeviceProcess *createProcess(QObject *parent) const override;
|
|
|
|
|
bool canAutoDetectPorts() const override;
|
|
|
|
|
ProjectExplorer::PortsGatheringMethod::Ptr portsGatheringMethod() const override;
|
|
|
|
|
bool canCreateProcessModel() const override { return false; }
|
|
|
|
|
ProjectExplorer::DeviceProcessList *createProcessListModel(QObject *parent) const override;
|
|
|
|
|
bool hasDeviceTester() const override { return false; }
|
|
|
|
|
ProjectExplorer::DeviceTester *createDeviceTester() const override;
|
|
|
|
|
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
|
|
|
|
ProjectExplorer::DeviceEnvironmentFetcher::Ptr environmentFetcher() const override;
|
|
|
|
|
|
2021-04-29 07:36:34 +02:00
|
|
|
Utils::FilePath mapToGlobalPath(const Utils::FilePath &pathOnDevice) const override;
|
2021-10-08 10:31:30 +02:00
|
|
|
QString mapToDevicePath(const Utils::FilePath &globalPath) const override;
|
2021-04-29 07:36:34 +02:00
|
|
|
|
|
|
|
|
bool handlesFile(const Utils::FilePath &filePath) const override;
|
|
|
|
|
bool isExecutableFile(const Utils::FilePath &filePath) const override;
|
|
|
|
|
bool isReadableFile(const Utils::FilePath &filePath) const override;
|
2021-06-22 07:09:00 +02:00
|
|
|
bool isWritableFile(const Utils::FilePath &filePath) const override;
|
2021-04-29 07:36:34 +02:00
|
|
|
bool isReadableDirectory(const Utils::FilePath &filePath) const override;
|
|
|
|
|
bool isWritableDirectory(const Utils::FilePath &filePath) const override;
|
2021-07-14 07:41:23 +02:00
|
|
|
bool isFile(const Utils::FilePath &filePath) const override;
|
|
|
|
|
bool isDirectory(const Utils::FilePath &filePath) const override;
|
2021-04-29 07:36:34 +02:00
|
|
|
bool createDirectory(const Utils::FilePath &filePath) const override;
|
2021-06-01 09:40:17 +02:00
|
|
|
bool exists(const Utils::FilePath &filePath) const override;
|
2021-06-29 09:41:53 +02:00
|
|
|
bool ensureExistingFile(const Utils::FilePath &filePath) const override;
|
2021-06-14 08:33:44 +02:00
|
|
|
bool removeFile(const Utils::FilePath &filePath) const override;
|
2021-06-28 15:26:44 +02:00
|
|
|
bool removeRecursively(const Utils::FilePath &filePath) const override;
|
2021-06-14 08:33:44 +02:00
|
|
|
bool copyFile(const Utils::FilePath &filePath, const Utils::FilePath &target) const override;
|
2021-06-28 13:57:10 +02:00
|
|
|
bool renameFile(const Utils::FilePath &filePath, const Utils::FilePath &target) const override;
|
2021-06-29 15:57:41 +02:00
|
|
|
Utils::FilePath symLinkTarget(const Utils::FilePath &filePath) const override;
|
2021-12-14 12:15:40 +01:00
|
|
|
void iterateDirectory(const Utils::FilePath &filePath,
|
|
|
|
|
const std::function<bool(const Utils::FilePath &)> &callBack,
|
2022-01-21 12:22:54 +01:00
|
|
|
const Utils::FileFilter &filter) const override;
|
2021-07-09 08:30:11 +02:00
|
|
|
QByteArray fileContents(const Utils::FilePath &filePath, qint64 limit, qint64 offset) const override;
|
2021-06-15 18:29:51 +02:00
|
|
|
bool writeFileContents(const Utils::FilePath &filePath, const QByteArray &data) const override;
|
2021-06-14 08:33:44 +02:00
|
|
|
QDateTime lastModified(const Utils::FilePath &filePath) const override;
|
2021-04-29 07:36:34 +02:00
|
|
|
void runProcess(Utils::QtcProcess &process) const override;
|
2021-07-23 12:06:38 +02:00
|
|
|
qint64 fileSize(const Utils::FilePath &filePath) const override;
|
2021-07-23 17:55:25 +02:00
|
|
|
QFileDevice::Permissions permissions(const Utils::FilePath &filePath) const override;
|
2021-08-12 10:29:18 +02:00
|
|
|
bool setPermissions(const Utils::FilePath &filePath, QFileDevice::Permissions permissions) const override;
|
2021-04-29 07:36:34 +02:00
|
|
|
|
2021-05-26 17:18:40 +02:00
|
|
|
Utils::Environment systemEnvironment() const override;
|
|
|
|
|
|
2021-03-29 09:11:36 +02:00
|
|
|
const DockerDeviceData &data() const;
|
2021-06-29 12:12:59 +02:00
|
|
|
DockerDeviceData &data();
|
2021-03-29 09:11:36 +02:00
|
|
|
|
2022-01-11 15:57:21 +01:00
|
|
|
void updateContainerAccess() const;
|
2021-07-09 13:18:22 +02:00
|
|
|
void setMounts(const QStringList &mounts) const;
|
2021-03-29 09:11:36 +02:00
|
|
|
|
2021-12-08 12:39:22 +01:00
|
|
|
protected:
|
|
|
|
|
void fromMap(const QVariantMap &map) final;
|
|
|
|
|
QVariantMap toMap() const final;
|
|
|
|
|
|
2021-04-29 07:36:34 +02:00
|
|
|
private:
|
2021-12-14 12:15:40 +01:00
|
|
|
void iterateWithFind(const Utils::FilePath &filePath,
|
|
|
|
|
const std::function<bool(const Utils::FilePath &)> &callBack,
|
2022-01-21 12:22:54 +01:00
|
|
|
const Utils::FileFilter &filter) const;
|
2021-03-29 09:11:36 +02:00
|
|
|
|
2021-05-31 13:01:49 +02:00
|
|
|
void aboutToBeRemoved() const final;
|
|
|
|
|
|
2021-04-29 07:36:34 +02:00
|
|
|
class DockerDevicePrivate *d = nullptr;
|
2021-05-18 06:16:25 +02:00
|
|
|
friend class DockerDeviceSetupWizard;
|
2021-05-31 10:10:53 +02:00
|
|
|
friend class DockerDeviceWidget;
|
2021-03-29 09:11:36 +02:00
|
|
|
};
|
|
|
|
|
|
2021-07-01 17:59:15 +02:00
|
|
|
class KitDetector : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit KitDetector(const ProjectExplorer::IDevice::ConstPtr &device);
|
|
|
|
|
~KitDetector() override;
|
|
|
|
|
|
2021-12-03 10:21:57 +01:00
|
|
|
void autoDetect(const QString &sharedId, const Utils::FilePaths &selectedPaths) const;
|
2021-07-01 17:59:15 +02:00
|
|
|
void undoAutoDetect(const QString &sharedId) const;
|
2021-07-15 12:25:23 +02:00
|
|
|
void listAutoDetected(const QString &sharedId) const;
|
2021-07-01 17:59:15 +02:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void logOutput(const QString &msg);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
class KitDetectorPrivate *d = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-29 09:11:36 +02:00
|
|
|
class DockerDeviceFactory final : public ProjectExplorer::IDeviceFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
DockerDeviceFactory();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // Docker
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Docker::Internal::DockerDeviceData)
|