github.com/terramate-io/tf@v0.0.0-20230830114523-fce866b4dfcd/addrs/targetable.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package addrs
     5  
     6  // Targetable is an interface implemented by all address types that can be
     7  // used as "targets" for selecting sub-graphs of a graph.
     8  type Targetable interface {
     9  	targetableSigil()
    10  
    11  	// TargetContains returns true if the receiver is considered to contain
    12  	// the given other address. Containment, for the purpose of targeting,
    13  	// means that if a container address is targeted then all of the
    14  	// addresses within it are also implicitly targeted.
    15  	//
    16  	// A targetable address always contains at least itself.
    17  	TargetContains(other Targetable) bool
    18  
    19  	// AddrType returns the address type for comparison with other Targetable
    20  	// addresses.
    21  	AddrType() TargetableAddrType
    22  
    23  	// String produces a string representation of the address that could be
    24  	// parsed as a HCL traversal and passed to ParseTarget to produce an
    25  	// identical result.
    26  	String() string
    27  }
    28  
    29  type targetable struct {
    30  }
    31  
    32  func (r targetable) targetableSigil() {
    33  }
    34  
    35  type TargetableAddrType int
    36  
    37  const (
    38  	ConfigResourceAddrType TargetableAddrType = iota
    39  	AbsResourceInstanceAddrType
    40  	AbsResourceAddrType
    41  	ModuleAddrType
    42  	ModuleInstanceAddrType
    43  )