Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
aojea committed May 26, 2024
1 parent c8ed1bc commit ce18145
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions cmd/kindnetd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ func main() {
noMaskIPv4Subnets, noMaskIPv6Subnets := getNoMasqueradeSubnets(clientset)
// detect the cluster IP family based on the Cluster CIDR akka PodSubnet
var ipFamily IPFamily
if len(noMaskIPv4Subnets) > 0 && len(noMaskIPv6Subnets) > 0 {
switch {
case len(noMaskIPv4Subnets) > 0 && len(noMaskIPv6Subnets) > 0:
ipFamily = DualStackFamily
} else if len(noMaskIPv6Subnets) > 0 {
case len(noMaskIPv6Subnets) > 0:
ipFamily = IPv6Family
} else if len(noMaskIPv4Subnets) > 0 {
case len(noMaskIPv4Subnets) > 0:
ipFamily = IPv4Family
} else {
panic(fmt.Sprint("Cluster CIDR is not defined"))
default:
panic("Cluster CIDR is not defined")
}
klog.Infof("kindnetd IP family: %q", ipFamily)

Expand Down Expand Up @@ -272,7 +273,7 @@ func makeNodesReconciler(cniConfig *CNIConfigWriter, hostIP string, ipFamily IPF

// obtain the PodCIDR gateway
var nodeIPv4, nodeIPv6 string
for _, ip := range nodeIPs.List() {
for _, ip := range nodeIPs.UnsortedList() {
if isIPv6String(ip) {
nodeIPv6 = ip
} else {
Expand Down Expand Up @@ -305,8 +306,8 @@ func makeNodesReconciler(cniConfig *CNIConfigWriter, hostIP string, ipFamily IPF
}

// internalIPs returns the internal IP address for node
func internalIPs(node *corev1.Node) sets.String {
ips := sets.NewString()
func internalIPs(node *corev1.Node) sets.Set[string] {
ips := sets.New[string]()
// check the node.Status.Addresses
for _, address := range node.Status.Addresses {
if address.Type == "InternalIP" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/kindnetd/masq.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (ma *IPMasqAgent) SyncRulesForever(interval time.Duration) error {
if err := ma.SyncRules(); err != nil {
errs++
if errs > 3 {
return fmt.Errorf("Can't synchronize rules after 3 attempts: %v", err)
return fmt.Errorf("can't synchronize rules after 3 attempts: %v", err)
}
} else {
errs = 0
Expand Down

0 comments on commit ce18145

Please sign in to comment.