deps: Update github.com/hashicorp/hcl/...

This commit is contained in:
James Nugent 2016-06-24 13:20:26 +01:00
parent 1f9a2b241e
commit c39044659b
6 changed files with 59 additions and 31 deletions

View File

@ -517,6 +517,12 @@ func (d *decoder) decodeStruct(name string, node ast.Node, result reflect.Value)
structType := structVal.Type()
for i := 0; i < structType.NumField(); i++ {
fieldType := structType.Field(i)
tagParts := strings.Split(fieldType.Tag.Get(tagName), ",")
// Ignore fields with tag name "-"
if tagParts[0] == "-" {
continue
}
if fieldType.Anonymous {
fieldKind := fieldType.Type.Kind()
@ -531,7 +537,6 @@ func (d *decoder) decodeStruct(name string, node ast.Node, result reflect.Value)
// We have an embedded field. We "squash" the fields down
// if specified in the tag.
squash := false
tagParts := strings.Split(fieldType.Tag.Get(tagName), ",")
for _, tag := range tagParts[1:] {
if tag == "squash" {
squash = true

View File

@ -133,6 +133,12 @@ type ObjectItem struct {
}
func (o *ObjectItem) Pos() token.Pos {
// I'm not entirely sure what causes this, but removing this causes
// a test failure. We should investigate at some point.
if len(o.Keys) == 0 {
return token.Pos{}
}
return o.Keys[0].Pos()
}

View File

@ -25,7 +25,7 @@ var (
type Options struct {
List bool // list files whose formatting differs
Write bool // write result to (source) file instead of stdout
Diff bool // display diffs instead of rewriting files
Diff bool // display diffs of formatting changes
}
func isValidFile(f os.FileInfo, extensions []string) bool {

View File

@ -220,8 +220,19 @@ func (p *Parser) objectKey() ([]*ast.ObjectKey, error) {
return keys, nil
case token.LBRACE:
var err error
// If we have no keys, then it is a syntax error. i.e. {{}} is not
// allowed.
if len(keys) == 0 {
err = &PosError{
Pos: p.tok.Pos,
Err: fmt.Errorf("expected: IDENT | STRING got: %s", p.tok.Type),
}
}
// object
return keys, nil
return keys, err
case token.IDENT, token.STRING:
keyCount++
keys = append(keys, &ast.ObjectKey{Token: p.tok})
@ -320,7 +331,7 @@ func (p *Parser) listType() (*ast.ListType, error) {
// get next list item or we are at the end
// do a look-ahead for line comment
p.scan()
if p.lineComment != nil {
if p.lineComment != nil && len(l.List) > 0 {
lit, ok := l.List[len(l.List)-1].(*ast.LiteralType)
if ok {
lit.LineComment = p.lineComment

View File

@ -128,6 +128,12 @@ func (p *Parser) objectKey() ([]*ast.ObjectKey, error) {
Token: p.tok.HCLToken(),
})
case token.COLON:
// If we have a zero keycount it means that we never got
// an object key, i.e. `{ :`. This is a syntax error.
if keyCount == 0 {
return nil, fmt.Errorf("expected: STRING got: %s", p.tok.Type)
}
// Done
return keys, nil
case token.ILLEGAL:

54
vendor/vendor.json vendored
View File

@ -770,70 +770,70 @@
"revision": "7e3c02b30806fa5779d3bdfc152ce4c6f40e7b38"
},
{
"checksumSHA1": "5LrCq/ydlbL6pq1cdmuxiw7QV98=",
"checksumSHA1": "SJIgBfV02h1fsqCAe5DHj/JbHoM=",
"path": "github.com/hashicorp/hcl",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "WP5ODRo9+USuAsKYPu5RW3q8Epg=",
"checksumSHA1": "IxyvRpCFeoJBGl2obLKJV7RCGjg=",
"path": "github.com/hashicorp/hcl/hcl/ast",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "z03dif8bqgQ3Zk/1RGbvfgBXMXo=",
"checksumSHA1": "5HVecyfmcTm6OTffEi6LGayQf5M=",
"path": "github.com/hashicorp/hcl/hcl/fmtcmd",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "SVw0qm83Anf5T2GkYabn+f7Ibv0=",
"checksumSHA1": "cO89nXP9rKQCcm0zKGbtBCWK2ok=",
"path": "github.com/hashicorp/hcl/hcl/parser",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "CSmwxPOTz7GSpnWPF9aGkbVeR64=",
"path": "github.com/hashicorp/hcl/hcl/printer",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "WZM0q7Sya8PcGj607x1npgcEPa4=",
"path": "github.com/hashicorp/hcl/hcl/scanner",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "riN5acfVDm4j6LhWXauqiWH5n84=",
"path": "github.com/hashicorp/hcl/hcl/strconv",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "c6yprzj06ASwCo18TtbbNNBHljA=",
"path": "github.com/hashicorp/hcl/hcl/token",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "uEaK2zagnGctsUmjWt8ZYmK1Yvs=",
"checksumSHA1": "jQ45CCc1ed/nlV7bbSnx6z72q1M=",
"path": "github.com/hashicorp/hcl/json/parser",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "S1e0F9ZKSnqgOLfjDTYazRL28tA=",
"path": "github.com/hashicorp/hcl/json/scanner",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "fNlXQCQEnb+B3k5UDL/r15xtSJY=",
"path": "github.com/hashicorp/hcl/json/token",
"revision": "da486364306ed66c218be9b7953e19173447c18b",
"revisionTime": "2016-06-20T17:04:52Z"
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
},
{
"checksumSHA1": "vWW3HXm7OTOMISuZPcCSJODRYkU=",