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:
|
2021-05-31 13:01:49 +02:00
|
|
|
QString id() const { return "docker:" + imageId; }
|
|
|
|
|
|
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;
|
2021-06-29 12:12:59 +02:00
|
|
|
QStringList mounts = {"/opt", "/data"};
|
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;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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-04-29 07:36:34 +02:00
|
|
|
QList<Utils::FilePath> directoryEntries(const Utils::FilePath &filePath,
|
|
|
|
|
const QStringList &nameFilters,
|
2021-06-29 11:10:27 +02:00
|
|
|
QDir::Filters filters,
|
|
|
|
|
QDir::SortFlags sort) const override;
|
2021-04-29 07:36:34 +02:00
|
|
|
QByteArray fileContents(const Utils::FilePath &filePath, int limit) 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-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
|
|
|
|
2021-04-29 07:36:34 +02:00
|
|
|
void tryCreateLocalFileAccess() const;
|
|
|
|
|
bool hasLocalFileAccess() const;
|
2021-03-29 09:11:36 +02:00
|
|
|
|
2021-04-29 07:36:34 +02:00
|
|
|
Utils::FilePath mapToLocalAccess(const Utils::FilePath &filePath) const;
|
|
|
|
|
Utils::FilePath mapFromLocalAccess(const Utils::FilePath &filePath) const;
|
|
|
|
|
Utils::FilePath mapFromLocalAccess(const QString &filePath) const;
|
|
|
|
|
|
|
|
|
|
private:
|
2021-03-29 09:11:36 +02:00
|
|
|
void fromMap(const QVariantMap &map) final;
|
|
|
|
|
QVariantMap toMap() const final;
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
void autoDetect(const QString &sharedId) const;
|
|
|
|
|
void undoAutoDetect(const QString &sharedId) const;
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::IDevice::Ptr create() const override;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // Docker
|
|
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(Docker::Internal::DockerDeviceData)
|