Merge pull request #11100 from hashicorp/b-update-hcl

vendor: update HCL
This commit is contained in:
Mitchell Hashimoto 2017-01-08 16:53:53 -08:00 committed by GitHub
commit dd1f930f4e
4 changed files with 48 additions and 31 deletions

View File

@ -91,7 +91,7 @@ func (d *decoder) decode(name string, node ast.Node, result reflect.Value) error
return d.decodeBool(name, node, result)
case reflect.Float64:
return d.decodeFloat(name, node, result)
case reflect.Int:
case reflect.Int, reflect.Int32, reflect.Int64:
return d.decodeInt(name, node, result)
case reflect.Interface:
// When we see an interface, we make our own thing
@ -164,7 +164,11 @@ func (d *decoder) decodeInt(name string, node ast.Node, result reflect.Value) er
return err
}
result.Set(reflect.ValueOf(int(v)))
if result.Kind() == reflect.Interface {
result.Set(reflect.ValueOf(int(v)))
} else {
result.SetInt(v)
}
return nil
case token.STRING:
v, err := strconv.ParseInt(n.Token.Value().(string), 0, 0)
@ -172,7 +176,11 @@ func (d *decoder) decodeInt(name string, node ast.Node, result reflect.Value) er
return err
}
result.Set(reflect.ValueOf(int(v)))
if result.Kind() == reflect.Interface {
result.Set(reflect.ValueOf(int(v)))
} else {
result.SetInt(v)
}
return nil
}
}

View File

@ -58,7 +58,7 @@ func processFile(filename string, in io.Reader, out io.Writer, stdin bool, opts
res, err := printer.Format(src)
if err != nil {
return err
return fmt.Errorf("In %s: %s", filename, err)
}
if !bytes.Equal(src, res) {

View File

@ -207,7 +207,7 @@ func (p *printer) literalType(lit *ast.LiteralType) []byte {
case token.STRING:
// If this is a multiline string, poison lines 2+ so we don't
// indent them.
if bytes.ContainsRune(result, '\n') {
if bytes.IndexRune(result, '\n') >= 0 {
result = p.heredocIndent(result)
}
}
@ -503,7 +503,16 @@ func (p *printer) list(l *ast.ListType) []byte {
val := p.output(item)
curLen := len(val)
buf.Write(p.indent(val))
buf.WriteString(",")
// if this item is a heredoc, then we output the comma on
// the next line. This is the only case this happens.
comma := []byte{','}
if lit, ok := item.(*ast.LiteralType); ok && lit.Token.Type == token.HEREDOC {
buf.WriteByte(newline)
comma = p.indent(comma)
}
buf.Write(comma)
if lit, ok := item.(*ast.LiteralType); ok && lit.LineComment != nil {
// if the next item doesn't have any comments, do not align

50
vendor/vendor.json vendored
View File

@ -1663,70 +1663,70 @@
"revision": "7e3c02b30806fa5779d3bdfc152ce4c6f40e7b38"
},
{
"checksumSHA1": "8OPDk+bKyRGJoKcS4QNw9F7dpE8=",
"checksumSHA1": "Ok3Csn6Voou7pQT6Dv2mkwpqFtw=",
"path": "github.com/hashicorp/hcl",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "XQmjDva9JCGGkIecOgwtBEMCJhU=",
"path": "github.com/hashicorp/hcl/hcl/ast",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "5HVecyfmcTm6OTffEi6LGayQf5M=",
"checksumSHA1": "DaQmLi48oUAwctWcX6A6DNN61UY=",
"path": "github.com/hashicorp/hcl/hcl/fmtcmd",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "vF6LLywGDoAaccTcAGrcY7mYvZc=",
"path": "github.com/hashicorp/hcl/hcl/parser",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "1k1PQRPdYEjeTbXsYz5ZP+Won1w=",
"checksumSHA1": "K1gXmpTINkcQEh4tBjzq9UeKy/U=",
"path": "github.com/hashicorp/hcl/hcl/printer",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "z6wdP4mRw4GVjShkNHDaOWkbxS0=",
"path": "github.com/hashicorp/hcl/hcl/scanner",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "oS3SCN9Wd6D8/LG0Yx1fu84a7gI=",
"path": "github.com/hashicorp/hcl/hcl/strconv",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "c6yprzj06ASwCo18TtbbNNBHljA=",
"path": "github.com/hashicorp/hcl/hcl/token",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "138aCV5n8n7tkGYMsMVQQnnLq+0=",
"path": "github.com/hashicorp/hcl/json/parser",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "YdvFsNOMSWMLnY6fcliWQa0O5Fw=",
"path": "github.com/hashicorp/hcl/json/scanner",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "fNlXQCQEnb+B3k5UDL/r15xtSJY=",
"path": "github.com/hashicorp/hcl/json/token",
"revision": "b97feebd3db0a834bb92535b0950e7d5d4527a58",
"revisionTime": "2016-11-30T20:58:18Z"
"revision": "eb6f65b2d77ed5078887f960ff570fbddbbeb49d",
"revisionTime": "2017-01-09T00:25:15Z"
},
{
"checksumSHA1": "2Nrl/YKrmowkRgCDLhA6UTFgYEY=",