mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
vendor: github.com/aws/aws-sdk-go-v2/config v1.26.6
vendor github.com/aws/aws-sdk-go-v2/config v1.26.6 and related dependencies. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
48
vendor/github.com/aws/aws-sdk-go-v2/internal/ini/ini.go
generated
vendored
48
vendor/github.com/aws/aws-sdk-go-v2/internal/ini/ini.go
generated
vendored
@ -1,13 +1,26 @@
|
||||
// Package ini implements parsing of the AWS shared config file.
|
||||
//
|
||||
// Example:
|
||||
// sections, err := ini.OpenFile("/path/to/file")
|
||||
// if err != nil {
|
||||
// panic(err)
|
||||
// }
|
||||
//
|
||||
// profile := "foo"
|
||||
// section, ok := sections.GetSection(profile)
|
||||
// if !ok {
|
||||
// fmt.Printf("section %q could not be found", profile)
|
||||
// }
|
||||
package ini
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// OpenFile takes a path to a given file, and will open and parse
|
||||
// that file.
|
||||
// OpenFile parses shared config from the given file path.
|
||||
func OpenFile(path string) (sections Sections, err error) {
|
||||
f, oerr := os.Open(path)
|
||||
if oerr != nil {
|
||||
@ -26,33 +39,18 @@ func OpenFile(path string) (sections Sections, err error) {
|
||||
return Parse(f, path)
|
||||
}
|
||||
|
||||
// Parse will parse the given file using the shared config
|
||||
// visitor.
|
||||
func Parse(f io.Reader, path string) (Sections, error) {
|
||||
tree, err := ParseAST(f)
|
||||
// Parse parses shared config from the given reader.
|
||||
func Parse(r io.Reader, path string) (Sections, error) {
|
||||
contents, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return Sections{}, err
|
||||
return Sections{}, fmt.Errorf("read all: %v", err)
|
||||
}
|
||||
|
||||
v := NewDefaultVisitor(path)
|
||||
if err = Walk(tree, v); err != nil {
|
||||
return Sections{}, err
|
||||
}
|
||||
|
||||
return v.Sections, nil
|
||||
}
|
||||
|
||||
// ParseBytes will parse the given bytes and return the parsed sections.
|
||||
func ParseBytes(b []byte) (Sections, error) {
|
||||
tree, err := ParseASTBytes(b)
|
||||
lines := strings.Split(string(contents), "\n")
|
||||
tokens, err := tokenize(lines)
|
||||
if err != nil {
|
||||
return Sections{}, err
|
||||
return Sections{}, fmt.Errorf("tokenize: %v", err)
|
||||
}
|
||||
|
||||
v := NewDefaultVisitor("")
|
||||
if err = Walk(tree, v); err != nil {
|
||||
return Sections{}, err
|
||||
}
|
||||
|
||||
return v.Sections, nil
|
||||
return parse(tokens, path), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user