mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: hashicorp/hcl v2.6.0
full diff: https://github.com/hashicorp/hcl/compare/v2.4.0...v2.6.0 v2.6.0 ------------------------- Enhancements: - hcldec: Add a new Spec, ValidateSpec, which allows custom validation of values at decode-time. Bugs Fixed: - hclsyntax: Fix panic with combination of sequences and null arguments - hclsyntax: Fix handling of unknown values and sequences v2.5.1 ------------------------- - hclwrite: handle legacy dot access of numeric indexes. (#369) - hclwrite: Fix panic for dotted full splat (foo.*) v2.5.0 ------------------------- - hclwrite: Generate multi-line objects and maps. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
24
vendor/github.com/hashicorp/hcl/v2/CHANGELOG.md
generated
vendored
24
vendor/github.com/hashicorp/hcl/v2/CHANGELOG.md
generated
vendored
@ -1,5 +1,29 @@
|
||||
# HCL Changelog
|
||||
|
||||
## v2.6.0 (June 4, 2020)
|
||||
|
||||
### Enhancements
|
||||
|
||||
* hcldec: Add a new `Spec`, `ValidateSpec`, which allows custom validation of values at decode-time. ([#387](https://github.com/hashicorp/hcl/pull/387))
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
* hclsyntax: Fix panic with combination of sequences and null arguments ([#386](https://github.com/hashicorp/hcl/pull/386))
|
||||
* hclsyntax: Fix handling of unknown values and sequences ([#386](https://github.com/hashicorp/hcl/pull/386))
|
||||
|
||||
## v2.5.1 (May 14, 2020)
|
||||
|
||||
### Bugs Fixed
|
||||
|
||||
* hclwrite: handle legacy dot access of numeric indexes. ([#369](https://github.com/hashicorp/hcl/pull/369))
|
||||
* hclwrite: Fix panic for dotted full splat (`foo.*`) ([#374](https://github.com/hashicorp/hcl/pull/374))
|
||||
|
||||
## v2.5.0 (May 6, 2020)
|
||||
|
||||
### Enhancements
|
||||
|
||||
* hclwrite: Generate multi-line objects and maps. ([#372](https://github.com/hashicorp/hcl/pull/372))
|
||||
|
||||
## v2.4.0 (Apr 13, 2020)
|
||||
|
||||
### Enhancements
|
||||
|
4
vendor/github.com/hashicorp/hcl/v2/diagnostic.go
generated
vendored
4
vendor/github.com/hashicorp/hcl/v2/diagnostic.go
generated
vendored
@ -22,14 +22,14 @@ const (
|
||||
)
|
||||
|
||||
// Diagnostic represents information to be presented to a user about an
|
||||
// error or anomoly in parsing or evaluating configuration.
|
||||
// error or anomaly in parsing or evaluating configuration.
|
||||
type Diagnostic struct {
|
||||
Severity DiagnosticSeverity
|
||||
|
||||
// Summary and Detail contain the English-language description of the
|
||||
// problem. Summary is a terse description of the general problem and
|
||||
// detail is a more elaborate, often-multi-sentence description of
|
||||
// the probem and what might be done to solve it.
|
||||
// the problem and what might be done to solve it.
|
||||
Summary string
|
||||
Detail string
|
||||
|
||||
|
61
vendor/github.com/hashicorp/hcl/v2/hclsyntax/expression.go
generated
vendored
61
vendor/github.com/hashicorp/hcl/v2/hclsyntax/expression.go
generated
vendored
@ -260,6 +260,20 @@ func (e *FunctionCallExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnosti
|
||||
}
|
||||
|
||||
switch {
|
||||
case expandVal.Type().Equals(cty.DynamicPseudoType):
|
||||
if expandVal.IsNull() {
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: "Invalid expanding argument value",
|
||||
Detail: "The expanding argument (indicated by ...) must not be null.",
|
||||
Subject: expandExpr.Range().Ptr(),
|
||||
Context: e.Range().Ptr(),
|
||||
Expression: expandExpr,
|
||||
EvalContext: ctx,
|
||||
})
|
||||
return cty.DynamicVal, diags
|
||||
}
|
||||
return cty.DynamicVal, diags
|
||||
case expandVal.Type().IsTupleType() || expandVal.Type().IsListType() || expandVal.Type().IsSetType():
|
||||
if expandVal.IsNull() {
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
@ -406,22 +420,39 @@ func (e *FunctionCallExpr) Value(ctx *hcl.EvalContext) (cty.Value, hcl.Diagnosti
|
||||
} else {
|
||||
param = varParam
|
||||
}
|
||||
argExpr := e.Args[i]
|
||||
|
||||
// TODO: we should also unpick a PathError here and show the
|
||||
// path to the deep value where the error was detected.
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: "Invalid function argument",
|
||||
Detail: fmt.Sprintf(
|
||||
"Invalid value for %q parameter: %s.",
|
||||
param.Name, err,
|
||||
),
|
||||
Subject: argExpr.StartRange().Ptr(),
|
||||
Context: e.Range().Ptr(),
|
||||
Expression: argExpr,
|
||||
EvalContext: ctx,
|
||||
})
|
||||
// this can happen if an argument is (incorrectly) null.
|
||||
if i > len(e.Args)-1 {
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: "Invalid function argument",
|
||||
Detail: fmt.Sprintf(
|
||||
"Invalid value for %q parameter: %s.",
|
||||
param.Name, err,
|
||||
),
|
||||
Subject: args[len(params)].StartRange().Ptr(),
|
||||
Context: e.Range().Ptr(),
|
||||
Expression: e,
|
||||
EvalContext: ctx,
|
||||
})
|
||||
} else {
|
||||
argExpr := e.Args[i]
|
||||
|
||||
// TODO: we should also unpick a PathError here and show the
|
||||
// path to the deep value where the error was detected.
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
Severity: hcl.DiagError,
|
||||
Summary: "Invalid function argument",
|
||||
Detail: fmt.Sprintf(
|
||||
"Invalid value for %q parameter: %s.",
|
||||
param.Name, err,
|
||||
),
|
||||
Subject: argExpr.StartRange().Ptr(),
|
||||
Context: e.Range().Ptr(),
|
||||
Expression: argExpr,
|
||||
EvalContext: ctx,
|
||||
})
|
||||
}
|
||||
|
||||
default:
|
||||
diags = append(diags, &hcl.Diagnostic{
|
||||
|
1
vendor/github.com/hashicorp/hcl/v2/hclsyntax/parser.go
generated
vendored
1
vendor/github.com/hashicorp/hcl/v2/hclsyntax/parser.go
generated
vendored
@ -670,6 +670,7 @@ Traversal:
|
||||
trav := make(hcl.Traversal, 0, 1)
|
||||
var firstRange, lastRange hcl.Range
|
||||
firstRange = p.NextRange()
|
||||
lastRange = marker.Range
|
||||
for p.Peek().Type == TokenDot {
|
||||
dot := p.Read()
|
||||
|
||||
|
16
vendor/github.com/hashicorp/hcl/v2/hclwrite/generate.go
generated
vendored
16
vendor/github.com/hashicorp/hcl/v2/hclwrite/generate.go
generated
vendored
@ -119,15 +119,15 @@ func appendTokensForValue(val cty.Value, toks Tokens) Tokens {
|
||||
Type: hclsyntax.TokenOBrace,
|
||||
Bytes: []byte{'{'},
|
||||
})
|
||||
if val.LengthInt() > 0 {
|
||||
toks = append(toks, &Token{
|
||||
Type: hclsyntax.TokenNewline,
|
||||
Bytes: []byte{'\n'},
|
||||
})
|
||||
}
|
||||
|
||||
i := 0
|
||||
for it := val.ElementIterator(); it.Next(); {
|
||||
if i > 0 {
|
||||
toks = append(toks, &Token{
|
||||
Type: hclsyntax.TokenComma,
|
||||
Bytes: []byte{','},
|
||||
})
|
||||
}
|
||||
eKey, eVal := it.Element()
|
||||
if hclsyntax.ValidIdentifier(eKey.AsString()) {
|
||||
toks = append(toks, &Token{
|
||||
@ -142,6 +142,10 @@ func appendTokensForValue(val cty.Value, toks Tokens) Tokens {
|
||||
Bytes: []byte{'='},
|
||||
})
|
||||
toks = appendTokensForValue(eVal, toks)
|
||||
toks = append(toks, &Token{
|
||||
Type: hclsyntax.TokenNewline,
|
||||
Bytes: []byte{'\n'},
|
||||
})
|
||||
i++
|
||||
}
|
||||
|
||||
|
27
vendor/github.com/hashicorp/hcl/v2/hclwrite/parser.go
generated
vendored
27
vendor/github.com/hashicorp/hcl/v2/hclwrite/parser.go
generated
vendored
@ -88,6 +88,16 @@ func (it inputTokens) PartitionType(ty hclsyntax.TokenType) (before, within, aft
|
||||
panic(fmt.Sprintf("didn't find any token of type %s", ty))
|
||||
}
|
||||
|
||||
func (it inputTokens) PartitionTypeOk(ty hclsyntax.TokenType) (before, within, after inputTokens, ok bool) {
|
||||
for i, t := range it.writerTokens {
|
||||
if t.Type == ty {
|
||||
return it.Slice(0, i), it.Slice(i, i+1), it.Slice(i+1, len(it.nativeTokens)), true
|
||||
}
|
||||
}
|
||||
|
||||
return inputTokens{}, inputTokens{}, inputTokens{}, false
|
||||
}
|
||||
|
||||
func (it inputTokens) PartitionTypeSingle(ty hclsyntax.TokenType) (before inputTokens, found *Token, after inputTokens) {
|
||||
before, within, after := it.PartitionType(ty)
|
||||
if within.Len() != 1 {
|
||||
@ -404,6 +414,19 @@ func parseTraversalStep(nativeStep hcl.Traverser, from inputTokens) (before inpu
|
||||
children = step.inTree.children
|
||||
before, from, after = from.Partition(nativeStep.SourceRange())
|
||||
|
||||
if inBefore, dot, from, ok := from.PartitionTypeOk(hclsyntax.TokenDot); ok {
|
||||
children.AppendUnstructuredTokens(inBefore.Tokens())
|
||||
children.AppendUnstructuredTokens(dot.Tokens())
|
||||
|
||||
valBefore, valToken, valAfter := from.PartitionTypeSingle(hclsyntax.TokenNumberLit)
|
||||
children.AppendUnstructuredTokens(valBefore.Tokens())
|
||||
key := newNumber(valToken)
|
||||
step.key = children.Append(key)
|
||||
children.AppendUnstructuredTokens(valAfter.Tokens())
|
||||
|
||||
return before, newNode(step), after
|
||||
}
|
||||
|
||||
var inBefore, oBrack, keyTokens, cBrack inputTokens
|
||||
inBefore, oBrack, from = from.PartitionType(hclsyntax.TokenOBrack)
|
||||
children.AppendUnstructuredTokens(inBefore.Tokens())
|
||||
@ -498,8 +521,8 @@ func writerTokens(nativeTokens hclsyntax.Tokens) Tokens {
|
||||
// The tokens are assumed to be in source order and non-overlapping, which
|
||||
// will be true if the token sequence from the scanner is used directly.
|
||||
func partitionTokens(toks hclsyntax.Tokens, rng hcl.Range) (start, end int) {
|
||||
// We us a linear search here because we assume tha in most cases our
|
||||
// target range is close to the beginning of the sequence, and the seqences
|
||||
// We use a linear search here because we assume that in most cases our
|
||||
// target range is close to the beginning of the sequence, and the sequences
|
||||
// are generally small for most reasonable files anyway.
|
||||
for i := 0; ; i++ {
|
||||
if i >= len(toks) {
|
||||
|
Reference in New Issue
Block a user