tweak docs; change to

This commit is contained in:
Megan Marsh 2019-12-16 21:35:42 -08:00
parent 0f6d1beccf
commit 6bc5a95c3a
2 changed files with 16 additions and 11 deletions

View File

@ -44,7 +44,7 @@ var FuncGens = map[string]interface{}{
"consul_key": funcGenConsul,
"vault": funcGenVault,
"sed": funcGenSed,
"generated": funcGenGenerated,
"build": funcGenBuild,
"replace": replace,
"replace_all": replace_all,
@ -164,7 +164,7 @@ func funcGenTemplateDir(ctx *Context) interface{} {
}
}
func funcGenGenerated(ctx *Context) interface{} {
func funcGenBuild(ctx *Context) interface{} {
return func(s string) (string, error) {
if data, ok := ctx.Data.(map[interface{}]interface{}); ok {
// PlaceholderData has been passed into generator, so if the given
@ -184,7 +184,7 @@ func funcGenGenerated(ctx *Context) interface{} {
return "", fmt.Errorf("loaded data, but couldnt find %s in it.", s)
}
return "", fmt.Errorf("Error validating computed variable: the given "+
return "", fmt.Errorf("Error validating build variable: the given "+
"variable %s will not be passed into your plugin.", s)
}
}

View File

@ -62,22 +62,27 @@ Here is a full list of the available functions for reference.
each function will behave.
- `env` - Returns environment variables. See example in [using home
variable](/docs/templates/user-variables.html#using-home-variable)
- `generated` - This engine will allow you to access special variables that
- `build` - This engine will allow you to access special variables that
provide connection information and basic instance state information.
Usage example:
```json
{
"type": "shell-local",
"environment_vars": ["TESTVAR={{ generated `PACKER_RUN_UUID`}}"],
"environment_vars": ["TESTVAR={{ build `PackerRunUUID`}}"],
"inline": ["echo $TESTVAR"]
},
```
Valid variables to request are: "ID", "Host", "Port", "User", "Password",
"ConnType", "PACKER_RUN_UUID", "SSHPublicKey", "SSHPrivateKey", and
"WinRMPassword", though obviously depending on which communicator you are
using, some of these values may be empty. ID represents the vm being
provisioned. For example, in Amazon it is the instance id; in digitalocean,
it is the droplet id; in Vmware, it is the vm name.
Valid variables to request are: "InstanceID", "CommunicatorHost",
"CommunicatorPort", "CommunicatorUser", "CommunicatorPassword", "ConnType",
"PackerRunUUID", "CommunicatorPublicKey", and "CommunicatorPrivateKey".
Depending on which communicator you are using, some of these values may be
empty -- for example, the public and private keys are unique to the SSH
communicator. InstanceID represents the vm being provisioned. For example,
in Amazon it is the instance id; in digitalocean, it is the droplet id; in
Vmware, it is the vm name.
For backwards compatability, `WinRMPassword` is also available through this
engine, though it is no different than using the more general `Password`.
This function is only for use within _provisioners_, and does not yet work
if the provisioners are being used in conjunction with our chroot builders