-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
schema: Introduce 1.1 terraform cloud block (#117)
* schema: Introduce 1.1 terraform cloud block * add tests
- Loading branch information
1 parent
f96f94a
commit e05b3dd
Showing
5 changed files
with
93 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package schema | ||
|
||
import ( | ||
"github.com/hashicorp/go-version" | ||
"github.com/hashicorp/hcl-lang/schema" | ||
|
||
v015_mod "github.com/hashicorp/terraform-schema/internal/schema/0.15" | ||
) | ||
|
||
func ModuleSchema(v *version.Version) *schema.BodySchema { | ||
bs := v015_mod.ModuleSchema(v) | ||
bs.Blocks["terraform"] = patchTerraformBlockSchema(bs.Blocks["terraform"], 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
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" | ||
) | ||
|
||
func patchTerraformBlockSchema(bs *schema.BlockSchema, v *version.Version) *schema.BlockSchema { | ||
bs.Body.Blocks["cloud"] = &schema.BlockSchema{ | ||
Description: lang.PlainText("Terraform Cloud configuration"), | ||
MaxItems: 1, | ||
Body: &schema.BodySchema{ | ||
Attributes: map[string]*schema.AttributeSchema{ | ||
"hostname": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsOptional: true, | ||
Description: lang.Markdown("The Terraform Enterprise hostname to connect to. " + | ||
"This optional argument defaults to `app.terraform.io` for use with Terraform Cloud."), | ||
}, | ||
"organization": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsRequired: true, | ||
Description: lang.PlainText("The name of the organization containing the targeted workspace(s)."), | ||
}, | ||
"token": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsOptional: true, | ||
Description: lang.Markdown("The token used to authenticate with Terraform Cloud/Enterprise. " + | ||
"Typically this argument should not be set, and `terraform login` used instead; " + | ||
"your credentials will then be fetched from your CLI configuration file " + | ||
"or configured credential helper."), | ||
}, | ||
}, | ||
Blocks: map[string]*schema.BlockSchema{ | ||
"workspaces": { | ||
Description: lang.Markdown("Workspace mapping strategy, either workspace `tags` or `name` is required."), | ||
MaxItems: 1, | ||
Body: &schema.BodySchema{ | ||
Attributes: map[string]*schema.AttributeSchema{ | ||
"name": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsOptional: true, | ||
Description: lang.Markdown("The name of a single Terraform Cloud workspace " + | ||
"to be used with this configuration When configured only the specified workspace " + | ||
"can be used. This option conflicts with `tags`."), | ||
}, | ||
"tags": { | ||
Expr: schema.ExprConstraints{ | ||
schema.SetExpr{Elem: schema.LiteralTypeOnly(cty.String)}, | ||
}, | ||
IsOptional: true, | ||
Description: lang.Markdown("A set of tags used to select remote Terraform Cloud workspaces" + | ||
" to be used for this single configuration. New workspaces will automatically be tagged " + | ||
"with these tag values. Generally, this is the primary and recommended strategy to use. " + | ||
"This option conflicts with `name`."), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
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
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