vendor: update github.com/hashicorp/hcl/v2 to v2.20.1

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-04-09 09:38:29 +02:00
parent e7f2da9c4f
commit 744c055560
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
20 changed files with 864 additions and 600 deletions

2
go.mod
View File

@ -24,7 +24,7 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.6.0 github.com/google/uuid v1.6.0
github.com/hashicorp/go-cty-funcs v0.0.0-20230405223818-a090f58aa992 github.com/hashicorp/go-cty-funcs v0.0.0-20230405223818-a090f58aa992
github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/hcl/v2 v2.20.1
github.com/in-toto/in-toto-golang v0.5.0 github.com/in-toto/in-toto-golang v0.5.0
github.com/moby/buildkit v0.13.0-rc3.0.20240328152707-25bec7145b39 // v0.14.0-dev github.com/moby/buildkit v0.13.0-rc3.0.20240328152707-25bec7145b39 // v0.14.0-dev
github.com/moby/sys/mountinfo v0.7.1 github.com/moby/sys/mountinfo v0.7.1

10
go.sum
View File

@ -244,8 +244,8 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty-funcs v0.0.0-20230405223818-a090f58aa992 h1:fYOrSfO5C9PmFGtmRWSYGqq52SOoE2dXMtAn2Xzh1LQ= github.com/hashicorp/go-cty-funcs v0.0.0-20230405223818-a090f58aa992 h1:fYOrSfO5C9PmFGtmRWSYGqq52SOoE2dXMtAn2Xzh1LQ=
github.com/hashicorp/go-cty-funcs v0.0.0-20230405223818-a090f58aa992/go.mod h1:Abjk0jbRkDaNCzsRhOv2iDCofYpX1eVsjozoiK63qLA= github.com/hashicorp/go-cty-funcs v0.0.0-20230405223818-a090f58aa992/go.mod h1:Abjk0jbRkDaNCzsRhOv2iDCofYpX1eVsjozoiK63qLA=
github.com/hashicorp/hcl/v2 v2.19.1 h1://i05Jqznmb2EXqa39Nsvyan2o5XyMowW5fnCKW5RPI= github.com/hashicorp/hcl/v2 v2.20.1 h1:M6hgdyz7HYt1UN9e61j+qKJBqR3orTWbI1HKBJEdxtc=
github.com/hashicorp/hcl/v2 v2.19.1/go.mod h1:ThLC89FV4p9MPW804KVbe/cEXoQ8NZEh+JtMeeGErHE= github.com/hashicorp/hcl/v2 v2.20.1/go.mod h1:TZDqQ4kNKCbh1iJp99FdPiUaVDDUPivbqxZulxDYqL4=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4= github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY= github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
@ -282,8 +282,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/magiconair/properties v1.5.3 h1:C8fxWnhYyME3n0klPOhVM7PtYUB3eV1W3DeFmN3j53Y= github.com/magiconair/properties v1.5.3 h1:C8fxWnhYyME3n0klPOhVM7PtYUB3eV1W3DeFmN3j53Y=
github.com/magiconair/properties v1.5.3/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.5.3/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
@ -404,8 +402,6 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE= github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
github.com/secure-systems-lab/go-securesystemslib v0.4.0/go.mod h1:FGBZgq2tXWICsxWQW1msNf49F0Pf2Op5Htayx335Qbs= github.com/secure-systems-lab/go-securesystemslib v0.4.0/go.mod h1:FGBZgq2tXWICsxWQW1msNf49F0Pf2Op5Htayx335Qbs=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b h1:h+3JX2VoWTFuyQEo87pStk/a99dzIO1mM9KxIyLPGTU= github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b h1:h+3JX2VoWTFuyQEo87pStk/a99dzIO1mM9KxIyLPGTU=
github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b/go.mod h1:/yeG0My1xr/u+HZrFQ1tOQQQQrOawfyMUH13ai5brBc= github.com/serialx/hashring v0.0.0-20200727003509-22c0c7ab6b1b/go.mod h1:/yeG0My1xr/u+HZrFQ1tOQQQQrOawfyMUH13ai5brBc=
github.com/shibumi/go-pathspec v1.3.0 h1:QUyMZhFo0Md5B8zV8x2tesohbb5kfbpTi9rBnKh5dkI= github.com/shibumi/go-pathspec v1.3.0 h1:QUyMZhFo0Md5B8zV8x2tesohbb5kfbpTi9rBnKh5dkI=
@ -468,6 +464,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/zclconf/go-cty v1.4.0/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ= github.com/zclconf/go-cty v1.4.0/go.mod h1:nHzOclRkoj++EU9ZjSrZvRG0BXIWt8c7loYc0qXAFGQ=
github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA= github.com/zclconf/go-cty v1.14.1 h1:t9fyA35fwjjUMcmL5hLER+e/rEPqrbCK1/OSE4SI9KA=
github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE= github.com/zclconf/go-cty v1.14.1/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b h1:FosyBZYxY34Wul7O/MSKey3txpPYyCqVO5ZyceuQJEI=
github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRKQfBXbGkpdV6QMzT3rU1kSTAnfu1dO8dPKjYprgj8=
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 h1:SpGay3w+nEwMpfVnbqOLH5gY52/foP8RE8UzTZ1pdSE= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.46.1 h1:SpGay3w+nEwMpfVnbqOLH5gY52/foP8RE8UzTZ1pdSE=

View File

@ -1,5 +1,25 @@
# HCL Changelog # HCL Changelog
## v2.20.1 (March 26, 2024)
### Bugs Fixed
* Return `ExprSyntaxError` when an invalid namespaced function is encountered during parsing ([#668](https://github.com/hashicorp/hcl/pull/668))
### Internal
* Standardize on only two value dumping/diffing libraries ([#669](https://github.com/hashicorp/hcl/pull/669))
## v2.20.0 (February 29, 2024)
### Enhancements
* Support for namespaced functions ([#639](https://github.com/hashicorp/hcl/pull/639))
### Bugs Fixed
* ext/dynblock: if `iterator` is invalid return this error instead of consequential errors ([#656](https://github.com/hashicorp/hcl/pull/656))
## v2.19.0 (October 16, 2023) ## v2.19.0 (October 16, 2023)
### Enhancements ### Enhancements
@ -43,7 +63,7 @@
* HCL now uses a newer version of the upstream `cty` library which has improved treatment of unknown values: it can now track additional optional information that reduces the range of an unknown value, which allows some operations against unknown values to return known or partially-known results. ([#590](https://github.com/hashicorp/hcl/pull/590)) * HCL now uses a newer version of the upstream `cty` library which has improved treatment of unknown values: it can now track additional optional information that reduces the range of an unknown value, which allows some operations against unknown values to return known or partially-known results. ([#590](https://github.com/hashicorp/hcl/pull/590))
**Note:** This change effectively passes on [`cty`'s notion of backward compatibility](https://github.com/zclconf/go-cty/blob/main/COMPATIBILITY.md) whereby unknown values can become "more known" in later releases. In particular, if your caller is using `cty.Value.RawEquals` in its tests against the results of operations with unknown values then you may see those tests begin failing after upgrading, due to the values now being more "refined". **Note:** This change effectively passes on [`cty`'s notion of backward compatibility](https://github.com/zclconf/go-cty/blob/main/COMPATIBILITY.md) whereby unknown values can become "more known" in later releases. In particular, if your caller is using `cty.Value.RawEquals` in its tests against the results of operations with unknown values then you may see those tests begin failing after upgrading, due to the values now being more "refined".
If so, you should review the refinements with consideration to [the `cty` refinements docs](https://github.com/zclconf/go-cty/blob/7dcbae46a6f247e983efb1fa774d2bb68781a333/docs/refinements.md) and update your expected results to match only if the reported refinements seem correct for the given situation. The `RawEquals` method is intended only for making exact value comparisons in test cases, so main application code should not use it; use `Equals` instead for real logic, which will take refinements into account automatically. If so, you should review the refinements with consideration to [the `cty` refinements docs](https://github.com/zclconf/go-cty/blob/7dcbae46a6f247e983efb1fa774d2bb68781a333/docs/refinements.md) and update your expected results to match only if the reported refinements seem correct for the given situation. The `RawEquals` method is intended only for making exact value comparisons in test cases, so main application code should not use it; use `Equals` instead for real logic, which will take refinements into account automatically.
## v2.16.2 (March 9, 2023) ## v2.16.2 (March 9, 2023)
@ -173,7 +193,7 @@
* hclsyntax: Mark objects with keys that are sensitive. ([#440](https://github.com/hashicorp/hcl/pull/440)) * hclsyntax: Mark objects with keys that are sensitive. ([#440](https://github.com/hashicorp/hcl/pull/440))
## v2.8.1 (December 17, 2020) ## v2.8.1 (December 17, 2020)
### Bugs Fixed ### Bugs Fixed
* hclsyntax: Fix panic when expanding marked function arguments. ([#429](https://github.com/hashicorp/hcl/pull/429)) * hclsyntax: Fix panic when expanding marked function arguments. ([#429](https://github.com/hashicorp/hcl/pull/429))

18
vendor/github.com/hashicorp/hcl/v2/Makefile generated vendored Normal file
View File

@ -0,0 +1,18 @@
fmtcheck:
"$(CURDIR)/scripts/gofmtcheck.sh"
fmtfix:
gofmt -w ./
vetcheck:
go vet ./...
copyrightcheck:
go run github.com/hashicorp/copywrite@latest headers --plan
copyrightfix:
go run github.com/hashicorp/copywrite@latest headers
check: copyrightcheck vetcheck fmtcheck
fix: copyrightfix fmtfix

View File

@ -6,6 +6,7 @@ package hclsyntax
import ( import (
"fmt" "fmt"
"sort" "sort"
"strings"
"sync" "sync"
"github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2"
@ -251,6 +252,76 @@ func (e *FunctionCallExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnosti
} }
} }
extraUnknown := &functionCallUnknown{
name: e.Name,
}
// For historical reasons, we represent namespaced function names
// as strings with :: separating the names. If this was an attempt
// to call a namespaced function then we'll try to distinguish
// between an invalid namespace or an invalid name within a valid
// namespace in order to give the user better feedback about what
// is wrong.
//
// The parser guarantees that a function name will always
// be a series of valid identifiers separated by "::" with no
// other content, so we can be relatively unforgiving in our processing
// here.
if sepIdx := strings.LastIndex(e.Name, "::"); sepIdx != -1 {
namespace := e.Name[:sepIdx+2]
name := e.Name[sepIdx+2:]
avail := make([]string, 0, len(ctx.Functions))
for availName := range ctx.Functions {
if strings.HasPrefix(availName, namespace) {
avail = append(avail, availName)
}
}
extraUnknown.name = name
extraUnknown.namespace = namespace
if len(avail) == 0 {
// TODO: Maybe use nameSuggestion for the other available
// namespaces? But that'd require us to go scan the function
// table again, so we'll wait to see if it's really warranted.
// For now, we're assuming people are more likely to misremember
// the function names than the namespaces, because in many
// applications there will be relatively few namespaces compared
// to the number of distinct functions.
return cty.DynamicVal, hcl.Diagnostics{
{
Severity: hcl.DiagError,
Summary: "Call to unknown function",
Detail: fmt.Sprintf("There are no functions in namespace %q.", namespace),
Subject: &e.NameRange,
Context: e.Range().Ptr(),
Expression: e,
EvalContext: ctx,
Extra: extraUnknown,
},
}
} else {
suggestion := nameSuggestion(name, avail)
if suggestion != "" {
suggestion = fmt.Sprintf(" Did you mean %s%s?", namespace, suggestion)
}
return cty.DynamicVal, hcl.Diagnostics{
{
Severity: hcl.DiagError,
Summary: "Call to unknown function",
Detail: fmt.Sprintf("There is no function named %q in namespace %s.%s", name, namespace, suggestion),
Subject: &e.NameRange,
Context: e.Range().Ptr(),
Expression: e,
EvalContext: ctx,
Extra: extraUnknown,
},
}
}
}
avail := make([]string, 0, len(ctx.Functions)) avail := make([]string, 0, len(ctx.Functions))
for name := range ctx.Functions { for name := range ctx.Functions {
avail = append(avail, name) avail = append(avail, name)
@ -269,6 +340,7 @@ func (e *FunctionCallExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnosti
Context: e.Range().Ptr(), Context: e.Range().Ptr(),
Expression: e, Expression: e,
EvalContext: ctx, EvalContext: ctx,
Extra: extraUnknown,
}, },
} }
} }
@ -616,6 +688,27 @@ func (e *functionCallDiagExtra) FunctionCallError() error {
return e.functionCallError return e.functionCallError
} }
// FunctionCallUnknownDiagExtra is an interface implemented by a value in the Extra
// field of some diagnostics to indicate when the error was caused by a call to
// an unknown function.
type FunctionCallUnknownDiagExtra interface {
CalledFunctionName() string
CalledFunctionNamespace() string
}
type functionCallUnknown struct {
name string
namespace string
}
func (e *functionCallUnknown) CalledFunctionName() string {
return e.name
}
func (e *functionCallUnknown) CalledFunctionNamespace() string {
return e.namespace
}
type ConditionalExpr struct { type ConditionalExpr struct {
Condition Expression Condition Expression
TrueResult Expression TrueResult Expression
@ -1920,3 +2013,27 @@ func (e *AnonSymbolExpr) Range() hcl.Range {
func (e *AnonSymbolExpr) StartRange() hcl.Range { func (e *AnonSymbolExpr) StartRange() hcl.Range {
return e.SrcRange return e.SrcRange
} }
// ExprSyntaxError is a placeholder for an invalid expression that could not
// be parsed due to syntax errors.
type ExprSyntaxError struct {
Placeholder cty.Value
ParseDiags hcl.Diagnostics
SrcRange hcl.Range
}
func (e *ExprSyntaxError) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnostics) {
return e.Placeholder, e.ParseDiags
}
func (e *ExprSyntaxError) walkChildNodes(w internalWalkFunc) {
// ExprSyntaxError is a leaf node in the tree
}
func (e *ExprSyntaxError) Range() hcl.Range {
return e.SrcRange
}
func (e *ExprSyntaxError) StartRange() hcl.Range {
return e.SrcRange
}

View File

@ -3,7 +3,7 @@
package hclsyntax package hclsyntax
// Generated by expression_vars_get.go. DO NOT EDIT. // Generated by expression_vars_gen.go. DO NOT EDIT.
// Run 'go generate' on this package to update the set of functions here. // Run 'go generate' on this package to update the set of functions here.
import ( import (
@ -22,6 +22,10 @@ func (e *ConditionalExpr) Variables() []hcl.Traversal {
return Variables(e) return Variables(e)
} }
func (e *ExprSyntaxError) Variables() []hcl.Traversal {
return Variables(e)
}
func (e *ForExpr) Variables() []hcl.Traversal { func (e *ForExpr) Variables() []hcl.Traversal {
return Variables(e) return Variables(e)
} }

View File

@ -9,4 +9,4 @@ package hclsyntax
//go:generate gofmt -w scan_tokens.go //go:generate gofmt -w scan_tokens.go
//go:generate ragel -Z scan_string_lit.rl //go:generate ragel -Z scan_string_lit.rl
//go:generate gofmt -w scan_string_lit.go //go:generate gofmt -w scan_string_lit.go
//go:generate stringer -type TokenType -output token_type_string.go //go:generate go run golang.org/x/tools/cmd/stringer -type TokenType -output token_type_string.go

View File

@ -999,7 +999,7 @@ func (p *parser) parseExpressionTerm() (Expression, hcl.Diagnostics) {
case TokenIdent: case TokenIdent:
tok := p.Read() // eat identifier token tok := p.Read() // eat identifier token
if p.Peek().Type == TokenOParen { if p.Peek().Type == TokenOParen || p.Peek().Type == TokenDoubleColon {
return p.finishParsingFunctionCall(tok) return p.finishParsingFunctionCall(tok)
} }
@ -1145,16 +1145,76 @@ func (p *parser) numberLitValue(tok Token) (cty.Value, hcl.Diagnostics) {
// finishParsingFunctionCall parses a function call assuming that the function // finishParsingFunctionCall parses a function call assuming that the function
// name was already read, and so the peeker should be pointing at the opening // name was already read, and so the peeker should be pointing at the opening
// parenthesis after the name. // parenthesis after the name, or at the double-colon after the initial
// function scope name.
func (p *parser) finishParsingFunctionCall(name Token) (Expression, hcl.Diagnostics) { func (p *parser) finishParsingFunctionCall(name Token) (Expression, hcl.Diagnostics) {
var diags hcl.Diagnostics
openTok := p.Read() openTok := p.Read()
if openTok.Type != TokenOParen { if openTok.Type != TokenOParen && openTok.Type != TokenDoubleColon {
// should never happen if callers behave // should never happen if callers behave
panic("finishParsingFunctionCall called with non-parenthesis as next token") panic("finishParsingFunctionCall called with unsupported next token")
}
nameStr := string(name.Bytes)
nameEndPos := name.Range.End
for openTok.Type == TokenDoubleColon {
nextName := p.Read()
if nextName.Type != TokenIdent {
diag := hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Missing function name",
Detail: "Function scope resolution symbol :: must be followed by a function name in this scope.",
Subject: &nextName.Range,
Context: hcl.RangeBetween(name.Range, nextName.Range).Ptr(),
}
diags = append(diags, &diag)
p.recoverOver(TokenOParen)
return &ExprSyntaxError{
ParseDiags: hcl.Diagnostics{&diag},
Placeholder: cty.DynamicVal,
SrcRange: hcl.RangeBetween(name.Range, nextName.Range),
}, diags
}
// Initial versions of HCLv2 didn't support function namespaces, and
// so for backward compatibility we just treat namespaced functions
// as weird names with "::" separators in them, saved as a string
// to keep the API unchanged. FunctionCallExpr also has some special
// handling of names containing :: when referring to a function that
// doesn't exist in EvalContext, to return better error messages
// when namespaces are used incorrectly.
nameStr = nameStr + "::" + string(nextName.Bytes)
nameEndPos = nextName.Range.End
openTok = p.Read()
}
nameRange := hcl.Range{
Filename: name.Range.Filename,
Start: name.Range.Start,
End: nameEndPos,
}
if openTok.Type != TokenOParen {
diag := hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Missing open parenthesis",
Detail: "Function selector must be followed by an open parenthesis to begin the function call.",
Subject: &openTok.Range,
Context: hcl.RangeBetween(name.Range, openTok.Range).Ptr(),
}
diags = append(diags, &diag)
p.recoverOver(TokenOParen)
return &ExprSyntaxError{
ParseDiags: hcl.Diagnostics{&diag},
Placeholder: cty.DynamicVal,
SrcRange: hcl.RangeBetween(name.Range, openTok.Range),
}, diags
} }
var args []Expression var args []Expression
var diags hcl.Diagnostics
var expandFinal bool var expandFinal bool
var closeTok Token var closeTok Token
@ -1218,7 +1278,7 @@ Token:
diags = append(diags, &hcl.Diagnostic{ diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError, Severity: hcl.DiagError,
Summary: "Unterminated function call", Summary: "Unterminated function call",
Detail: "There is no closing parenthesis for this function call before the end of the file. This may be caused by incorrect parethesis nesting elsewhere in this file.", Detail: "There is no closing parenthesis for this function call before the end of the file. This may be caused by incorrect parenthesis nesting elsewhere in this file.",
Subject: hcl.RangeBetween(name.Range, openTok.Range).Ptr(), Subject: hcl.RangeBetween(name.Range, openTok.Range).Ptr(),
}) })
default: default:
@ -1245,12 +1305,12 @@ Token:
p.PopIncludeNewlines() p.PopIncludeNewlines()
return &FunctionCallExpr{ return &FunctionCallExpr{
Name: string(name.Bytes), Name: nameStr,
Args: args, Args: args,
ExpandFinal: expandFinal, ExpandFinal: expandFinal,
NameRange: name.Range, NameRange: nameRange,
OpenParenRange: openTok.Range, OpenParenRange: openTok.Range,
CloseParenRange: closeTok.Range, CloseParenRange: closeTok.Range,
}, diags }, diags

View File

@ -1,13 +1,12 @@
//line scan_string_lit.rl:1
// Copyright (c) HashiCorp, Inc. // Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0 // SPDX-License-Identifier: MPL-2.0
//line scan_string_lit.rl:1
package hclsyntax package hclsyntax
// This file is generated from scan_string_lit.rl. DO NOT EDIT. // This file is generated from scan_string_lit.rl. DO NOT EDIT.
//line scan_string_lit.go:9 //line scan_string_lit.go:11
var _hclstrtok_actions []byte = []byte{ var _hclstrtok_actions []byte = []byte{
0, 1, 0, 1, 1, 2, 1, 0, 0, 1, 0, 1, 1, 2, 1, 0,
} }
@ -117,12 +116,12 @@ const hclstrtok_error int = 0
const hclstrtok_en_quoted int = 10 const hclstrtok_en_quoted int = 10
const hclstrtok_en_unquoted int = 4 const hclstrtok_en_unquoted int = 4
//line scan_string_lit.rl:10 //line scan_string_lit.rl:12
func scanStringLit(data []byte, quoted bool) [][]byte { func scanStringLit(data []byte, quoted bool) [][]byte {
var ret [][]byte var ret [][]byte
//line scan_string_lit.rl:61 //line scan_string_lit.rl:63
// Ragel state // Ragel state
p := 0 // "Pointer" into data p := 0 // "Pointer" into data
@ -147,11 +146,11 @@ func scanStringLit(data []byte, quoted bool) [][]byte {
ret = append(ret, data[ts:te]) ret = append(ret, data[ts:te])
}*/ }*/
//line scan_string_lit.go:154 //line scan_string_lit.go:156
{ {
} }
//line scan_string_lit.go:158 //line scan_string_lit.go:160
{ {
var _klen int var _klen int
var _trans int var _trans int
@ -232,7 +231,7 @@ func scanStringLit(data []byte, quoted bool) [][]byte {
_acts++ _acts++
switch _hclstrtok_actions[_acts-1] { switch _hclstrtok_actions[_acts-1] {
case 0: case 0:
//line scan_string_lit.rl:40 //line scan_string_lit.rl:42
// If te is behind p then we've skipped over some literal // If te is behind p then we've skipped over some literal
// characters which we must now return. // characters which we must now return.
@ -242,12 +241,12 @@ func scanStringLit(data []byte, quoted bool) [][]byte {
ts = p ts = p
case 1: case 1:
//line scan_string_lit.rl:48 //line scan_string_lit.rl:50
te = p te = p
ret = append(ret, data[ts:te]) ret = append(ret, data[ts:te])
//line scan_string_lit.go:253 //line scan_string_lit.go:255
} }
} }
@ -270,12 +269,12 @@ func scanStringLit(data []byte, quoted bool) [][]byte {
__acts++ __acts++
switch _hclstrtok_actions[__acts-1] { switch _hclstrtok_actions[__acts-1] {
case 1: case 1:
//line scan_string_lit.rl:48 //line scan_string_lit.rl:50
te = p te = p
ret = append(ret, data[ts:te]) ret = append(ret, data[ts:te])
//line scan_string_lit.go:278 //line scan_string_lit.go:280
} }
} }
} }
@ -285,7 +284,7 @@ func scanStringLit(data []byte, quoted bool) [][]byte {
} }
} }
//line scan_string_lit.rl:89 //line scan_string_lit.rl:91
if te < p { if te < p {
// Collect any leftover literal characters at the end of the input // Collect any leftover literal characters at the end of the input

View File

@ -1,3 +1,5 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package hclsyntax package hclsyntax

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,5 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package hclsyntax package hclsyntax
@ -53,6 +55,7 @@ func scanTokens(data []byte, filename string, start hcl.Pos, mode scanMode) []To
LogicalAnd = "&&"; LogicalAnd = "&&";
LogicalOr = "||"; LogicalOr = "||";
DoubleColon = "::";
Ellipsis = "..."; Ellipsis = "...";
FatArrow = "=>"; FatArrow = "=>";
@ -294,6 +297,7 @@ func scanTokens(data []byte, filename string, start hcl.Pos, mode scanMode) []To
LessThanEqual => { token(TokenLessThanEq); }; LessThanEqual => { token(TokenLessThanEq); };
LogicalAnd => { token(TokenAnd); }; LogicalAnd => { token(TokenAnd); };
LogicalOr => { token(TokenOr); }; LogicalOr => { token(TokenOr); };
DoubleColon => { token(TokenDoubleColon); };
Ellipsis => { token(TokenEllipsis); }; Ellipsis => { token(TokenEllipsis); };
FatArrow => { token(TokenFatArrow); }; FatArrow => { token(TokenFatArrow); };
SelfToken => { selfToken() }; SelfToken => { selfToken() };

View File

@ -668,7 +668,7 @@ a == b equal
a != b not equal a != b not equal
``` ```
Two values are equal if the are of identical types and their values are Two values are equal if they are of identical types and their values are
equal as defined in the HCL syntax-agnostic information model. The equality equal as defined in the HCL syntax-agnostic information model. The equality
operators are commutative and opposite, such that `(a == b) == !(a != b)` operators are commutative and opposite, such that `(a == b) == !(a != b)`
and `(a == b) == (b == a)` for all values `a` and `b`. and `(a == b) == (b == a)` for all values `a` and `b`.

View File

@ -63,8 +63,9 @@ const (
TokenDot TokenType = '.' TokenDot TokenType = '.'
TokenComma TokenType = ',' TokenComma TokenType = ','
TokenEllipsis TokenType = '…' TokenDoubleColon TokenType = '⸬'
TokenFatArrow TokenType = '⇒' TokenEllipsis TokenType = '…'
TokenFatArrow TokenType = '⇒'
TokenQuestion TokenType = '?' TokenQuestion TokenType = '?'
TokenColon TokenType = ':' TokenColon TokenType = ':'

View File

@ -1,11 +1,11 @@
// Code generated by "stringer -type TokenType -output token_type_string.go"; DO NOT EDIT. // Code generated by "stringer -type TokenType -output token_type_string.go token_type.go"; DO NOT EDIT.
package hclsyntax package hclsyntax
import "strconv" import "strconv"
func _() { func _() {
// An "invalid array index" compiler error signifies that the constant values have changed. // An "invalid array index" compiler error signifies that the constant values (55) have changed.
// Re-run the stringer command to generate them again. // Re-run the stringer command to generate them again.
var x [1]struct{} var x [1]struct{}
_ = x[TokenOBrace-123] _ = x[TokenOBrace-123]
@ -35,6 +35,7 @@ func _() {
_ = x[TokenBang-33] _ = x[TokenBang-33]
_ = x[TokenDot-46] _ = x[TokenDot-46]
_ = x[TokenComma-44] _ = x[TokenComma-44]
_ = x[TokenDoubleColon-11820]
_ = x[TokenEllipsis-8230] _ = x[TokenEllipsis-8230]
_ = x[TokenFatArrow-8658] _ = x[TokenFatArrow-8658]
_ = x[TokenQuestion-63] _ = x[TokenQuestion-63]
@ -64,7 +65,7 @@ func _() {
_ = x[TokenNil-0] _ = x[TokenNil-0]
} }
const _TokenType_name = "TokenNilTokenNewlineTokenBangTokenPercentTokenBitwiseAndTokenApostropheTokenOParenTokenCParenTokenStarTokenPlusTokenCommaTokenMinusTokenDotTokenSlashTokenColonTokenSemicolonTokenLessThanTokenEqualTokenGreaterThanTokenQuestionTokenCommentTokenOHeredocTokenIdentTokenNumberLitTokenQuotedLitTokenStringLitTokenOBrackTokenCBrackTokenBitwiseXorTokenBacktickTokenCHeredocTokenOBraceTokenBitwiseOrTokenCBraceTokenBitwiseNotTokenOQuoteTokenCQuoteTokenTemplateControlTokenEllipsisTokenFatArrowTokenTemplateSeqEndTokenAndTokenOrTokenTemplateInterpTokenEqualOpTokenNotEqualTokenLessThanEqTokenGreaterThanEqTokenEOFTokenTabsTokenQuotedNewlineTokenStarStarTokenInvalidTokenBadUTF8" const _TokenType_name = "TokenNilTokenNewlineTokenBangTokenPercentTokenBitwiseAndTokenApostropheTokenOParenTokenCParenTokenStarTokenPlusTokenCommaTokenMinusTokenDotTokenSlashTokenColonTokenSemicolonTokenLessThanTokenEqualTokenGreaterThanTokenQuestionTokenCommentTokenOHeredocTokenIdentTokenNumberLitTokenQuotedLitTokenStringLitTokenOBrackTokenCBrackTokenBitwiseXorTokenBacktickTokenCHeredocTokenOBraceTokenBitwiseOrTokenCBraceTokenBitwiseNotTokenOQuoteTokenCQuoteTokenTemplateControlTokenEllipsisTokenFatArrowTokenTemplateSeqEndTokenAndTokenOrTokenTemplateInterpTokenEqualOpTokenNotEqualTokenLessThanEqTokenGreaterThanEqTokenEOFTokenTabsTokenQuotedNewlineTokenStarStarTokenDoubleColonTokenInvalidTokenBadUTF8"
var _TokenType_map = map[TokenType]string{ var _TokenType_map = map[TokenType]string{
0: _TokenType_name[0:8], 0: _TokenType_name[0:8],
@ -119,8 +120,9 @@ var _TokenType_map = map[TokenType]string{
9225: _TokenType_name[603:612], 9225: _TokenType_name[603:612],
9252: _TokenType_name[612:630], 9252: _TokenType_name[612:630],
10138: _TokenType_name[630:643], 10138: _TokenType_name[630:643],
65533: _TokenType_name[643:655], 11820: _TokenType_name[643:659],
128169: _TokenType_name[655:667], 65533: _TokenType_name[659:671],
128169: _TokenType_name[671:683],
} }
func (i TokenType) String() string { func (i TokenType) String() string {

View File

@ -234,6 +234,11 @@ func spaceAfterToken(subject, before, after *Token) bool {
// Don't split a function name from open paren in a call // Don't split a function name from open paren in a call
return false return false
case (subject.Type == hclsyntax.TokenIdent && after.Type == hclsyntax.TokenDoubleColon) ||
(subject.Type == hclsyntax.TokenDoubleColon && after.Type == hclsyntax.TokenIdent):
// Don't split namespace segments in a function call
return false
case subject.Type == hclsyntax.TokenDot || after.Type == hclsyntax.TokenDot: case subject.Type == hclsyntax.TokenDot || after.Type == hclsyntax.TokenDot:
// Don't use spaces around attribute access dots // Don't use spaces around attribute access dots
return false return false
@ -450,11 +455,11 @@ func tokenBracketChange(tok *Token) int {
// formatLine represents a single line of source code for formatting purposes, // formatLine represents a single line of source code for formatting purposes,
// splitting its tokens into up to three "cells": // splitting its tokens into up to three "cells":
// //
// lead: always present, representing everything up to one of the others // - lead: always present, representing everything up to one of the others
// assign: if line contains an attribute assignment, represents the tokens // - assign: if line contains an attribute assignment, represents the tokens
// starting at (and including) the equals symbol // starting at (and including) the equals symbol
// comment: if line contains any non-comment tokens and ends with a // - comment: if line contains any non-comment tokens and ends with a
// single-line comment token, represents the comment. // single-line comment token, represents the comment.
// //
// When formatting, the leading spaces of the first tokens in each of these // When formatting, the leading spaces of the first tokens in each of these
// cells is adjusted to align vertically their occurences on consecutive // cells is adjusted to align vertically their occurences on consecutive

View File

@ -10,7 +10,7 @@ import (
"github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2"
) )
//go:generate stringer -type tokenType scanner.go //go:generate go run golang.org/x/tools/cmd/stringer -type tokenType scanner.go
type tokenType rune type tokenType rune
const ( const (

View File

@ -4,6 +4,24 @@ package json
import "strconv" import "strconv"
func _() {
// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
var x [1]struct{}
_ = x[tokenBraceO-123]
_ = x[tokenBraceC-125]
_ = x[tokenBrackO-91]
_ = x[tokenBrackC-93]
_ = x[tokenComma-44]
_ = x[tokenColon-58]
_ = x[tokenKeyword-75]
_ = x[tokenString-83]
_ = x[tokenNumber-78]
_ = x[tokenEOF-9220]
_ = x[tokenInvalid-0]
_ = x[tokenEquals-61]
}
const _tokenType_name = "tokenInvalidtokenCommatokenColontokenEqualstokenKeywordtokenNumbertokenStringtokenBrackOtokenBrackCtokenBraceOtokenBraceCtokenEOF" const _tokenType_name = "tokenInvalidtokenCommatokenColontokenEqualstokenKeywordtokenNumbertokenStringtokenBrackOtokenBrackCtokenBraceOtokenBraceCtokenEOF"
var _tokenType_map = map[tokenType]string{ var _tokenType_map = map[tokenType]string{

11
vendor/github.com/hashicorp/hcl/v2/tools.go generated vendored Normal file
View File

@ -0,0 +1,11 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build tools
// +build tools
package hcl
import (
_ "golang.org/x/tools/cmd/stringer"
)

2
vendor/modules.txt vendored
View File

@ -446,7 +446,7 @@ github.com/hashicorp/go-cty-funcs/cidr
github.com/hashicorp/go-cty-funcs/crypto github.com/hashicorp/go-cty-funcs/crypto
github.com/hashicorp/go-cty-funcs/encoding github.com/hashicorp/go-cty-funcs/encoding
github.com/hashicorp/go-cty-funcs/uuid github.com/hashicorp/go-cty-funcs/uuid
# github.com/hashicorp/hcl/v2 v2.19.1 # github.com/hashicorp/hcl/v2 v2.20.1
## explicit; go 1.18 ## explicit; go 1.18
github.com/hashicorp/hcl/v2 github.com/hashicorp/hcl/v2
github.com/hashicorp/hcl/v2/ext/customdecode github.com/hashicorp/hcl/v2/ext/customdecode