rebase: bump the github-dependencies group with 3 updates

Bumps the github-dependencies group with 3 updates: [github.com/aws/aws-sdk-go-v2/service/sts](https://github.com/aws/aws-sdk-go-v2), [github.com/hashicorp/vault/api](https://github.com/hashicorp/vault) and [github.com/pkg/xattr](https://github.com/pkg/xattr).


Updates `github.com/aws/aws-sdk-go-v2/service/sts` from 1.33.19 to 1.33.20
- [Release notes](https://github.com/aws/aws-sdk-go-v2/releases)
- [Changelog](https://github.com/aws/aws-sdk-go-v2/blob/main/changelog-template.json)
- [Commits](https://github.com/aws/aws-sdk-go-v2/compare/service/sns/v1.33.19...service/sns/v1.33.20)

Updates `github.com/hashicorp/vault/api` from 1.16.0 to 1.20.0
- [Release notes](https://github.com/hashicorp/vault/releases)
- [Changelog](https://github.com/hashicorp/vault/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/vault/compare/v1.16.0...api/v1.20.0)

Updates `github.com/pkg/xattr` from 0.4.10 to 0.4.11
- [Release notes](https://github.com/pkg/xattr/releases)
- [Commits](https://github.com/pkg/xattr/compare/v0.4.10...v0.4.11)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go-v2/service/sts
  dependency-version: 1.33.20
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
- dependency-name: github.com/hashicorp/vault/api
  dependency-version: 1.20.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: github-dependencies
- dependency-name: github.com/pkg/xattr
  dependency-version: 0.4.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: github-dependencies
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2025-06-09 20:39:04 +00:00
committed by mergify[bot]
parent 3ff34e56b1
commit 598e7a6e4f
15 changed files with 339 additions and 34 deletions

View File

@ -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()

View File

@ -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

View File

@ -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)
}