refactor: use standard library instead of isIn (#6125)

Signed-off-by: yyzxw <1020938856@qq.com>
Signed-off-by: xiaowu.zhu <xiaowu.zhu@daocloud.io>
This commit is contained in:
yyzxw 2023-05-29 15:53:55 +08:00 committed by GitHub
parent 7231bb0881
commit e4be859d48
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,6 +9,8 @@ import (
"github.com/coredns/coredns/core/dnsserver" "github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin" "github.com/coredns/coredns/plugin"
"github.com/coredns/coredns/plugin/pkg/log" "github.com/coredns/coredns/plugin/pkg/log"
"k8s.io/utils/strings/slices"
) )
func setup(c *caddy.Controller) error { func setup(c *caddy.Controller) error {
@ -37,7 +39,7 @@ func setup(c *caddy.Controller) error {
} }
for _, ip := range ips { for _, ip := range ips {
if !isIn(ip, except) { if !slices.Contains(except, ip) {
all = append(all, ip) all = append(all, ip)
} }
} }
@ -98,14 +100,3 @@ func listIP(args []string, ifaces []net.Interface) ([]string, error) {
} }
return all, nil return all, nil
} }
// isIn checks if a string array contains an element
func isIn(s string, list []string) bool {
is := false
for _, l := range list {
if s == l {
is = true
}
}
return is
}