Skip to content

Commit

Permalink
Conclude Terraform Experiments Completion (#337)
Browse files Browse the repository at this point in the history
* Conclude Terraform Experiments Completion

This commit concludes the work on the Terraform experiments feature by removing the list of features from completion for the `experiments` attriubute.

Terraform language experiments are temporary features that are added, removed, and/or concluded at cadences too unpredictable to be included in this completion list. These are used in alpha or beta builds of Terraform and are changed frequently enough that it would either always be out of date or require constant releases to keep up to date.

As such, the completion list for the `experiments` attribute has been removed and documentation added to instruct the user to look to documentation for the particular release they are using for a list of features that can be enabled.

* Update internal/schema/0.14/terraform.go

Co-authored-by: Ansgar Mertens <mertens.ansgar@gmail.com>

* conclude module_variable_optional_attrs experiment in new TF 1.8 schema

---------

Co-authored-by: Ansgar Mertens <mertens.ansgar@gmail.com>
Co-authored-by: Ansgar Mertens <ansgar@hashicorp.com>
  • Loading branch information
3 people committed Apr 10, 2024
1 parent 3ad377b commit 72025f5
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/schema/1.8/root.go
@@ -0,0 +1,17 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package schema

import (
"github.com/hashicorp/go-version"
"github.com/hashicorp/hcl-lang/schema"

v1_7_mod "github.com/hashicorp/terraform-schema/internal/schema/1.7"
)

func ModuleSchema(v *version.Version) *schema.BodySchema {
bs := v1_7_mod.ModuleSchema(v)
bs.Blocks["terraform"] = patchTerraformBlockSchema(bs.Blocks["terraform"])
return bs
}
27 changes: 27 additions & 0 deletions internal/schema/1.8/terraform.go
@@ -0,0 +1,27 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package schema

import (
"github.com/hashicorp/hcl-lang/lang"
"github.com/hashicorp/hcl-lang/schema"
)

func patchTerraformBlockSchema(bs *schema.BlockSchema) *schema.BlockSchema {
// removes module_variable_optional_attrs experiment (defined in 0.14)
bs.Body.Attributes["experiments"] = &schema.AttributeSchema{
Constraint: schema.Set{
Elem: schema.OneOf{
schema.Keyword{
Keyword: "provider_sensitive_attrs",
Name: "feature",
},
},
},
IsOptional: true,
Description: lang.Markdown("A set of experimental language features to enable"),
}

return bs
}
4 changes: 4 additions & 0 deletions schema/core_schema.go
Expand Up @@ -16,6 +16,7 @@ import (
mod_v1_5 "github.com/hashicorp/terraform-schema/internal/schema/1.5"
mod_v1_6 "github.com/hashicorp/terraform-schema/internal/schema/1.6"
mod_v1_7 "github.com/hashicorp/terraform-schema/internal/schema/1.7"
mod_v1_8 "github.com/hashicorp/terraform-schema/internal/schema/1.8"
)

var (
Expand All @@ -38,6 +39,9 @@ var (
// It will return error if such schema cannot be found.
func CoreModuleSchemaForVersion(v *version.Version) (*schema.BodySchema, error) {
ver := v.Core()
if ver.GreaterThanOrEqual(v1_8) {
return mod_v1_8.ModuleSchema(ver), nil
}
if ver.GreaterThanOrEqual(v1_7) {
return mod_v1_7.ModuleSchema(ver), nil
}
Expand Down

0 comments on commit 72025f5

Please sign in to comment.