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 16, 2017
·
18 revisions
Iterates over a list of objects that contains properties (and their values) and deploys for each of them (similar to each).
The following example iterates over the 2 objects of My SFTP server
(s. from
).
The target writes the values of its 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 SFTP server",
"type": "each",
"description": "Deploys to 'Template for My SFTP server' for each of its values.",
"from": [
{
"host": "host1.example.com",
"user": "user1",
"password": "password1"
},
{
"host": "host2.example.com",
"user": "user2",
"password": "password2"
}
],
"targets": [ "Template for My SFTP server" ]
},
{
"name": "Template for My SFTP server",
"type": "sftp",
"dir": "/home/myApp",
"host": "NO NEED TO SET, because it is done by 'My SFTP server'",
"user": "NO NEED TO SET, because it is done by 'My SFTP server'",
"password": "NO NEED TO SET, because it is done by 'My SFTP server'",
"isHidden": true
}
]
}
}
Name | Description |
---|---|
from |
A list of objects 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 |
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;