terraform: make UX a bit better for input
This commit is contained in:
parent
99d0e52ead
commit
980fce1d6c
|
@ -168,7 +168,7 @@ func (c *Context) Input() error {
|
||||||
value, err = c.uiInput.Input(&InputOpts{
|
value, err = c.uiInput.Input(&InputOpts{
|
||||||
Id: fmt.Sprintf("var.%s", n),
|
Id: fmt.Sprintf("var.%s", n),
|
||||||
Query: fmt.Sprintf(
|
Query: fmt.Sprintf(
|
||||||
"Please enter a value for '%s': ", n),
|
"Variable '%s': ", n),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf(
|
return fmt.Errorf(
|
||||||
|
@ -572,6 +572,7 @@ func (c *walkContext) inputWalkFn() depgraph.WalkFunc {
|
||||||
// Wrap the input into a namespace
|
// Wrap the input into a namespace
|
||||||
input := &PrefixUIInput{
|
input := &PrefixUIInput{
|
||||||
IdPrefix: fmt.Sprintf("provider.%s", rn.ID),
|
IdPrefix: fmt.Sprintf("provider.%s", rn.ID),
|
||||||
|
QueryPrefix: fmt.Sprintf("Provider %s", rn.ID),
|
||||||
UIInput: c.Context.uiInput,
|
UIInput: c.Context.uiInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,12 @@ import (
|
||||||
// with a string, allowing queries to be namespaced.
|
// with a string, allowing queries to be namespaced.
|
||||||
type PrefixUIInput struct {
|
type PrefixUIInput struct {
|
||||||
IdPrefix string
|
IdPrefix string
|
||||||
|
QueryPrefix string
|
||||||
UIInput UIInput
|
UIInput UIInput
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *PrefixUIInput) Input(opts *InputOpts) (string, error) {
|
func (i *PrefixUIInput) Input(opts *InputOpts) (string, error) {
|
||||||
opts.Id = fmt.Sprintf("%s.%s", i.IdPrefix, opts.Id)
|
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)
|
return i.UIInput.Input(opts)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue