aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/devcontainer/devcontainerfeature.h
blob: 5d9420fd2d560d840a114d50ebfc55361c25f2b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "devcontainer_global.h"
#include "devcontainerconfig.h"

#include <utils/result.h>

#include <QJsonObject>

namespace DevContainer {

struct DEVCONTAINER_EXPORT FeatureOption
{
    static FeatureOption fromJson(
        const QJsonObject &obj, const JsonStringToString &jsonStringToString);

    QString type;
    QVariant defaultValue;
    QString description;
    QStringList enumValues;
    QStringList proposals;
};

struct DEVCONTAINER_EXPORT Feature
{
    static Utils::Result<Feature> fromJson(
        const QJsonObject &obj, const JsonStringToString &jsonStringToString);

    static Utils::Result<Feature> fromJson(
        const QByteArray &data, const JsonStringToString &jsonStringToString);

    // Identification fields
    QString id;
    QStringList legacyIds;
    QString version;

    // Meta data fields
    QString description;
    QString documentationURL;
    QString licenseURL;
    QString name;
    QStringList keywords;
    bool deprecated = false;

    // Fields that are added / merged onto the container config
    QString entrypoint;
    QStringList capAdd;
    QStringList securityOpt;
    std::map<QString, QString> containerEnv;
    QJsonObject customizations;
    std::vector<std::variant<Mount, QString>> mounts;

    bool init = false;
    bool privileged = false;

    std::optional<Command> onCreateCommand;
    std::optional<Command> updateContentCommand;
    std::optional<Command> postCreateCommand;
    std::optional<Command> postStartCommand;
    std::optional<Command> postAttachCommand;

    // Installation order fields (https://containers.dev/implementors/features/#installation-order)
    QStringList installsAfter;
    QList<FeatureDependency> dependsOn;

    // Options for the feature (https://containers.dev/implementors/features/#options-property)
    QMap<QString, FeatureOption> options;
};

DEVCONTAINER_EXPORT QJsonObject mergeCustomizations(QJsonObject left, const QJsonObject &right);

} // namespace DevContainer