provisioner(converge): transfer module directories

This commit is contained in:
Brian Hicks 2016-12-27 11:29:36 -06:00
parent e2daefab71
commit 4f0034e574
No known key found for this signature in database
GPG Key ID: FF1F407C0D3C2430
1 changed files with 27 additions and 0 deletions

View File

@ -22,11 +22,22 @@ import (
type Config struct { type Config struct {
common.PackerConfig `mapstructure:",squash"` common.PackerConfig `mapstructure:",squash"`
// Bootstrapping
NoBootstrap bool `mapstructure:"no_bootstrap"` // TODO: add a way to specify bootstrap version NoBootstrap bool `mapstructure:"no_bootstrap"` // TODO: add a way to specify bootstrap version
// Modules
ModuleDirs []ModuleDir `mapstructure:"module_dirs"`
ctx interpolate.Context ctx interpolate.Context
} }
// ModuleDir is a directory to transfer to the remote system
type ModuleDir struct {
Source string `mapstructure:"source"`
Destination string `mapstructure:"destination"`
Exclude []string `mapstructure:"exclude"`
}
// Provisioner for Converge // Provisioner for Converge
type Provisioner struct { type Provisioner struct {
config Config config Config
@ -60,6 +71,11 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
return err // error messages are already user-friendly return err // error messages are already user-friendly
} }
// send module directories to the remote host
if err := p.sendModuleDirectories(ui, comm); err != nil {
return err // error messages are already user-friendly
}
return nil return nil
} }
@ -132,6 +148,17 @@ func (p *Provisioner) checkVersion(ui packer.Ui, comm packer.Communicator) error
return nil return nil
} }
func (p *Provisioner) sendModuleDirectories(ui packer.Ui, comm packer.Communicator) error {
for _, dir := range p.config.ModuleDirs {
if err := comm.UploadDir(dir.Destination, dir.Source, dir.Exclude); err != nil {
return fmt.Errorf("Could not upload %q: %s", dir.Source, err)
}
ui.Message(fmt.Sprintf("transferred %q to %q", dir.Source, dir.Destination))
}
return nil
}
// Cancel the provisioning process // Cancel the provisioning process
func (p *Provisioner) Cancel() { func (p *Provisioner) Cancel() {
log.Println("cancel called in Converge provisioner") log.Println("cancel called in Converge provisioner")