Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema: Introduce BuiltinReferences(modPath) #93

Merged
merged 2 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/schema/refscope/scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

var (
BuiltinScope = lang.ScopeId("builtin")
DataScope = lang.ScopeId("data")
LocalScope = lang.ScopeId("local")
ModuleScope = lang.ScopeId("module")
Expand Down
53 changes: 53 additions & 0 deletions schema/builtin_references.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package schema

import (
"github.com/hashicorp/hcl-lang/lang"
"github.com/hashicorp/hcl-lang/reference"
"github.com/hashicorp/terraform-schema/internal/schema/refscope"
"github.com/zclconf/go-cty/cty"
)

func BuiltinReferences(modPath string) reference.Targets {
return reference.Targets{
{
Addr: lang.Address{
lang.RootStep{Name: "path"},
lang.AttrStep{Name: "module"},
},
ScopeId: refscope.BuiltinScope,
Type: cty.String,
Description: lang.Markdown("The filesystem path of the module where the expression is placed\n\n" +
modPath),
},
{
Addr: lang.Address{
lang.RootStep{Name: "path"},
lang.AttrStep{Name: "root"},
},
ScopeId: refscope.BuiltinScope,
Type: cty.String,
Description: lang.Markdown("The filesystem path of the root module of the configuration"),
},
{
Addr: lang.Address{
lang.RootStep{Name: "path"},
lang.AttrStep{Name: "cwd"},
},
ScopeId: refscope.BuiltinScope,
Type: cty.String,
Description: lang.Markdown("The filesystem path of the current working directory.\n\n" +
"In normal use of Terraform this is the same as `path.root`, " +
"but some advanced uses of Terraform run it from a directory " +
"other than the root module directory, causing these paths to be different."),
},
{
Addr: lang.Address{
lang.RootStep{Name: "terraform"},
lang.AttrStep{Name: "workspace"},
},
ScopeId: refscope.BuiltinScope,
Type: cty.String,
Description: lang.Markdown("The name of the currently selected workspace"),
},
}
}