From 980fce1d6ce8302b171d3e755a69dc98c3591e3b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 29 Sep 2014 12:45:28 -0700 Subject: [PATCH] terraform: make UX a bit better for input --- terraform/context.go | 7 ++++--- terraform/ui_input_prefix.go | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/terraform/context.go b/terraform/context.go index f8ce99e5a..0570068ef 100644 --- a/terraform/context.go +++ b/terraform/context.go @@ -168,7 +168,7 @@ func (c *Context) Input() error { value, err = c.uiInput.Input(&InputOpts{ Id: fmt.Sprintf("var.%s", n), Query: fmt.Sprintf( - "Please enter a value for '%s': ", n), + "Variable '%s': ", n), }) if err != nil { return fmt.Errorf( @@ -571,8 +571,9 @@ func (c *walkContext) inputWalkFn() depgraph.WalkFunc { // Wrap the input into a namespace input := &PrefixUIInput{ - IdPrefix: fmt.Sprintf("provider.%s", rn.ID), - UIInput: c.Context.uiInput, + IdPrefix: fmt.Sprintf("provider.%s", rn.ID), + QueryPrefix: fmt.Sprintf("Provider %s", rn.ID), + UIInput: c.Context.uiInput, } // Go through each provider and capture the input necessary diff --git a/terraform/ui_input_prefix.go b/terraform/ui_input_prefix.go index 0ba40debe..aebd54493 100644 --- a/terraform/ui_input_prefix.go +++ b/terraform/ui_input_prefix.go @@ -7,11 +7,13 @@ import ( // PrefixUIInput is an implementation of UIInput that prefixes the ID // with a string, allowing queries to be namespaced. type PrefixUIInput struct { - IdPrefix string - UIInput UIInput + IdPrefix string + QueryPrefix string + UIInput UIInput } func (i *PrefixUIInput) Input(opts *InputOpts) (string, error) { opts.Id = fmt.Sprintf("%s.%s", i.IdPrefix, opts.Id) + opts.Query = fmt.Sprintf("%s %s", i.QueryPrefix, opts.Query) return i.UIInput.Input(opts) }