Pull request 2480: AGDNS-2899-new-yaml

Squashed commit of the following:

commit 0577b40f83
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Wed Sep 17 13:27:12 2025 +0300

    all: upd yaml
This commit is contained in:
Ainar Garipov 2025-09-19 13:04:23 +03:00
parent 5e7e0092ac
commit b4f1ab2808
11 changed files with 34 additions and 26 deletions

3
go.mod
View File

@ -33,12 +33,12 @@ require (
github.com/stretchr/testify v1.11.1
github.com/ti-mo/netfilter v0.5.3
go.etcd.io/bbolt v1.4.1
go.yaml.in/yaml/v4 v4.0.0-rc.2
golang.org/x/crypto v0.41.0
golang.org/x/exp v0.0.0-20250813145105-42675adae3e6
golang.org/x/net v0.43.0
golang.org/x/sys v0.35.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
gopkg.in/yaml.v3 v3.0.1
howett.net/plist v1.0.1
)
@ -103,6 +103,7 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20250826171959-ef028d996bc1 // indirect
google.golang.org/grpc v1.75.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.6.1 // indirect
mvdan.cc/editorconfig v0.3.0 // indirect
mvdan.cc/gofumpt v0.9.0 // indirect

2
go.sum
View File

@ -200,6 +200,8 @@ go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs=
go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8=
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
go.yaml.in/yaml/v4 v4.0.0-rc.2 h1:/FrI8D64VSr4HtGIlUtlFMGsm7H7pWTbj6vOLVZcA6s=
go.yaml.in/yaml/v4 v4.0.0-rc.2/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=

View File

@ -286,7 +286,7 @@ func testDiskConf(schemaVersion int) (diskConf yobj) {
return diskConf
}
// testDNSConf creates a DNS config for test the way gopkg.in/yaml.v3 would
// testDNSConf creates a DNS config for test the way [go.yaml.in/yaml/v4] would
// unmarshal it. In YAML, keys aren't guaranteed to always only be strings.
func testDNSConf(schemaVersion int) (dnsConf yobj) {
dnsConf = yobj{

View File

@ -5,7 +5,7 @@ import (
"fmt"
"github.com/AdguardTeam/golibs/log"
yaml "gopkg.in/yaml.v3"
yaml "go.yaml.in/yaml/v4"
)
// Config is a the configuration for initializing a [Migrator].

View File

@ -12,8 +12,8 @@ import (
"github.com/AdguardTeam/AdGuardHome/internal/configmigrate"
"github.com/AdguardTeam/golibs/testutil"
"github.com/stretchr/testify/require"
yaml "go.yaml.in/yaml/v4"
"golang.org/x/crypto/bcrypt"
yaml "gopkg.in/yaml.v3"
)
func TestMain(m *testing.M) {

View File

@ -30,7 +30,7 @@ import (
"github.com/AdguardTeam/golibs/timeutil"
"github.com/google/go-cmp/cmp"
"github.com/google/renameio/v2/maybe"
yaml "gopkg.in/yaml.v3"
yaml "go.yaml.in/yaml/v4"
)
const (

View File

@ -27,7 +27,7 @@ import (
"github.com/AdguardTeam/golibs/netutil"
"github.com/AdguardTeam/golibs/netutil/urlutil"
"github.com/ameshkov/dnscrypt/v2"
yaml "gopkg.in/yaml.v3"
yaml "go.yaml.in/yaml/v4"
)
// Default listening ports.

View File

@ -10,8 +10,8 @@ import (
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
"github.com/AdguardTeam/golibs/log"
"github.com/AdguardTeam/golibs/logutil/slogutil"
yaml "go.yaml.in/yaml/v4"
"gopkg.in/natefinch/lumberjack.v2"
"gopkg.in/yaml.v3"
)
// configSyslog is used to indicate that syslog or eventlog (win) should be used

View File

@ -23,7 +23,7 @@ import (
"github.com/AdguardTeam/golibs/logutil/slogutil"
"github.com/AdguardTeam/golibs/timeutil"
"github.com/google/renameio/v2/maybe"
"gopkg.in/yaml.v3"
yaml "go.yaml.in/yaml/v4"
)
// Manager handles full and partial changes in the configuration, persisting

View File

@ -9,7 +9,7 @@ import (
"github.com/AdguardTeam/AdGuardHome/internal/aghhttp"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/timeutil"
"gopkg.in/yaml.v3"
yaml "go.yaml.in/yaml/v4"
)
// Weekly is a schedule for one week. Each day of the week has one range with

View File

@ -9,7 +9,7 @@ import (
"github.com/AdguardTeam/golibs/timeutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gopkg.in/yaml.v3"
yaml "go.yaml.in/yaml/v4"
)
func TestWeekly_Contains(t *testing.T) {
@ -183,25 +183,30 @@ yaml: "bad"
data: []byte(brusselsSundayYAML),
want: brusselsWeekly,
}, {
name: "start_equal_end",
wantErrMsg: "weekday Sunday: bad day range: start 9h0m0s is greater or equal to end 9h0m0s",
data: []byte(sameTime),
want: &Weekly{},
name: "start_equal_end",
wantErrMsg: "yaml: unmarshal errors:\n" +
" line 2: weekday Sunday: bad day range: " +
"start 9h0m0s is greater or equal to end 9h0m0s",
data: []byte(sameTime),
want: &Weekly{},
}, {
name: "start_negative",
wantErrMsg: "weekday Sunday: bad day range: start -1h0m0s is negative",
data: []byte(negativeStart),
want: &Weekly{},
name: "start_negative",
wantErrMsg: "yaml: unmarshal errors:\n" +
" line 2: weekday Sunday: bad day range: start -1h0m0s is negative",
data: []byte(negativeStart),
want: &Weekly{},
}, {
name: "bad_time_zone",
wantErrMsg: "unknown time zone bad_timezone",
data: []byte(badTZ),
want: &Weekly{},
name: "bad_time_zone",
wantErrMsg: "yaml: unmarshal errors:\n" +
" line 2: unknown time zone bad_timezone",
data: []byte(badTZ),
want: &Weekly{},
}, {
name: "bad_yaml",
wantErrMsg: "yaml: unmarshal errors:\n line 3: mapping key \"yaml\" already defined at line 2",
data: []byte(badYAML),
want: &Weekly{},
name: "bad_yaml",
wantErrMsg: "yaml: unmarshal errors:\n" +
" line 3: mapping key \"yaml\" already defined at line 2",
data: []byte(badYAML),
want: &Weekly{},
}}
for _, tc := range testCases {