]>
Commit | Line | Data |
---|---|---|
bae9f6d2 JC |
1 | package terraform |
2 | ||
3 | import ( | |
107c1cdb | 4 | "context" |
bae9f6d2 JC |
5 | "fmt" |
6 | ) | |
7 | ||
8 | // PrefixUIInput is an implementation of UIInput that prefixes the ID | |
9 | // with a string, allowing queries to be namespaced. | |
10 | type PrefixUIInput struct { | |
11 | IdPrefix string | |
12 | QueryPrefix string | |
13 | UIInput UIInput | |
14 | } | |
15 | ||
107c1cdb | 16 | func (i *PrefixUIInput) Input(ctx context.Context, opts *InputOpts) (string, error) { |
bae9f6d2 JC |
17 | opts.Id = fmt.Sprintf("%s.%s", i.IdPrefix, opts.Id) |
18 | opts.Query = fmt.Sprintf("%s%s", i.QueryPrefix, opts.Query) | |
107c1cdb | 19 | return i.UIInput.Input(ctx, opts) |
bae9f6d2 | 20 | } |