github.com/wikibal01/hashicorp-terraform@v0.11.12-beta1/terraform/ui_input_prefix.go (about)

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