{
    "additionalProperties": false,
    "definitions": {
        "attributes": {
            "additionalProperties": {
                "type": "string"
            },
            "type": "object"
        },
        "selector": {
            "additionalProperties": {
                "type": "string"
            },
            "type": "object"
        }
    },
    "description": "This schema describes the structure of the devfile object",
    "meta:license": [
        " Copyright (c) 2012-2019 Red Hat, Inc.",
        " This program and the accompanying materials are made",
        " available under the terms of the Eclipse Public License 2.0",
        " which is available at https://www.eclipse.org/legal/epl-2.0/",
        " SPDX-License-Identifier: EPL-2.0",
        " Contributors:",
        " Red Hat, Inc. - initial API and implementation"
    ],
    "properties": {
        "apiVersion": {
            "const": "1.0.0",
            "title": "Devfile API Version"
        },
        "attributes": {
            "additionalProperties": {
                "type": "string"
            },
            "editorFree": {
                "default": "false",
                "description": "Defines that no editor is needed and default one should not be provisioned. Defaults to `false`.",
                "type": "boolean"
            },
            "persistVolumes": {
                "default": "true",
                "description": "Defines whether volumes should be stored or not. Defaults to `true`. In case of `false` workspace volumes will be created as `emptyDir`. The data in the `emptyDir` volume is deleted forever when a workspace Pod is removed for any reason(pod is crashed, workspace is restarted).",
                "type": "boolean"
            },
            "type": "object"
        },
        "commands": {
            "description": "Description of the predefined commands to be available in workspace",
            "items": {
                "additionalProperties": false,
                "properties": {
                    "actions": {
                        "description": "List of the actions of given command. Now the only one command must be specified in list but there are plans to implement supporting multiple actions commands.",
                        "items": {
                            "oneOf": [
                                {
                                    "additionalProperties": false,
                                    "properties": {
                                        "command": {},
                                        "component": {},
                                        "type": {},
                                        "workdir": {}
                                    },
                                    "required": [
                                        "type",
                                        "component",
                                        "command"
                                    ]
                                },
                                {
                                    "additionalProperties": false,
                                    "anyOf": [
                                        {
                                            "additionalProperties": true,
                                            "required": [
                                                "type",
                                                "reference"
                                            ]
                                        },
                                        {
                                            "additionalProperties": true,
                                            "required": [
                                                "type",
                                                "referenceContent"
                                            ]
                                        }
                                    ],
                                    "properties": {
                                        "reference": {},
                                        "referenceContent": {},
                                        "type": {}
                                    }
                                }
                            ],
                            "properties": {
                                "command": {
                                    "description": "The actual action command-line string",
                                    "examples": [
                                        "mvn package"
                                    ],
                                    "type": "string"
                                },
                                "component": {
                                    "description": "Describes component to which given action relates",
                                    "examples": [
                                        "mvn-stack"
                                    ],
                                    "type": "string"
                                },
                                "reference": {
                                    "description": "the path relative to the location of the devfile to the configuration file defining one or more actions in the editor-specific format",
                                    "examples": [
                                        "../ide-config/launch.json"
                                    ],
                                    "type": "string"
                                },
                                "referenceContent": {
                                    "description": "The content of the referenced configuration file that defines one or more actions in the editor-specific format",
                                    "examples": [
                                        "{\"version\": \"2.0.0\",\n    \"tasks\": [\n        {\n            \"type\": \"typescript\",\n            \"tsconfig\": \"tsconfig.json\",\n            \"problemMatcher\": [\n                \"$tsc\"\n            ],\n            \"group\": {\n                \"kind\": \"build\",\n                \"isDefault\": true\n            }\n        }\n    ]}"
                                    ],
                                    "type": "string"
                                },
                                "type": {
                                    "description": "Describes action type",
                                    "examples": [
                                        "exec",
                                        "vscode-task",
                                        "vscode-launch"
                                    ],
                                    "type": "string"
                                },
                                "workdir": {
                                    "description": "Working directory where the command should be executed",
                                    "examples": [
                                        "/projects/spring-petclinic"
                                    ],
                                    "type": "string"
                                }
                            },
                            "type": "object"
                        },
                        "maxItems": 1,
                        "minItems": 1,
                        "title": "The Command Actions List",
                        "type": "array"
                    },
                    "attributes": {
                        "$ref": "#/definitions/attributes",
                        "description": "Additional command attributes"
                    },
                    "name": {
                        "description": "Describes the name of the command. Should be unique per commands set.",
                        "examples": [
                            "build"
                        ],
                        "type": "string"
                    },
                    "previewUrl": {
                        "properties": {
                            "path": {
                                "type": "string"
                            },
                            "port": {
                                "maximum": 65535,
                                "minimum": 0,
                                "type": "number"
                            }
                        },
                        "required": [
                            "port"
                        ],
                        "type": "object"
                    }
                },
                "required": [
                    "name",
                    "actions"
                ],
                "type": "object"
            },
            "title": "The Commands List",
            "type": "array"
        },
        "components": {
            "description": "Description of the workspace components, such as editor and plugins",
            "items": {
                "additionalProperties": true,
                "if": {
                    "properties": {
                        "type": {
                            "type": "string"
                        }
                    },
                    "required": [
                        "type"
                    ]
                },
                "properties": {
                    "alias": {
                        "description": "The name using which other places of this devfile (like commands) can refer to this component. This attribute is optional but must be unique in the devfile if specified.",
                        "examples": [
                            "mvn-stack"
                        ],
                        "type": "string"
                    },
                    "automountWorkspaceSecrets": {
                        "description": "Describes whether namespace secrets should be mount to the component.",
                        "type": "boolean"
                    },
                    "cpuLimit": {
                        "anyOf": [
                            {
                                "type": "string"
                            },
                            {
                                "exclusiveMinimum": 0,
                                "type": "number"
                            }
                        ],
                        "description": "Describes CPU limit for the component. You can express CPU limit as a float-point cores or as a  fixed-point integer millicores using 'm' suffix",
                        "examples": [
                            "2",
                            "0.235",
                            "100m",
                            "1230m"
                        ]
                    },
                    "cpuRequest": {
                        "anyOf": [
                            {
                                "type": "string"
                            },
                            {
                                "exclusiveMinimum": 0,
                                "type": "number"
                            }
                        ],
                        "description": "Describes CPU request for the component. You can express CPU request as a float-point cores or as a  fixed-point integer millicores using 'm' suffix",
                        "examples": [
                            "2",
                            "0.235",
                            "100m",
                            "1230m"
                        ]
                    },
                    "endpoints": {
                        "description": "Describes dockerimage component endpoints",
                        "items": {
                            "description": "Describes dockerimage component endpoint",
                            "name": "object",
                            "properties": {
                                "attributes": {
                                    "additionalProperties": {
                                        "type": "string"
                                    },
                                    "discoverable": {
                                        "default": "false",
                                        "description": "Identifies endpoint as accessible by its name.",
                                        "type": "boolean"
                                    },
                                    "javaType": "java.util.Map<String, String>",
                                    "protocol": {
                                        "description": "Defines protocol that should be used for communication with endpoint. Is used for endpoint URL evaluation",
                                        "type": "boolean"
                                    },
                                    "public": {
                                        "default": "true",
                                        "description": "Identifies endpoint as workspace internally or externally accessible.",
                                        "type": "boolean"
                                    },
                                    "secure": {
                                        "default": "false",
                                        "description": "Identifies server as secure or non-secure. Requests to secure servers will be authenticated and must contain machine token",
                                        "type": "boolean"
                                    },
                                    "type": "object"
                                },
                                "name": {
                                    "description": "The Endpoint name",
                                    "title": "The Endpoint Name",
                                    "type": "string"
                                },
                                "port": {
                                    "description": "The container port that should be used as endpoint",
                                    "title": "The Endpoint Port",
                                    "type": "integer"
                                }
                            },
                            "required": [
                                "name",
                                "port"
                            ]
                        },
                        "type": "array"
                    },
                    "env": {
                        "description": "The environment variables list that should be set to docker container",
                        "items": {
                            "description": "Describes environment variable",
                            "properties": {
                                "name": {
                                    "description": "The environment variable name",
                                    "title": "The Environment Variable Name",
                                    "type": "string"
                                },
                                "value": {
                                    "description": "The environment variable value",
                                    "title": "The Environment Variable Value",
                                    "type": "string"
                                }
                            },
                            "required": [
                                "name",
                                "value"
                            ],
                            "type": "object"
                        },
                        "type": "array"
                    },
                    "mountSources": {
                        "default": "false",
                        "description": "Describes whether projects sources should be mount to the component. `CHE_PROJECTS_ROOT` environment variable should contains a path where projects sources are mount",
                        "type": "boolean"
                    },
                    "type": {
                        "description": "Describes type of the component, e.g. whether it is an plugin or editor or other type",
                        "enum": [
                            "cheEditor",
                            "chePlugin",
                            "kubernetes",
                            "openshift",
                            "dockerimage"
                        ],
                        "examples": [
                            "chePlugin",
                            "cheEditor",
                            "kubernetes",
                            "openshift",
                            "dockerimage"
                        ]
                    },
                    "volumes": {
                        "description": "Describes volumes which should be mount to component",
                        "items": {
                            "description": "Describe volume that should be mount to component",
                            "properties": {
                                "containerPath": {
                                    "examples": [
                                        "/home/user/data"
                                    ],
                                    "title": "The path where volume should be mount to container",
                                    "type": "string"
                                },
                                "name": {
                                    "description": "The volume name. If several components mount the same volume then they will reuse the volume and will be able to access to the same files",
                                    "examples": [
                                        "my-data"
                                    ],
                                    "title": "The Volume Name",
                                    "type": "string"
                                }
                            },
                            "required": [
                                "name",
                                "containerPath"
                            ],
                            "type": "object"
                        },
                        "type": "array"
                    }
                },
                "required": [
                    "type"
                ],
                "then": {
                    "allOf": [
                        {
                            "if": {
                                "properties": {
                                    "type": {
                                        "enum": [
                                            "cheEditor",
                                            "chePlugin"
                                        ]
                                    }
                                }
                            },
                            "then": {
                                "oneOf": [
                                    {
                                        "not": {
                                            "required": [
                                                "reference"
                                            ]
                                        },
                                        "required": [
                                            "id"
                                        ]
                                    },
                                    {
                                        "not": {
                                            "required": [
                                                "id"
                                            ]
                                        },
                                        "required": [
                                            "reference"
                                        ]
                                    }
                                ],
                                "properties": {
                                    "alias": {},
                                    "id": {
                                        "description": "Describes the component id. It has the following format: {plugin/editor PUBLISHER}/{plugin/editor NAME}/{plugin/editor VERSION}",
                                        "examples": [
                                            "eclipse/maven-jdk8/1.0.0"
                                        ],
                                        "pattern": "[a-z0-9_\\-.]+/[a-z0-9_\\-.]+/[a-z0-9_\\-.]+$",
                                        "type": "string"
                                    },
                                    "memoryLimit": {
                                        "anyOf": [
                                            {
                                                "type": "string"
                                            },
                                            {
                                                "exclusiveMinimum": 0,
                                                "type": "integer"
                                            }
                                        ],
                                        "description": "Describes memory limit for the component. You can express memory as a plain integer or as a fixed-point integer using one of these suffixes: E, P, T, G, M, K. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki",
                                        "examples": [
                                            "128974848",
                                            "129e6",
                                            "129M",
                                            "123Mi"
                                        ]
                                    },
                                    "memoryRequest": {
                                        "anyOf": [
                                            {
                                                "type": "string"
                                            },
                                            {
                                                "exclusiveMinimum": 0,
                                                "type": "integer"
                                            }
                                        ],
                                        "description": "Describes memory request for the component. You can express memory as a plain integer or as a fixed-point integer using one of these suffixes: E, P, T, G, M, K. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki",
                                        "examples": [
                                            "128974848",
                                            "129e6",
                                            "129M",
                                            "123Mi"
                                        ]
                                    },
                                    "reference": {
                                        "description": "Describes raw location of plugin yaml file.",
                                        "examples": [
                                            "https://pastebin.com/raw/kYprWiNB"
                                        ],
                                        "type": "string"
                                    },
                                    "registryUrl": {
                                        "description": "Describes URL of custom plugin registry.",
                                        "examples": [
                                            "https://che-plugin-registry.openshift.io/v3/"
                                        ],
                                        "pattern": "^(https?://)[a-zA-Z0-9_\\-./]+",
                                        "type": "string"
                                    },
                                    "type": {}
                                }
                            }
                        },
                        {
                            "if": {
                                "properties": {
                                    "type": {
                                        "enum": [
                                            "cheEditor"
                                        ]
                                    }
                                }
                            },
                            "then": {
                                "additionalProperties": false,
                                "properties": {
                                    "alias": {},
                                    "automountWorkspaceSecrets": {},
                                    "cpuLimit": {},
                                    "cpuRequest": {},
                                    "endpoints": {},
                                    "env": {},
                                    "id": {},
                                    "memoryLimit": {},
                                    "memoryRequest": {},
                                    "reference": {},
                                    "registryUrl": {},
                                    "type": {},
                                    "volumes": {}
                                }
                            }
                        },
                        {
                            "if": {
                                "properties": {
                                    "type": {
                                        "enum": [
                                            "chePlugin"
                                        ]
                                    }
                                }
                            },
                            "then": {
                                "additionalProperties": false,
                                "properties": {
                                    "alias": {},
                                    "automountWorkspaceSecrets": {},
                                    "cpuLimit": {},
                                    "cpuRequest": {},
                                    "endpoints": {},
                                    "env": {},
                                    "id": {},
                                    "memoryLimit": {},
                                    "memoryRequest": {},
                                    "preferences": {
                                        "additionalProperties": {
                                            "anyOf": [
                                                {
                                                    "type": [
                                                        "boolean",
                                                        "string",
                                                        "number"
                                                    ]
                                                },
                                                {
                                                    "items": {
                                                        "type": [
                                                            "boolean",
                                                            "string",
                                                            "number"
                                                        ]
                                                    },
                                                    "type": "array"
                                                }
                                            ]
                                        },
                                        "description": "Additional plugin preferences",
                                        "examples": [
                                            "{\"java.home\": \"/home/user/jdk11\", \"java.jdt.ls.vmargs\": \"-Xmx1G\"}"
                                        ],
                                        "type": "object"
                                    },
                                    "reference": {},
                                    "registryUrl": {},
                                    "type": {},
                                    "volumes": {}
                                }
                            }
                        },
                        {
                            "if": {
                                "properties": {
                                    "type": {
                                        "enum": [
                                            "kubernetes",
                                            "openshift"
                                        ]
                                    }
                                }
                            },
                            "then": {
                                "additionalProperties": false,
                                "anyOf": [
                                    {
                                        "additionalProperties": true,
                                        "required": [
                                            "reference"
                                        ]
                                    },
                                    {
                                        "additionalProperties": true,
                                        "required": [
                                            "referenceContent"
                                        ]
                                    }
                                ],
                                "properties": {
                                    "alias": {},
                                    "automountWorkspaceSecrets": {},
                                    "endpoints": {},
                                    "entrypoints": {
                                        "items": {
                                            "properties": {
                                                "args": {
                                                    "default": null,
                                                    "description": "The arguments to supply to the command running the component. The arguments are supplied either to the default command provided in the image of the container or to the overridden command. Defaults to null, meaning use whatever is defined in the image.",
                                                    "examples": [
                                                        "['-R', '-f']"
                                                    ],
                                                    "items": {
                                                        "type": "string"
                                                    },
                                                    "type": "array"
                                                },
                                                "command": {
                                                    "default": null,
                                                    "description": "The command to run in the component instead of the default one provided in the image of the container. Defaults to null, meaning use whatever is defined in the image.",
                                                    "examples": [
                                                        "['/bin/sh', '-c']"
                                                    ],
                                                    "items": {
                                                        "type": "string"
                                                    },
                                                    "type": "array"
                                                },
                                                "containerName": {
                                                    "description": "The name of the container to apply the entrypoint to. If not specified, the entrypoint is modified on all matching containers.",
                                                    "type": "string"
                                                },
                                                "parentName": {
                                                    "description": "The name of the top level object in the referenced object list in which to search for containers. If not specified, the objects to search through can have any name.",
                                                    "type": "string"
                                                },
                                                "parentSelector": {
                                                    "$ref": "#/definitions/selector",
                                                    "description": "The selector on labels of the top level objects in the referenced list in which to search for containers. If not specified, the objects to search through can have any labels."
                                                }
                                            },
                                            "type": "object"
                                        },
                                        "type": "array"
                                    },
                                    "env": {},
                                    "mountSources": {},
                                    "reference": {
                                        "description": "Describes absolute or devfile-relative location of Kubernetes list yaml file. Applicable only for 'kubernetes' and 'openshift' type components",
                                        "examples": [
                                            "petclinic-app.yaml"
                                        ],
                                        "type": "string"
                                    },
                                    "referenceContent": {
                                        "description": "Inlined content of a file specified in field 'reference'",
                                        "examples": [
                                            "{\"kind\":\"List\",\"items\":[{\"apiVersion\":\"v1\",\"kind\":\"Pod\",\"metadata\":{\"name\":\"ws\"},\"spec\":{\"containers\":[{\"image\":\"quay.io/eclipse/che-dev:nightly\"}]}}]}"
                                        ],
                                        "type": "string"
                                    },
                                    "selector": {
                                        "$ref": "#/definitions/selector",
                                        "description": "Describes the objects selector for the recipe type components. Allows to pick-up only selected items from k8s/openshift list",
                                        "examples": [
                                            "{\n   \"app.kubernetes.io/name\" : \"mysql\", \n   \"app.kubernetes.io/component\" : \"database\", \n   \"app.kubernetes.io/part-of\" : \"petclinic\" \n}"
                                        ]
                                    },
                                    "type": {},
                                    "volumes": {}
                                }
                            }
                        },
                        {
                            "if": {
                                "properties": {
                                    "type": {
                                        "enum": [
                                            "dockerimage"
                                        ]
                                    }
                                }
                            },
                            "then": {
                                "additionalProperties": false,
                                "properties": {
                                    "alias": {},
                                    "args": {
                                        "default": null,
                                        "description": "The arguments to supply to the command running the dockerimage component. The arguments are supplied either to the default command provided in the image or to the overridden command. Defaults to null, meaning use whatever is defined in the image.",
                                        "examples": [
                                            "['-R', '-f']"
                                        ],
                                        "items": {
                                            "type": "string"
                                        },
                                        "type": "array"
                                    },
                                    "automountWorkspaceSecrets": {},
                                    "command": {
                                        "default": null,
                                        "description": "The command to run in the dockerimage component instead of the default one provided in the image. Defaults to null, meaning use whatever is defined in the image.",
                                        "examples": [
                                            "['/bin/sh', '-c']"
                                        ],
                                        "items": {
                                            "type": "string"
                                        },
                                        "type": "array"
                                    },
                                    "cpuLimit": {},
                                    "cpuRequest": {},
                                    "endpoints": {},
                                    "env": {},
                                    "image": {
                                        "description": "Specifies the docker image that should be used for component",
                                        "examples": [
                                            "eclipse/maven-jdk8:1.0.0"
                                        ],
                                        "type": "string"
                                    },
                                    "memoryLimit": {
                                        "anyOf": [
                                            {
                                                "type": "string"
                                            },
                                            {
                                                "exclusiveMinimum": 0,
                                                "type": "integer"
                                            }
                                        ],
                                        "description": "Describes memory limit for the component. You can express memory as a plain integer or as a fixed-point integer using one of these suffixes: E, P, T, G, M, K. You can also use the power-of-two equivalents: Ei, Pi, Ti, Gi, Mi, Ki",
                                        "examples": [
                                            "128974848",
                                            "129e6",
                                            "129M",
                                            "123Mi"
                                        ]
                                    },
                                    "mountSources": {},
                                    "type": {},
                                    "volumes": {}
                                },
                                "required": [
                                    "image",
                                    "memoryLimit"
                                ]
                            }
                        }
                    ]
                },
                "type": "object"
            },
            "title": "The Components List",
            "type": "array"
        },
        "metadata": {
            "additionalProperties": false,
            "anyOf": [
                {
                    "required": [
                        "name"
                    ]
                },
                {
                    "required": [
                        "generateName"
                    ]
                }
            ],
            "properties": {
                "generateName": {
                    "description": "Workspaces created from devfile, will use it as base and append random suffix. It's used when name is not defined.",
                    "examples": [
                        "petclinic-"
                    ],
                    "minLength": 1,
                    "title": "Devfile Generate Name",
                    "type": "string"
                },
                "name": {
                    "description": "The name of the devfile. Workspaces created from devfile, will inherit this name",
                    "examples": [
                        "petclinic-dev-environment"
                    ],
                    "minLength": 1,
                    "title": "Devfile Name",
                    "type": "string"
                }
            },
            "type": "object"
        },
        "projects": {
            "description": "Description of the projects, containing names and sources locations",
            "items": {
                "additionalProperties": false,
                "properties": {
                    "clonePath": {
                        "description": "The path relative to the root of the projects to which this project should be cloned into. This is a unix-style relative path (i.e. uses forward slashes). The path is invalid if it is absolute or tries to escape the project root through the usage of '..'. If not specified, defaults to the project name.",
                        "type": "string"
                    },
                    "name": {
                        "examples": [
                            "petclinic"
                        ],
                        "title": "The Project Name",
                        "type": "string"
                    },
                    "source": {
                        "description": "Describes the project's source - type and location",
                        "properties": {
                            "branch": {
                                "description": "The name of the of the branch to check out after obtaining the source from the location. The branch has to already exist in the source otherwise the default branch is used. In case of git, this is also the name of the remote branch to push to.",
                                "examples": [
                                    "master",
                                    "feature-42"
                                ],
                                "type": "string"
                            },
                            "commitId": {
                                "description": "The id of the commit to reset the checked out branch to. Note that this is equivalent to 'startPoint' and provided for convenience.",
                                "examples": [
                                    "349d3ad"
                                ],
                                "type": "string"
                            },
                            "location": {
                                "description": "Project's source location address. Should be URL for git and github located projects, or file:// for zip.",
                                "examples": [
                                    "git@github.com:spring-projects/spring-petclinic.git"
                                ],
                                "type": "string"
                            },
                            "sparseCheckoutDir": {
                                "description": "Part of project to populate in the working directory.",
                                "examples": [
                                    "/core/",
                                    "core/",
                                    "core",
                                    "/wsmaster/che-core-api-workspace/",
                                    "/d*"
                                ],
                                "type": "string"
                            },
                            "startPoint": {
                                "description": "The tag or commit id to reset the checked out branch to.",
                                "examples": [
                                    "release/4.2",
                                    "349d3ad",
                                    "v4.2.0"
                                ],
                                "type": "string"
                            },
                            "tag": {
                                "description": "The name of the tag to reset the checked out branch to. Note that this is equivalent to 'startPoint' and provided for convenience.",
                                "examples": [
                                    "v4.2.0"
                                ],
                                "type": "string"
                            },
                            "type": {
                                "description": "Project's source type.",
                                "examples": [
                                    "git",
                                    "github",
                                    "zip"
                                ],
                                "type": "string"
                            }
                        },
                        "required": [
                            "type",
                            "location"
                        ],
                        "title": "The Project Source object",
                        "type": "object"
                    }
                },
                "required": [
                    "name",
                    "source"
                ],
                "type": "object"
            },
            "title": "The Projects List",
            "type": "array"
        }
    },
    "required": [
        "apiVersion",
        "metadata"
    ],
    "title": "Devfile object",
    "type": "object"
}