Compare commits
2 commits
9eccdccc5c
...
d243349640
Author | SHA1 | Date | |
---|---|---|---|
d243349640 | |||
1beb83c8f7 |
2 changed files with 9 additions and 5 deletions
|
@ -7,7 +7,7 @@ jobs:
|
|||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: stable
|
||||
- uses: https://github.com/golangci/golangci-lint-action@v4
|
||||
- uses: https://github.com/golangci/golangci-lint-action@v6
|
||||
tests:
|
||||
runs-on: docker
|
||||
steps:
|
||||
|
|
12
adapters.go
12
adapters.go
|
@ -14,6 +14,10 @@ import (
|
|||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
func parseError(err error) error {
|
||||
return fmt.Errorf("cannot parse config file: %w", err)
|
||||
}
|
||||
|
||||
type filetype int
|
||||
|
||||
const (
|
||||
|
@ -79,7 +83,7 @@ func marshal(ft filetype, v any) ([]byte, error) {
|
|||
func unmarshalJSON(data []byte, v any) error {
|
||||
err := json.Unmarshal(data, v)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot parse config file: %w", err)
|
||||
return parseError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -99,7 +103,7 @@ func marshalJSON(v any) ([]byte, error) {
|
|||
func unmarshalTOML(data []byte, v any) error {
|
||||
err := toml.Unmarshal(data, v)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot parse config file: %w", err)
|
||||
return parseError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -125,7 +129,7 @@ func unmarshalHCL(filepath string, data []byte, v any) error {
|
|||
newDiags := hclFilterDiagnostics(diags)
|
||||
|
||||
if len(newDiags) > 0 {
|
||||
return fmt.Errorf("cannot parse config file: %w", newDiags)
|
||||
return parseError(newDiags)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -159,7 +163,7 @@ func hclFilterDiagnostics(diags hcl.Diagnostics) hcl.Diagnostics {
|
|||
func unmarshalYAML(data []byte, v any) error {
|
||||
err := yaml.Unmarshal(data, v)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot parse config file: %w", err)
|
||||
return parseError(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
Loading…
Reference in a new issue