summaryrefslogtreecommitdiff
path: root/yaml-to-json.py
blob: 5cf9d981afb32a31b01d619a8112b17953567a4a (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
#!/usr/bin/python

import json
import os
import string
import sys
import yaml


def main():
    with open(sys.argv[1]) as f:
        template = string.Template(f.read())

    lava_template = template.safe_substitute(
        BOOT_URL=os.environ.get('BOOT_URL'),
        BUILD_NUMBER=os.environ.get('BUILD_NUMBER'),
        BUILD_URL=os.environ.get('BUILD_URL'),
        BUNDLE_STREAM_NAME=os.environ.get('BUNDLE_STREAM_NAME'),
        DATA_URL=os.environ.get('DATA_URL'),
        DEVICE_TYPE=os.environ.get('DEVICE_TYPE'),
        DTB=os.environ.get('DTB'),
        DTB_URL=os.environ.get('DTB_URL'),
        GIT_BRANCH=os.environ.get('GIT_BRANCH'),
        GIT_COMMIT=os.environ.get('GIT_COMMIT'),
        GIT_URL=os.environ.get('GIT_URL'),
        HWPACK_BUILD_URL=os.environ.get('HWPACK_BUILD_URL'),
        IMAGE_URL=os.environ.get('IMAGE_URL'),
        KERNEL=os.environ.get('KERNEL'),
        KERNEL_URL=os.environ.get('KERNEL_URL'),
        LAVA_SERVER=os.environ.get('LAVA_SERVER'),
        ROOTFS_BUILD_NUMBER=os.environ.get('ROOTFS_BUILD_NUMBER'),
        ROOTFS_BUILD_URL=os.environ.get('ROOTFS_BUILD_URL'),
        STARTUP_NSH=os.environ.get('STARTUP_NSH'),
        SYSTEM_URL=os.environ.get('SYSTEM_URL'),
        defconfig=os.environ.get('defconfig'),
        hwpack_type=os.environ.get('hwpack_type'),
        kernel_config=os.environ.get('kernel_config'),
    )

    config = json.dumps(yaml.safe_load(lava_template), indent=2)
    print config


if __name__ == '__main__':
    main()