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