mirror of https://github.com/k3s-io/k3s
Fix lint errors of pkg/util/net/sets/ipnet.go
parent
016f1cfd8f
commit
6cfbd9329a
|
@ -21,8 +21,10 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// IPNet maps string to net.IPNet.
|
||||
type IPNet map[string]*net.IPNet
|
||||
|
||||
// ParseIPNets parses string slice to IPNet.
|
||||
func ParseIPNets(specs ...string) (IPNet, error) {
|
||||
ipnetset := make(IPNet)
|
||||
for _, spec := range specs {
|
||||
|
@ -96,9 +98,9 @@ func (s IPNet) StringSlice() []string {
|
|||
}
|
||||
|
||||
// IsSuperset returns true if and only if s1 is a superset of s2.
|
||||
func (s1 IPNet) IsSuperset(s2 IPNet) bool {
|
||||
func (s IPNet) IsSuperset(s2 IPNet) bool {
|
||||
for k := range s2 {
|
||||
_, found := s1[k]
|
||||
_, found := s[k]
|
||||
if !found {
|
||||
return false
|
||||
}
|
||||
|
@ -109,8 +111,8 @@ func (s1 IPNet) IsSuperset(s2 IPNet) bool {
|
|||
// Equal returns true if and only if s1 is equal (as a set) to s2.
|
||||
// Two sets are equal if their membership is identical.
|
||||
// (In practice, this means same elements, order doesn't matter)
|
||||
func (s1 IPNet) Equal(s2 IPNet) bool {
|
||||
return len(s1) == len(s2) && s1.IsSuperset(s2)
|
||||
func (s IPNet) Equal(s2 IPNet) bool {
|
||||
return len(s) == len(s2) && s.IsSuperset(s2)
|
||||
}
|
||||
|
||||
// Len returns the size of the set.
|
||||
|
|
Loading…
Reference in New Issue