aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/hashicorp
diff options
context:
space:
mode:
authorNiall Sheridan <nsheridan@gmail.com>2016-07-17 17:16:14 +0100
committerNiall Sheridan <nsheridan@gmail.com>2016-07-17 18:24:20 +0100
commitc9849d667ab55c23d343332a11afb3eb8ede3f2d (patch)
tree86684d5481d8b12be84ea1a3a8f32afaac007efa /vendor/github.com/hashicorp
parent49f40a952943f26494d6407dc608b50b2ec0df7f (diff)
Update vendor libs
Diffstat (limited to 'vendor/github.com/hashicorp')
-rw-r--r--vendor/github.com/hashicorp/hcl/README.md17
-rw-r--r--vendor/github.com/hashicorp/hcl/decoder.go7
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/ast/ast.go6
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/parser/parser.go49
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go17
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go13
-rw-r--r--vendor/github.com/hashicorp/hcl/hcl/token/token.go5
-rw-r--r--vendor/github.com/hashicorp/hcl/json/parser/parser.go6
8 files changed, 99 insertions, 21 deletions
diff --git a/vendor/github.com/hashicorp/hcl/README.md b/vendor/github.com/hashicorp/hcl/README.md
index 3d5b8bd..e292d59 100644
--- a/vendor/github.com/hashicorp/hcl/README.md
+++ b/vendor/github.com/hashicorp/hcl/README.md
@@ -81,9 +81,20 @@ FOO
* Boolean values: `true`, `false`
* Arrays can be made by wrapping it in `[]`. Example:
- `["foo", "bar", 42]`. Arrays can contain primitives
- and other arrays, but cannot contain objects. Objects must
- use the block syntax shown below.
+ `["foo", "bar", 42]`. Arrays can contain primitives,
+ other arrays, and objects. As an alternative, lists
+ of objects can be created with repeated blocks, using
+ this structure:
+
+ ```hcl
+ service {
+ key = "value"
+ }
+
+ service {
+ key = "value"
+ }
+ ```
Objects and nested objects are created using the structure shown below:
diff --git a/vendor/github.com/hashicorp/hcl/decoder.go b/vendor/github.com/hashicorp/hcl/decoder.go
index 02888d2..cfddbf3 100644
--- a/vendor/github.com/hashicorp/hcl/decoder.go
+++ b/vendor/github.com/hashicorp/hcl/decoder.go
@@ -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
diff --git a/vendor/github.com/hashicorp/hcl/hcl/ast/ast.go b/vendor/github.com/hashicorp/hcl/hcl/ast/ast.go
index f8bb71a..692ac24 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/ast/ast.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/ast/ast.go
@@ -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()
}
diff --git a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go
index cc129b6..f46ed4c 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go
@@ -79,6 +79,13 @@ func (p *Parser) objectList() (*ast.ObjectList, error) {
}
node.Add(n)
+
+ // object lists can be optionally comma-delimited e.g. when a list of maps
+ // is being expressed, so a comma is allowed here - it's simply consumed
+ tok := p.scan()
+ if tok.Type != token.COMMA {
+ p.unscan()
+ }
}
return node, nil
}
@@ -220,8 +227,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})
@@ -300,15 +318,20 @@ func (p *Parser) listType() (*ast.ListType, error) {
needComma := false
for {
tok := p.scan()
- switch tok.Type {
- case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
- if needComma {
+ if needComma {
+ switch tok.Type {
+ case token.COMMA, token.RBRACK:
+ default:
return nil, &PosError{
Pos: tok.Pos,
- Err: fmt.Errorf("unexpected token: %s. Expecting %s", tok.Type, token.COMMA),
+ Err: fmt.Errorf(
+ "error parsing list, expected comma or list end, got: %s",
+ tok.Type),
}
}
-
+ }
+ switch tok.Type {
+ case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
node, err := p.literalType()
if err != nil {
return nil, err
@@ -320,7 +343,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
@@ -332,6 +355,18 @@ func (p *Parser) listType() (*ast.ListType, error) {
needComma = false
continue
+ case token.LBRACE:
+ // Looks like a nested object, so parse it out
+ node, err := p.objectType()
+ if err != nil {
+ return nil, &PosError{
+ Pos: tok.Pos,
+ Err: fmt.Errorf(
+ "error while trying to parse object within list: %s", err),
+ }
+ }
+ l.Add(node)
+ needComma = true
case token.BOOL:
// TODO(arslan) should we support? not supported by HCL yet
case token.LBRACK:
diff --git a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
index a3f34a7..b204165 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go
@@ -469,7 +469,7 @@ func (s *Scanner) scanString() {
// read character after quote
ch := s.next()
- if ch == '\n' || ch < 0 || ch == eof {
+ if ch < 0 || ch == eof {
s.err("literal not terminated")
return
}
@@ -525,16 +525,27 @@ func (s *Scanner) scanEscape() rune {
// scanDigits scans a rune with the given base for n times. For example an
// octal notation \184 would yield in scanDigits(ch, 8, 3)
func (s *Scanner) scanDigits(ch rune, base, n int) rune {
+ start := n
for n > 0 && digitVal(ch) < base {
ch = s.next()
+ if ch == eof {
+ // If we see an EOF, we halt any more scanning of digits
+ // immediately.
+ break
+ }
+
n--
}
if n > 0 {
s.err("illegal char escape")
}
- // we scanned all digits, put the last non digit char back
- s.unread()
+ if n != start {
+ // we scanned all digits, put the last non digit char back,
+ // only if we read anything at all
+ s.unread()
+ }
+
return ch
}
diff --git a/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go b/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go
index e87ac63..956c899 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/strconv/quote.go
@@ -27,9 +27,6 @@ func Unquote(s string) (t string, err error) {
if quote != '"' {
return "", ErrSyntax
}
- if contains(s, '\n') {
- return "", ErrSyntax
- }
// Is it trivial? Avoid allocation.
if !contains(s, '\\') && !contains(s, quote) && !contains(s, '$') {
@@ -49,7 +46,7 @@ func Unquote(s string) (t string, err error) {
for len(s) > 0 {
// If we're starting a '${}' then let it through un-unquoted.
// Specifically: we don't unquote any characters within the `${}`
- // section, except for escaped quotes, which we handle specifically.
+ // section, except for escaped backslashes, which we handle specifically.
if s[0] == '$' && len(s) > 1 && s[1] == '{' {
buf = append(buf, '$', '{')
s = s[2:]
@@ -64,10 +61,12 @@ func Unquote(s string) (t string, err error) {
s = s[size:]
- // We special case escaped double quotes in interpolations, converting
- // them to straight double quotes.
+ // We special case escaped backslashes in interpolations, converting
+ // them to their unescaped equivalents.
if r == '\\' {
- if q, _ := utf8.DecodeRuneInString(s); q == '"' {
+ q, _ := utf8.DecodeRuneInString(s)
+ switch q {
+ case '\\':
continue
}
}
diff --git a/vendor/github.com/hashicorp/hcl/hcl/token/token.go b/vendor/github.com/hashicorp/hcl/hcl/token/token.go
index 6e99498..e37c066 100644
--- a/vendor/github.com/hashicorp/hcl/hcl/token/token.go
+++ b/vendor/github.com/hashicorp/hcl/hcl/token/token.go
@@ -152,6 +152,11 @@ func (t Token) Value() interface{} {
f = strconv.Unquote
}
+ // This case occurs if json null is used
+ if t.Text == "" {
+ return ""
+ }
+
v, err := f(t.Text)
if err != nil {
panic(fmt.Sprintf("unquote %s err: %s", t.Text, err))
diff --git a/vendor/github.com/hashicorp/hcl/json/parser/parser.go b/vendor/github.com/hashicorp/hcl/json/parser/parser.go
index 65d56c9..3a62ec3 100644
--- a/vendor/github.com/hashicorp/hcl/json/parser/parser.go
+++ b/vendor/github.com/hashicorp/hcl/json/parser/parser.go
@@ -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: