From bbd3d7f7a2785df725435db7db1bbc52f2436b41 Mon Sep 17 00:00:00 2001 From: Rob Campbell Date: Wed, 21 Feb 2018 11:47:45 -0500 Subject: [PATCH] Updates the capitalization of the bind documenation for habitat provisioner. Also fixes an issue where channels and URLs are not honored in the initial package install. Signed-off-by: Rob Campbell --- .../habitat/resource_provisioner.go | 25 +++++++++++++++---- .../docs/provisioners/habitat.html.markdown | 6 ++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/builtin/provisioners/habitat/resource_provisioner.go b/builtin/provisioners/habitat/resource_provisioner.go index aa404dae1..853d16c8e 100644 --- a/builtin/provisioners/habitat/resource_provisioner.go +++ b/builtin/provisioners/habitat/resource_provisioner.go @@ -179,6 +179,7 @@ func Provisioner() terraform.ResourceProvisioner { Optional: true, }, "channel": &schema.Schema{ + Type: schema.TypeString, Optional: true, }, @@ -626,22 +627,36 @@ func (p *provisioner) createHabUser(o terraform.UIOutput, comm communicator.Comm return nil } -func (p *provisioner) startHabService(o terraform.UIOutput, comm communicator.Communicator, service Service) error { +// In the future we'll remove the dedicated install once the synchronous load feature in hab-sup is +// available. Until then we install here to provide output and a noisy failure mechanism because +// if you install with the pkg load, it occurs asynchronously and fails quietly. +func (p *provisioner) installHabPackage(o terraform.UIOutput, comm communicator.Communicator, service Service) error { var command string + options := "" + if service.Channel != "" { + options += fmt.Sprintf(" --channel %s", service.Channel) + } + + if service.URL != "" { + options += fmt.Sprintf(" --url %s", service.URL) + } if p.UseSudo { - command = fmt.Sprintf("env HAB_NONINTERACTIVE=true sudo -E hab pkg install %s", service.Name) + command = fmt.Sprintf("env HAB_NONINTERACTIVE=true sudo -E hab pkg install %s %s", service.Name, options) } else { - command = fmt.Sprintf("env HAB_NONINTERACTIVE=true hab pkg install %s", service.Name) + command = fmt.Sprintf("env HAB_NONINTERACTIVE=true hab pkg install %s %s", service.Name, options) } if p.BuilderAuthToken != "" { command = fmt.Sprintf("env HAB_AUTH_TOKEN=%s %s", p.BuilderAuthToken, command) } + return p.runCommand(o, comm, command) +} - if err := p.runCommand(o, comm, command); err != nil { +func (p *provisioner) startHabService(o terraform.UIOutput, comm communicator.Communicator, service Service) error { + var command string + if err := p.installHabPackage(o, comm, service); err != nil { return err } - if err := p.uploadUserTOML(o, comm, service); err != nil { return err } diff --git a/website/docs/provisioners/habitat.html.markdown b/website/docs/provisioners/habitat.html.markdown index 55ac2232b..f96239b8e 100644 --- a/website/docs/provisioners/habitat.html.markdown +++ b/website/docs/provisioners/habitat.html.markdown @@ -70,9 +70,9 @@ There are 2 configuration levels, `supervisor` and `service`. Configuration pla ```hcl bind { - Alias = "backend" - Service = "nginx" - Group = "default" + alias = "backend" + service = "nginx" + group = "default" } ``` * `topology (string)` - (Optional) Topology to start service in. Possible values `standalone` or `leader`. (Defaults to `standalone`)