func (p *Provisioner) Prepare(raws ...interface{}) error {
	p.done = make(chan struct{})

	// Create passthrough for winrm password so we can fill it in once we know
	// it
	p.config.ctx.Data = &PassthroughTemplate{
		WinRMPassword: `{{.WinRMPassword}}`,
	}

	err := config.Decode(&p.config, &config.DecodeOpts{
		Interpolate:        true,
		InterpolateContext: &p.config.ctx,
		InterpolateFilter: &interpolate.RenderFilter{
			Exclude: []string{},
		},
	}, raws...)
	if err != nil {
		return err
	}

	var errs *packer.MultiError

	// Defaults
	if p.config.Command == "" {
		p.config.Command = "bolt"
	}

	// Validate that a bolt task or bolt plan is specified
	if p.config.BoltTask == "" && p.config.BoltPlan == "" {
		errs = packer.MultiErrorAppend(errs, fmt.Errorf("A bolt task or bolt plan must be specified"))
	}

	// Validate that both a bolt plan and task are not specified at the same time
	if p.config.BoltTask != "" && p.config.BoltPlan != "" {
		errs = packer.MultiErrorAppend(errs, fmt.Errorf("A bolt task and bolt plan cannot be specified at the same time"))
	}

	if len(p.config.BoltModulePath) > 0 {
		err = validateModuleDirectoryConfig(p.config.BoltModulePath)
		if err != nil {
			log.Println(p.config.BoltModulePath, "does not exist")
			errs = packer.MultiErrorAppend(errs, err)
		}
	}

	if !p.config.SkipVersionCheck {
		err = p.getVersion()
		if err != nil {
			errs = packer.MultiErrorAppend(errs, err)
		}
	}

	if p.config.User == "" {
		usr, err := user.Current()
		if err != nil {
			errs = packer.MultiErrorAppend(errs, err)
		} else {
			p.config.User = usr.Username
		}
	}

	if p.config.User == "" {
		errs = packer.MultiErrorAppend(errs, fmt.Errorf("user: could not determine current user from environment"))
	}

	if errs != nil && len(errs.Errors) > 0 {
		return errs
	}
	return nil
}
// Prepare the config data for provisioning
Prepare the config data for provisioning
// Prepare the config data for provisioning
func (p *Provisioner) Prepare(raws ...interface{}) error {
	p.done = make(chan struct{})
	p.config.ctx.Data = &PassthroughTemplate{
		WinRMPassword: `{{.WinRMPassword}}`,
	}
	err := config.Decode(&p.config, &config.DecodeOpts{
		Interpolate:        true,
		InterpolateContext: &p.config.ctx,
		InterpolateFilter: &interpolate.RenderFilter{
			Exclude: []string{},
		},
	}, raws...)
	if err != nil {
		return err
	}
	var errs *packer.MultiError
	if p.config.Command == "" {
		p.config.Command = "bolt"
	}
	if p.config.BoltTask == "" && p.config.BoltPlan == "" {
		errs = packer.MultiErrorAppend(errs, fmt.Errorf("A bolt task or bolt plan must be specified"))
	}
	if p.config.BoltTask != "" && p.config.BoltPlan != "" {
		errs = packer.MultiErrorAppend(errs, fmt.Errorf("A bolt task and bolt plan cannot be specified at the same time"))
	}
	if len(p.config.BoltModulePath) > 0 {
		err = validateModuleDirectoryConfig(p.config.BoltModulePath)
		if err != nil {
			log.Println(p.config.BoltModulePath, "does not exist")
			errs = packer.MultiErrorAppend(errs, err)
		}
	}
	if !p.config.SkipVersionCheck {
		err = p.getVersion()
		if err != nil {
			errs = packer.MultiErrorAppend(errs, err)
		}
	}
	if p.config.User == "" {
		usr, err := user.Current()
		if err != nil {
			errs = packer.MultiErrorAppend(errs, err)
		} else {
			p.config.User = usr.Username
		}
	}
	if p.config.User == "" {
		errs = packer.MultiErrorAppend(errs, fmt.Errorf("user: could not determine current user from environment"))
	}
	if errs != nil && len(errs.Errors) > 0 {
		return errs
	}
	return nil
}
func ( p * Provisioner ) Prepare ( raws ... interface { } ) error { p . done = make ( chan struct { } ) p . config . ctx . Data = & PassthroughTemplate { WinRMPassword : `{{.WinRMPassword}}` , } err := config . Decode ( & p . config , & config . DecodeOpts { Interpolate : true , InterpolateContext : & p . config . ctx , InterpolateFilter : & interpolate . RenderFilter { Exclude : [ ] string { } , } , } , raws ... ) if err != nil { return err } var errs * packer . MultiError if p . config . Command == " " { p . config . Command = " " } if p . config . BoltTask == " " && p . config . BoltPlan == " " { errs = packer . MultiErrorAppend ( errs , fmt . Errorf ( " " ) ) } if p . config . BoltTask != " " && p . config . BoltPlan != " " { errs = packer . MultiErrorAppend ( errs , fmt . Errorf ( " " ) ) } if len ( p . config . BoltModulePath ) > 0 { err = validateModuleDirectoryConfig ( p . config . BoltModulePath ) if err != nil { log . Println ( p . config . BoltModulePath , " " ) errs = packer . MultiErrorAppend ( errs , err ) } } if ! p . config . SkipVersionCheck { err = p . getVersion ( ) if err != nil { errs = packer . MultiErrorAppend ( errs , err ) } } if p . config . User == " " { usr , err := user . Current ( ) if err != nil { errs = packer . MultiErrorAppend ( errs , err ) } else { p . config . User = usr . Username } } if p . config . User == " " { errs = packer . MultiErrorAppend ( errs , fmt . Errorf ( " " ) ) } if errs != nil && len ( errs . Errors ) > 0 { return errs } return nil }
Prepare the config data for provisioning
Prepare the config data for provisioning
// Create passthrough for winrm password so we can fill it in once we know // it // Defaults // Validate that a bolt task or bolt plan is specified // Validate that both a bolt plan and task are not specified at the same time