stub out generated func for validation

pull/7866/head
Megan Marsh 7 years ago
parent 7616fbcf3f
commit 528b853178

@ -48,6 +48,8 @@ func PlaceholderData() map[string]string {
placeholderData[name] = fmt.Sprintf("{{.%s}}", name)
}
placeholderData["ID"] = "{{.ID}}"
return placeholderData
}
@ -58,6 +60,7 @@ type StepProvision struct {
func PopulateProvisionHookData(state multistep.StateBag) map[string]interface{} {
hookData := map[string]interface{}{}
// Read communicator data into hook data
// state.GetOK("id")
commConf, ok := state.GetOk("communicator_config")
if !ok {
log.Printf("Unable to load config from state to populate provisionHookData")
@ -94,7 +97,6 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa
ui := state.Get("ui").(packer.Ui)
hookData := PopulateProvisionHookData(state)
log.Printf("Megan hookdata is %T", hookData)
// Run the provisioner in a goroutine so we can continually check
// for cancellations...

@ -43,6 +43,7 @@ var FuncGens = map[string]interface{}{
"consul_key": funcGenConsul,
"vault": funcGenVault,
"sed": funcGenSed,
"generated": funcGenGenerated,
"replace": replace,
"replace_all": replace_all,
@ -162,6 +163,13 @@ func funcGenTemplateDir(ctx *Context) interface{} {
}
}
func funcGenGenerated(ctx *Context) interface{} {
return func(k string) (string, error) {
// Return the key inside braces _without_ the generated func attached
return fmt.Sprintf("{{.%s}}", k), nil
}
}
func funcGenTimestamp(ctx *Context) interface{} {
return func() string {
return strconv.FormatInt(InitTime.Unix(), 10)

Loading…
Cancel
Save