You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
terraform/internal/stacks/stackaddrs/referenceable.go

47 lines
1.2 KiB

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package stackaddrs
// Referenceable is a type set containing all address types that can be
// the target of an expression-based reference within a particular stack.
type Referenceable interface {
referenceableSigil()
String() string
}
var _ Referenceable = Component{}
var _ Referenceable = StackCall{}
var _ Referenceable = InputVariable{}
var _ Referenceable = LocalValue{}
var _ Referenceable = ProviderConfigRef{}
var _ Referenceable = TestOnlyGlobal{}
var _ Referenceable = ContextualRef(0)
type ContextualRef rune
const EachValue = ContextualRef('v')
const EachKey = ContextualRef('k')
const CountIndex = ContextualRef('i')
const Self = ContextualRef('s')
// String implements Referenceable.
func (e ContextualRef) String() string {
switch e {
case EachKey:
return "each.key"
case EachValue:
return "each.value"
case CountIndex:
return "count.index"
case Self:
return "self"
default:
// The four constants in this package are the only valid values of this type
panic("invalid ContextualRef instance")
}
}
// referenceableSigil implements Referenceable.
func (e ContextualRef) referenceableSigil() {}