This repository has been archived by the owner on Jul 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
target_map
Marcel Kloubert edited this page Apr 18, 2017
·
18 revisions
Iterates over a list of objects that contain properties (and their values) and deploys for each of them (similar to each).
The following example iterates over the objects of My SFTP server
(s. from
).
The target writes the values of this objects to the host
, user
and password
properties of Template for My SFTP server
and starts a deployment for each of them.
{
"deploy": {
"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) with properties and their values which should be written to the targets defined in targets . |
targets |
One or more target (name) to deploy. |
usePlaceholders |
Use [[placeholders |
An external file must have the following format:
{
//... properties with their values
}
or
"<SOURCE OF A NESTED FILE WITH DATA>"
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;