Skip to content

Commit

Permalink
Fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
damyan committed Mar 22, 2024
1 parent 476492c commit d8c5e2c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions plugins/ipam/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ func NewK8sClient(namespace string, subnetNames []string) K8sClient {
}

func (k K8sClient) createIpamIP(ipaddr net.IP, mac net.HardwareAddr) error {
ip, err := ipamv1alpha1.IPAddrFromString(ipaddr.String())
if err != nil {
err = errors.Wrapf(err, "Failed to parse IP %s", ip)
return err
}

// select the subnet matching the CIDR of the request
subnetMatch := false
for _, subnetName := range k.SubnetNames {
Expand All @@ -90,7 +84,7 @@ func (k K8sClient) createIpamIP(ipaddr net.IP, mac net.HardwareAddr) error {
subnetMatch = true

var ipamIP *ipamv1alpha1.IP
ipamIP, err = k.prepareCreateIpamIP(subnetName, ipaddr, mac)
ipamIP, err := k.prepareCreateIpamIP(subnetName, ipaddr, mac)
if err != nil {
return err
}
Expand All @@ -105,7 +99,7 @@ func (k K8sClient) createIpamIP(ipaddr net.IP, mac net.HardwareAddr) error {
}

if !subnetMatch {
log.Warningf("No matching subnet found for IP %s/%s", k.Namespace, ip)
log.Warningf("No matching subnet found for IP %s/%s", k.Namespace, ipaddr)
}

return nil
Expand Down Expand Up @@ -138,6 +132,11 @@ func (k K8sClient) getMatchingSubnet(subnetName string, ipaddr net.IP) *ipamv1al

func (k K8sClient) prepareCreateIpamIP(subnetName string, ipaddr net.IP, mac net.HardwareAddr) (*ipamv1alpha1.IP, error) {
ip, err := ipamv1alpha1.IPAddrFromString(ipaddr.String())
if err != nil {
err = errors.Wrapf(err, "Failed to parse IP %s", ipaddr)
return nil, err
}

// a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and
// must start and end with an alphanumeric character.
// 2001:abcd:abcd::1 will become 2001-abcd-abcd-0000-0000-0000-0000-00001
Expand Down

0 comments on commit d8c5e2c

Please sign in to comment.