From 4f0034e5743ddce0e441face6513e95152deefdf Mon Sep 17 00:00:00 2001 From: Brian Hicks Date: Tue, 27 Dec 2016 11:29:36 -0600 Subject: [PATCH] provisioner(converge): transfer module directories --- provisioner/converge/provisioner.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/provisioner/converge/provisioner.go b/provisioner/converge/provisioner.go index 49557a67d..f00e04d82 100644 --- a/provisioner/converge/provisioner.go +++ b/provisioner/converge/provisioner.go @@ -22,11 +22,22 @@ import ( type Config struct { common.PackerConfig `mapstructure:",squash"` + // Bootstrapping NoBootstrap bool `mapstructure:"no_bootstrap"` // TODO: add a way to specify bootstrap version + // Modules + ModuleDirs []ModuleDir `mapstructure:"module_dirs"` + 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 type Provisioner struct { 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 } + // 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 } @@ -132,6 +148,17 @@ func (p *Provisioner) checkVersion(ui packer.Ui, comm packer.Communicator) error 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 func (p *Provisioner) Cancel() { log.Println("cancel called in Converge provisioner")