-
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.
- Loading branch information
1 parent
8f28989
commit d351b10
Showing
29 changed files
with
2,299 additions
and
115 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,93 @@ | ||
package schema | ||
|
||
import ( | ||
"github.com/hashicorp/go-version" | ||
"github.com/hashicorp/hcl-lang/lang" | ||
"github.com/hashicorp/hcl-lang/schema" | ||
"github.com/hashicorp/terraform-schema/internal/schema/backends" | ||
"github.com/hashicorp/terraform-schema/internal/schema/refscope" | ||
"github.com/zclconf/go-cty/cty" | ||
) | ||
|
||
var terraformBlockSchema = &schema.BlockSchema{ | ||
Description: lang.Markdown("Terraform block used to configure some high-level behaviors of Terraform"), | ||
Body: &schema.BodySchema{ | ||
Attributes: map[string]*schema.AttributeSchema{ | ||
"required_version": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsOptional: true, | ||
Description: lang.Markdown("Constraint to specify which versions of Terraform can be used " + | ||
"with this configuration, e.g. `~> 0.12`"), | ||
}, | ||
"experiments": { | ||
Expr: schema.ExprConstraints{ | ||
schema.TupleConsExpr{ | ||
Name: "set of features", | ||
func terraformBlockSchema(v *version.Version) *schema.BlockSchema { | ||
return &schema.BlockSchema{ | ||
Description: lang.Markdown("Terraform block used to configure some high-level behaviors of Terraform"), | ||
Body: &schema.BodySchema{ | ||
Attributes: map[string]*schema.AttributeSchema{ | ||
"required_version": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsOptional: true, | ||
Description: lang.Markdown("Constraint to specify which versions of Terraform can be used " + | ||
"with this configuration, e.g. `~> 0.12`"), | ||
}, | ||
"experiments": { | ||
Expr: schema.ExprConstraints{ | ||
schema.TupleConsExpr{ | ||
Name: "set of features", | ||
}, | ||
}, | ||
IsOptional: true, | ||
Description: lang.Markdown("A set of experimental language features to enable"), | ||
}, | ||
IsOptional: true, | ||
Description: lang.Markdown("A set of experimental language features to enable"), | ||
}, | ||
}, | ||
Blocks: map[string]*schema.BlockSchema{ | ||
"backend": { | ||
Description: lang.Markdown("Backend configuration which defines exactly where and how " + | ||
"operations are performed, where state snapshots are stored, etc."), | ||
Labels: []*schema.LabelSchema{ | ||
{ | ||
Name: "type", | ||
Description: lang.Markdown("Backend Type"), | ||
IsDepKey: true, | ||
Blocks: map[string]*schema.BlockSchema{ | ||
"backend": { | ||
Description: lang.Markdown("Backend configuration which defines exactly where and how " + | ||
"operations are performed, where state snapshots are stored, etc."), | ||
Labels: []*schema.LabelSchema{ | ||
{ | ||
Name: "type", | ||
Description: lang.Markdown("Backend Type"), | ||
IsDepKey: true, | ||
}, | ||
}, | ||
DependentBody: backends.ConfigsAsDependentBodies(v), | ||
}, | ||
}, | ||
"provider_meta": { | ||
Description: lang.Markdown("Metadata to pass into a provider which supports this"), | ||
Labels: []*schema.LabelSchema{ | ||
{ | ||
Name: "name", | ||
Description: lang.Markdown("Provider Name"), | ||
IsDepKey: true, | ||
"provider_meta": { | ||
Description: lang.Markdown("Metadata to pass into a provider which supports this"), | ||
Labels: []*schema.LabelSchema{ | ||
{ | ||
Name: "name", | ||
Description: lang.Markdown("Provider Name"), | ||
IsDepKey: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
"required_providers": { | ||
Description: lang.Markdown("What provider version to use within this configuration " + | ||
"and where to source it from"), | ||
Body: &schema.BodySchema{ | ||
AnyAttribute: &schema.AttributeSchema{ | ||
Expr: schema.ExprConstraints{ | ||
schema.ObjectExpr{ | ||
Attributes: schema.ObjectExprAttributes{ | ||
"source": &schema.AttributeSchema{ | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
Description: lang.Markdown("The global source address for the provider " + | ||
"you intend to use, such as `hashicorp/aws`"), | ||
}, | ||
"version": &schema.AttributeSchema{ | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
Description: lang.Markdown("Version constraint specifying which subset of " + | ||
"available provider versions the module is compatible with, e.g. `~> 1.0`"), | ||
"required_providers": { | ||
Description: lang.Markdown("What provider version to use within this configuration " + | ||
"and where to source it from"), | ||
Body: &schema.BodySchema{ | ||
AnyAttribute: &schema.AttributeSchema{ | ||
Expr: schema.ExprConstraints{ | ||
schema.ObjectExpr{ | ||
Attributes: schema.ObjectExprAttributes{ | ||
"source": &schema.AttributeSchema{ | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
Description: lang.Markdown("The global source address for the provider " + | ||
"you intend to use, such as `hashicorp/aws`"), | ||
}, | ||
"version": &schema.AttributeSchema{ | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
Description: lang.Markdown("Version constraint specifying which subset of " + | ||
"available provider versions the module is compatible with, e.g. `~> 1.0`"), | ||
}, | ||
}, | ||
}, | ||
schema.LiteralTypeExpr{Type: cty.String}, | ||
}, | ||
schema.LiteralTypeExpr{Type: cty.String}, | ||
}, | ||
Address: &schema.AttributeAddrSchema{ | ||
Steps: []schema.AddrStep{ | ||
schema.AttrNameStep{}, | ||
Address: &schema.AttributeAddrSchema{ | ||
Steps: []schema.AddrStep{ | ||
schema.AttrNameStep{}, | ||
}, | ||
AsReference: true, | ||
FriendlyName: "provider", | ||
ScopeId: refscope.ProviderScope, | ||
}, | ||
AsReference: true, | ||
FriendlyName: "provider", | ||
ScopeId: refscope.ProviderScope, | ||
Description: lang.Markdown("Provider source and version constraint"), | ||
}, | ||
Description: lang.Markdown("Provider source and version constraint"), | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
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,50 @@ | ||
package backends | ||
|
||
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 artifactoryBackend(v *version.Version) *schema.BodySchema { | ||
// https://github.com/hashicorp/terraform/blob/v0.12.0/backend/remote-state/artifactory/backend.go | ||
// https://github.com/hashicorp/terraform/blob/v1.0.0/internal/backend/remote-state/artifactory/backend.go | ||
// Docs: | ||
// https://github.com/hashicorp/terraform/blob/v1.0.0/website/docs/language/settings/backends/artifactory.html.md | ||
docsUrl := "https://www.terraform.io/docs/language/settings/backends/artifactory.html" | ||
return &schema.BodySchema{ | ||
Description: lang.Markdown("Artifactory"), | ||
HoverURL: docsUrl, | ||
DocsLink: &schema.DocsLink{ | ||
URL: docsUrl, | ||
}, | ||
Attributes: map[string]*schema.AttributeSchema{ | ||
"username": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsRequired: true, | ||
Description: lang.Markdown("Username"), | ||
}, | ||
"password": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsRequired: true, | ||
Description: lang.Markdown("Password"), | ||
}, | ||
"url": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsRequired: true, | ||
Description: lang.Markdown("Artfactory base URL (i.e. URL without repo and subpath)"), | ||
}, | ||
"repo": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsRequired: true, | ||
Description: lang.Markdown("The repository name"), | ||
}, | ||
"subpath": { | ||
Expr: schema.LiteralTypeOnly(cty.String), | ||
IsRequired: true, | ||
Description: lang.Markdown("Path within the repository"), | ||
}, | ||
}, | ||
} | ||
} |
Oops, something went wrong.