diff --git a/go.mod b/go.mod index 6dfcdc2..2136ea6 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.18 require ( github.com/Jille/dfr v1.0.0 + github.com/Jille/genericz v0.1.0 github.com/creachadair/getpass v0.2.1 github.com/google/go-cmp v0.5.8 github.com/iancoleman/strcase v0.2.0 @@ -12,7 +13,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/xdg-go/pbkdf2 v1.0.0 github.com/xdg-go/scram v1.1.1 - gogen.quis.cx/stringlib v0.0.0-20211012140410-76d47c45f099 + golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b ) @@ -27,7 +28,6 @@ require ( github.com/jackc/pgtype v1.11.0 // indirect github.com/xdg-go/stringprep v1.0.3 // indirect golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect - golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d // indirect golang.org/x/sys v0.4.0 // indirect golang.org/x/term v0.4.0 // indirect golang.org/x/text v0.3.7 // indirect diff --git a/go.sum b/go.sum index 192122f..c9ef54a 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ github.com/Jille/dfr v1.0.0 h1:hKZ5Ui4sVJ47ocwIBaYg0my4GLuZs5/7pietSOYpub0= github.com/Jille/dfr v1.0.0/go.mod h1:P2H4sBdbgPVuq7pvi6IBwig1wxFnlnS/MHj0BSLivR8= github.com/Jille/errchain v1.0.0 h1:S1YDbLdKAADkE1Rbj7A6d0QeoWZIvMzTBeoKjEkw9LA= github.com/Jille/errchain v1.0.0/go.mod h1:XaSP9ruaReMvv1BmcI52KV4NCmjVFTxjMGmKX9ixzG8= +github.com/Jille/genericz v0.1.0 h1:z1sZobHQIqgIrIFL6pKqiq7RXzq1iypzFrzOHYLOkY4= +github.com/Jille/genericz v0.1.0/go.mod h1:J9GF608ey+8AmME0HFGGFuD5f+2TRHbOfcmaF8dIIXI= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= @@ -136,8 +138,6 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -gogen.quis.cx/stringlib v0.0.0-20211012140410-76d47c45f099 h1:EwiPz8zR1xUFqhsbdFt1bcV+HCe1/q5lIbkR5c/TM3U= -gogen.quis.cx/stringlib v0.0.0-20211012140410-76d47c45f099/go.mod h1:Bp5H6ALHwREwb4Dt58IxzV/T9lj9ZFWb/EYlC7h25is= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -148,8 +148,8 @@ golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWP golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d h1:vtUKgx8dahOomfFzLREU8nSv25YHnTgLBn4rDnWZdU0= -golang.org/x/exp v0.0.0-20220613132600-b0d781184e0d/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= +golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w= +golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= diff --git a/validate.go b/validate.go index ae20f8a..80eaa79 100644 --- a/validate.go +++ b/validate.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" + "github.com/Jille/genericz/slicez" "github.com/samber/lo" - "gogen.quis.cx/stringlib" ) // TODO: Do we want to raise warnings for likely incorrect configurations? (RoleAttributes.Replication without RoleAttributes.Login etc) @@ -98,14 +98,14 @@ func (v *validator) validatePrivileges(what string, privs []GenericPrivilege) { if len(t) == 0 { v.addErrorf("%s: privilege is missing %s field", src, what) } else if len(t) > 1 { - v.addErrorf("%s: privilege has invalid fields: %v", src, stringlib.Diff(t, []string{what})) + v.addErrorf("%s: privilege has invalid fields: %v", src, slicez.Diff(t, []string{what})) } if what != t[0] { v.addErrorf("%s: privilege has wrong target field (want %q, got %q)", src, what, t[0]) } if len(p.Privileges) == 1 && p.Privileges[0] == "ALL PRIVILEGES" { // OK - } else if unknown := stringlib.Diff(p.Privileges, validPrivileges[what]); len(unknown) > 0 { + } else if unknown := slicez.Diff(p.Privileges, validPrivileges[what]); len(unknown) > 0 { v.addErrorf("%s: privilege has invalid privileges %v for %s_privileges", src, unknown, what[:len(what)-1]) } for _, tgt := range p.untypedTargets() {