terraform: make UX a bit better for input

This commit is contained in:
Mitchell Hashimoto 2014-09-29 12:45:28 -07:00
parent 99d0e52ead
commit 980fce1d6c
2 changed files with 8 additions and 5 deletions

View File

@ -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

View File

@ -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)
}