summaryrefslogtreecommitdiff
path: root/lib/spack/spack/schema/env.py
blob: 91931ec90cbace470a6c131c8ce98f835adfce70 (plain) (blame)
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
# Copyright 2013-2019 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

"""Schema for env.yaml configuration file.

.. literalinclude:: _spack_root/lib/spack/spack/schema/env.py
   :lines: 36-
"""
from llnl.util.lang import union_dicts

import spack.schema.merged


schema = {
    '$schema': 'http://json-schema.org/schema#',
    'title': 'Spack environment file schema',
    'type': 'object',
    'additionalProperties': False,
    'patternProperties': {
        '^env|spack$': {
            'type': 'object',
            'default': {},
            'additionalProperties': False,
            'properties': union_dicts(
                # merged configuration scope schemas
                spack.schema.merged.properties,
                # extra environment schema properties
                {
                    'include': {
                        'type': 'array',
                        'items': {
                            'type': 'string'
                        },
                    },
                    'specs': {
                        # Specs is a list of specs, which can have
                        # optional additional properties in a sub-dict
                        'type': 'array',
                        'default': [],
                        'additionalProperties': False,
                        'items': {
                            'anyOf': [
                                {'type': 'string'},
                                {'type': 'null'},
                                {'type': 'object'},
                            ]
                        }
                    },
                    'view': {
                        'type': ['boolean', 'string']
                    }
                }
            )
        }
    }
}