-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schema: Add v1.4 local-exec provisioner quiet attribute (#218)
- Loading branch information
1 parent
3d07383
commit 934122b
Showing
4 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package schema | ||
|
||
import ( | ||
"github.com/hashicorp/go-version" | ||
"github.com/hashicorp/hcl-lang/lang" | ||
"github.com/hashicorp/hcl-lang/schema" | ||
"github.com/zclconf/go-cty/cty" | ||
|
||
v0_15_mod "github.com/hashicorp/terraform-schema/internal/schema/0.15" | ||
) | ||
|
||
var ( | ||
FileProvisioner = v0_15_mod.FileProvisioner | ||
LocalExecProvisioner = func() *schema.BodySchema { | ||
// See https: //github.com/hashicorp/terraform/pull/32116/files | ||
bodySchema := v0_15_mod.LocalExecProvisioner | ||
bodySchema.Attributes["quiet"] = &schema.AttributeSchema{ | ||
Constraint: schema.LiteralType{Type: cty.Bool}, | ||
IsOptional: true, | ||
Description: lang.Markdown("Whether to suppress script output"), | ||
} | ||
return bodySchema | ||
}() | ||
RemoteExecProvisioner = v0_15_mod.RemoteExecProvisioner | ||
) | ||
|
||
func ProvisionerDependentBodies(v *version.Version) map[schema.SchemaKey]*schema.BodySchema { | ||
return map[schema.SchemaKey]*schema.BodySchema{ | ||
labelKey("file"): FileProvisioner, | ||
labelKey("local-exec"): LocalExecProvisioner, | ||
labelKey("remote-exec"): RemoteExecProvisioner, | ||
} | ||
} | ||
|
||
func labelKey(value string) schema.SchemaKey { | ||
return schema.NewSchemaKey(schema.DependencyKeys{ | ||
Labels: []schema.LabelDependent{{Index: 0, Value: value}}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 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_2_mod "github.com/hashicorp/terraform-schema/internal/schema/1.2" | ||
) | ||
|
||
func ModuleSchema(v *version.Version) *schema.BodySchema { | ||
bs := v1_2_mod.ModuleSchema(v) | ||
bs.Blocks["resource"].Body.Blocks["provisioner"].DependentBody = ProvisionerDependentBodies(v) | ||
|
||
return bs | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters