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:
parent
7231bb0881
commit
e4be859d48
1 changed files with 3 additions and 12 deletions
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue