diff --git a/internal/schema/1.8/root.go b/internal/schema/1.8/root.go new file mode 100644 index 00000000..6d0cb5d5 --- /dev/null +++ b/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 +} diff --git a/internal/schema/1.8/terraform.go b/internal/schema/1.8/terraform.go new file mode 100644 index 00000000..2089d198 --- /dev/null +++ b/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 +} diff --git a/schema/core_schema.go b/schema/core_schema.go index fc2afd48..2e87cbc1 100644 --- a/schema/core_schema.go +++ b/schema/core_schema.go @@ -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 ( @@ -30,6 +31,7 @@ var ( v1_5 = version.Must(version.NewVersion("1.5")) v1_6 = version.Must(version.NewVersion("1.6")) v1_7 = version.Must(version.NewVersion("1.7")) + v1_8 = version.Must(version.NewVersion("1.8")) ) // CoreModuleSchemaForVersion finds a module schema which is relevant @@ -37,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 }