Skip to content

chore(deps): Bump github.com/hashicorp/hcl from 1.0.1-vault-5 to 1.0.1-vault-7 #3911

chore(deps): Bump github.com/hashicorp/hcl from 1.0.1-vault-5 to 1.0.1-vault-7

chore(deps): Bump github.com/hashicorp/hcl from 1.0.1-vault-5 to 1.0.1-vault-7 #3911

Triggered via pull request November 8, 2024 17:47
Status Failure
Total duration 3m 22s
Artifacts

verify-codegen.yaml

on: pull_request
Fit to window
Zoom out
Zoom in

Annotations

4 errors and 1 warning
Verify codegen: third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/decoder.go#L1
Please run ./hack/update-codegen.sh. diff --git a/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/decoder.go b/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/decoder.go index d9a00f21..39e56f22 100644 --- a/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/decoder.go +++ b/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/decoder.go @@ -24,7 +24,18 @@ var ( // Unmarshal accepts a byte slice as input and writes the // data to the value pointed to by v. func Unmarshal(bs []byte, v interface{}) error { - root, err := parse(bs) + root, err := parse(bs, false) + if err != nil { + return err + } + + return DecodeObject(v, root) +} + +// UnmarshalErrorOnDuplicates accepts a byte slice as input and writes the +// data to the value pointed to by v but errors on duplicate attribute key. +func UnmarshalErrorOnDuplicates(bs []byte, v interface{}) error { + root, err := parse(bs, true) if err != nil { return err } @@ -35,7 +46,19 @@ func Unmarshal(bs []byte, v interface{}) error { // Decode reads the given input and decodes it into the structure // given by `out`. func Decode(out interface{}, in string) error { - obj, err := Parse(in) + return decode(out, in, false) +} + +// DecodeErrorOnDuplicates reads the given input and decodes it into the structure but errrors on duplicate attribute key +// given by `out`. +func DecodeErrorOnDuplicates(out interface{}, in string) error { + return decode(out, in, true) +} + +// decode reads the given input and decodes it into the structure given by `out`. +// takes in a boolean to determine if it should error on duplicate attribute +func decode(out interface{}, in string, errorOnDuplicateAtributes bool) error { + obj, err := parse([]byte(in), errorOnDuplicateAtributes) if err != nil { return err } @@ -393,10 +416,16 @@ func (d *decoder) decodeMap(name string, node ast.Node, result reflect.Value) er // Set the final map if we can set.Set(resultMap) + return nil } func (d *decoder) decodePtr(name string, node ast.Node, result reflect.Value) error { + // if pointer is not nil, decode into existing value + if !result.IsNil() { + return d.decode(name, node, result.Elem()) + } + // Create an element of the concrete (non pointer) type and decode // into that. Then set the value of the pointer to this type. resultType := result.Type()
Verify codegen: third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/hcl/parser/parser.go#L1
Please run ./hack/update-codegen.sh. diff --git a/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/hcl/parser/parser.go b/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/hcl/parser/parser.go index 64c83bcf..0f5d929c 100644 --- a/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/hcl/parser/parser.go +++ b/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/hcl/parser/parser.go @@ -27,22 +27,35 @@ type Parser struct { enableTrace bool indent int n int // buffer size (max = 1) + + errorOnDuplicateKeys bool } -func newParser(src []byte) *Parser { +func newParser(src []byte, errorOnDuplicateKeys bool) *Parser { return &Parser{ - sc: scanner.New(src), + sc: scanner.New(src), + errorOnDuplicateKeys: errorOnDuplicateKeys, } } // Parse returns the fully parsed source and returns the abstract syntax tree. func Parse(src []byte) (*ast.File, error) { + return parse(src, true) +} + +// Parse returns the fully parsed source and returns the abstract syntax tree. +func ParseDontErrorOnDuplicateKeys(src []byte) (*ast.File, error) { + return parse(src, false) +} + +// Parse returns the fully parsed source and returns the abstract syntax tree. +func parse(src []byte, errorOnDuplicateKeys bool) (*ast.File, error) { // normalize all line endings // since the scanner and output only work with "\n" line endings, we may // end up with dangling "\r" characters in the parsed data. src = bytes.Replace(src, []byte("\r\n"), []byte("\n"), -1) - p := newParser(src) + p := newParser(src, errorOnDuplicateKeys) return p.Parse() } @@ -65,6 +78,7 @@ func (p *Parser) Parse() (*ast.File, error) { } f.Comments = p.comments + return f, nil } @@ -76,6 +90,7 @@ func (p *Parser) objectList(obj bool) (*ast.ObjectList, error) { defer un(trace(p, "ParseObjectList")) node := &ast.ObjectList{} + seenKeys := map[string]struct{}{} for { if obj { tok := p.scan() @@ -83,11 +98,29 @@ func (p *Parser) objectList(obj bool) (*ast.ObjectList, error) { if tok.Type == token.RBRACE { break } + } n, err := p.objectItem() + if err == errEofToken { break // we are finished + } else if err != nil { + return nil, err + } + + if n.Assign.String() != "-" { + for _, key := range n.Keys { + if !p.errorOnDuplicateKeys { + break + } + _, ok := seenKeys[key.Token.Text] + if ok { + return nil, errors.New(fmt.Sprintf("The argument %q at %s was already set. Each argument can only be defined once", key.Token.Text, key.Token.Pos.String())) + + } + seenKeys[key.Token.Text] = struct{}{} + } } // we don't return a nil node, because might want to use already @@ -324,6 +357,8 @@ func (p *Parser) objectType() (*ast.ObjectType, error) { // not a RBRACE, it's an syntax error and we just return it. if err != nil && p.tok.Type != token.RBRACE { return nil, err + } else if err != nil { + return nil, err } // No error, scan and expect the ending to be a brace @@ -365,6 +400,7 @@ func (p *Parser) listType() (*ast.ListType, error) { } switch tok.Type { case token.BOOL, token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC: + node, err := p.literalType() if err != nil { return nil, err
Verify codegen: third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/parse.go#L1
Please run ./hack/update-codegen.sh. diff --git a/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/parse.go b/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/parse.go index 1fca53c4..f4cc1255 100644 --- a/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/parse.go +++ b/third_party/VENDOR-LICENSE/github.com/hashicorp/hcl/parse.go @@ -12,17 +12,20 @@ import ( // // Input can be either JSON or HCL func ParseBytes(in []byte) (*ast.File, error) { - return parse(in) + return parse(in, true) } // ParseString accepts input as a string and returns ast tree. func ParseString(input string) (*ast.File, error) { - return parse([]byte(input)) + return parse([]byte(input), true) } -func parse(in []byte) (*ast.File, error) { +func parse(in []byte, errorOnDuplicateKeys bool) (*ast.File, error) { switch lexMode(in) { case lexModeHcl: + if !errorOnDuplicateKeys { + return hclParser.ParseDontErrorOnDuplicateKeys(in) + } return hclParser.Parse(in) case lexModeJson: return jsonParser.Parse(in) @@ -35,5 +38,5 @@ func parse(in []byte) (*ast.File, error) { // // The input format can be either HCL or JSON. func Parse(input string) (*ast.File, error) { - return parse([]byte(input)) + return parse([]byte(input), true) }
Verify codegen
Process completed with exit code 1.
Verify codegen
Restore cache failed: Dependencies file is not found in /home/runner/work/policy-controller/policy-controller. Supported file pattern: go.sum