mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-25 08:21:07 -06:00
24 lines
566 B
Go
24 lines
566 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package tofu
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// PrefixUIInput is an implementation of UIInput that prefixes the ID
|
|
// with a string, allowing queries to be namespaced.
|
|
type PrefixUIInput struct {
|
|
IdPrefix string
|
|
QueryPrefix string
|
|
UIInput UIInput
|
|
}
|
|
|
|
func (i *PrefixUIInput) Input(ctx context.Context, 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(ctx, opts)
|
|
}
|