2014-09-29 12:36:49 -05:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
2019-03-07 14:07:13 -06:00
|
|
|
"context"
|
2014-09-29 12:36:49 -05:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// PrefixUIInput is an implementation of UIInput that prefixes the ID
|
|
|
|
// with a string, allowing queries to be namespaced.
|
|
|
|
type PrefixUIInput struct {
|
2014-09-29 14:45:28 -05:00
|
|
|
IdPrefix string
|
|
|
|
QueryPrefix string
|
|
|
|
UIInput UIInput
|
2014-09-29 12:36:49 -05:00
|
|
|
}
|
|
|
|
|
2019-03-07 14:07:13 -06:00
|
|
|
func (i *PrefixUIInput) Input(ctx context.Context, opts *InputOpts) (string, error) {
|
2014-09-29 12:36:49 -05:00
|
|
|
opts.Id = fmt.Sprintf("%s.%s", i.IdPrefix, opts.Id)
|
2014-09-29 14:52:48 -05:00
|
|
|
opts.Query = fmt.Sprintf("%s%s", i.QueryPrefix, opts.Query)
|
2019-03-07 14:07:13 -06:00
|
|
|
return i.UIInput.Input(ctx, opts)
|
2014-09-29 12:36:49 -05:00
|
|
|
}
|