Skip to content

Commit

Permalink
addrs: Reserve "template" and similar prefixes for future expansion
Browse files Browse the repository at this point in the history
At the time of this commit we have a proposal #28700 which would, if
accepted, need to reserve a new reference prefix to represent template
arguments.

It seems unlikely that the proposal would be accepted and implemented
before Terraform v1.0 creates additional compatibility constraints, and so
this pre-emptively reserves a few candidate symbol names to allow
something like that proposal to potentially move forward later without
requiring a new opt-in language edition.

If we do move forward with the proposal then we'll select one of these
three reserved names depending on which form of the proposal we decide
to move forward with, and then un-reserve the other two. If we decide to
not pursue this proposal at all then we'll un-reserve all three once
that decision is finalized.

It's unlikely that there is any existing provider which has a resource
type named either "template", "lazy", or "arg", but in that unlikely event
users of that provider can keep using it by adding the "resource."
escaping prefix, such as changing "lazy.foo.bar" into
"resource.lazy.foo.bar".
  • Loading branch information
apparentlymart committed May 17, 2021
1 parent ad3e99b commit db43867
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions addrs/parse_ref.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,18 @@ func parseRef(traversal hcl.Traversal) (*Reference, tfdiags.Diagnostics) {
Remaining: remain,
}, diags

case "template", "lazy", "arg":
// These names are all pre-emptively reserved in the hope of landing
// some version of "template values" or "lazy expressions" feature
// before the next opt-in language edition, but don't yet do anything.
diags = diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Reserved symbol name",
Detail: fmt.Sprintf("The symbol name %q is reserved for use in a future Terraform version. If you are using a provider that already uses this as a resource type name, add the prefix \"resource.\" to force interpretation as a resource type name.", root),
Subject: rootRange.Ptr(),
})
return nil, diags

default:
return parseResourceRef(ManagedResourceMode, rootRange, traversal)
}
Expand Down
19 changes: 19 additions & 0 deletions addrs/parse_ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,25 @@ func TestParseRef(t *testing.T) {
``,
},

// We have some names reserved which might be used by a
// still-under-discussion proposal for template values or lazy
// expressions.
{
`template.foo`,
nil,
`The symbol name "template" is reserved for use in a future Terraform version. If you are using a provider that already uses this as a resource type name, add the prefix "resource." to force interpretation as a resource type name.`,
},
{
`lazy.foo`,
nil,
`The symbol name "lazy" is reserved for use in a future Terraform version. If you are using a provider that already uses this as a resource type name, add the prefix "resource." to force interpretation as a resource type name.`,
},
{
`arg.foo`,
nil,
`The symbol name "arg" is reserved for use in a future Terraform version. If you are using a provider that already uses this as a resource type name, add the prefix "resource." to force interpretation as a resource type name.`,
},

// anything else, interpreted as a managed resource reference
{
`boop_instance.foo`,
Expand Down

0 comments on commit db43867

Please sign in to comment.