Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

target_map

Marcel Kloubert edited this page Jan 6, 2018 · 4 revisions

Home >> Targets >> map

map

Iterates over a list of objects that contain properties (and their values) and deploys for each of them.

The following example iterates over the objects of My FTP server (s. from).

The target writes the values of this objects to the host, user and password properties of Template for My FTP server and starts a deployment for each of them.

{
    "deploy.reloaded": {
        "targets": [
            {
                "name": "My FTP server",
                "type": "map",

                "from": [
                    {
                        "host": "ftp1.example.com",
                        
                        "user": "user1",
                        "password": "password1" 
                    },

                    "E:/data/for/ftp2/from/a/local/file.json",
                    "./data/for/ftp3/from/a/file/inside/workspace.json",
                    "https://cdn.example.com/data/for/ftp4/from/http/server.json",
                    "ftp://cdn.example.com@user:password/data/for/ftp5/from/ftp/server.json",
                    "sftp://cdn.example.com@user:password/data/for/ftp6/from/sftp/server.json",

                    {
                        "host": "ftp7.example.com",
                        
                        "user": "user7",
                        "password": "password7" 
                    }
                ],

                "targets": [ "Template for My FTP server" ]
            },

            {
                "name": "Template for My FTP server",
                "type": "ftp",
                "dir": "/home/myApp",

                "host": "NO NEED TO SET, because it is done by 'My FTP server'",
                "user": "NO NEED TO SET, because it is done by 'My FTP server'",
                "password": "NO NEED TO SET, because it is done by 'My FTP server'",

                "isHidden": true
            }
        ]
    }
}
Name Description
from A list of objects (and/or paths / URLs to JSON files, s. external sources) with properties and their values which should be written to the targets defined in targets.
targets One or more target (name) to deploy.

External sources

An external file must have the following format:

{
    //... properties with their values
}

or

[
    {
        //... properties of FIRST object
    },

    {
        //... properties of SECOND object
    }
]

Relative and local paths will be mapped to your home directory (.vscode-deploy-reloaded sub folder) or the .vscode folder.

How it works

The following TypeScript code demonstrates how the target works in general:

// iterate over "real" targets
// as defined in 'targets'
targets.forEach(currentTarget => {
    // set values
    // as defined in objects
    // of 'from'
    from.forEach(obj => {
        // clone 'currentTarget'
        // to 'clonedTarget'

        // fill properties of 'clonedTarget'
        // as defined in 'obj'
        // with 'value'
        for (let property in obj) {
            let value = obj[property];

            clonedTarget[property] = value;
        }

        // deploy 'clonedTarget'
    });
});

let numberOfExecutions = targets.length *
                         from.length;
Clone this wiki locally