Documentation
¶
Overview ¶
Package addrs contains types that represent "addresses", which are references to specific objects within a Packer configuration.
All addresses have string representations based on HCL traversal syntax which should be used in the user-interface, and also in-memory representations that can be used internally.
All types within this package should be treated as immutable, even if this is not enforced by the Go compiler. It is always an implementation error to modify an address object in-place after it is initially constructed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPluginPartNormalized ¶ added in v1.7.0
IsPluginPartNormalized compares a given string to the result of ParsePluginPart(string)
func ParsePluginPart ¶ added in v1.7.0
ParsePluginPart processes an addrs.Plugin namespace or type string provided by an end-user, producing a normalized version if possible or an error if the string contains invalid characters.
A plugin part is processed in the same way as an individual label in a DNS domain name: it is transformed to lowercase per the usual DNS case mapping and normalization rules and may contain only letters, digits, and dashes. Additionally, dashes may not appear at the start or end of the string.
These restrictions are intended to allow these names to appear in fussy contexts such as directory/file names on case-insensitive filesystems, repository names on GitHub, etc. We're using the DNS rules in particular, rather than some similar rules defined locally, because the hostname part of an addrs.Plugin is already a hostname and it's ideal to use exactly the same case folding and normalization rules for all of the parts.
It's valid to pass the result of this function as the argument to a subsequent call, in which case the result will be identical.
Types ¶
type InputVariable ¶
type InputVariable struct { Name string // contains filtered or unexported fields }
InputVariable is the address of an input variable.
func (InputVariable) String ¶
func (v InputVariable) String() string
type Plugin ¶ added in v1.7.0
Plugin encapsulates a single plugin type.
func ParsePluginSourceString ¶ added in v1.7.0
ParsePluginSourceString parses the source attribute and returns a plugin. This is intended primarily to parse the FQN-like strings
The following are valid source string formats:
name namespace/name hostname/namespace/name
func (Plugin) RealRelativePath ¶ added in v1.7.0
type Reference ¶
type Reference struct { Subject Referenceable SourceRange hcl.Range Remaining hcl.Traversal }
Reference describes a reference to an address with source location information.
func ParseRef ¶
func ParseRef(traversal hcl.Traversal) (*Reference, hcl.Diagnostics)
ParseRef attempts to extract a referencable address from the prefix of the given traversal, which must be an absolute traversal or this function will panic.
If no error diagnostics are returned, the returned reference includes the address that was extracted, the source range it was extracted from, and any remaining relative traversal that was not consumed as part of the reference.
If error diagnostics are returned then the Reference value is invalid and must not be used.
type Referenceable ¶
type Referenceable interface { // String produces a string representation of the address that could be // parsed as a HCL traversal and passed to ParseRef to produce an identical // result. String() string // contains filtered or unexported methods }
Referenceable is an interface implemented by all address types that can appear as references in configuration language expressions.