Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #524 from bshephar/remove-unused-params
Browse files Browse the repository at this point in the history
Remove unused params from getAddressFromAnsibleHost()
  • Loading branch information
openshift-merge-bot[bot] authored Nov 20, 2023
2 parents d578048 + 06c5f6b commit 75def08
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions pkg/deployment/kube_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func CreateKubeServices(
// if we have IPSets, lets go to search for the IPs there
addresses[i], addressType = getAddressFromIPSet(&item, namespacedName, &kubeService, helper)
} else if len(item.Ansible.AnsibleHost) > 0 {
addresses[i], addressType = getAddressFromAnsibleHost(&item, namespacedName, &kubeService, helper)
addresses[i], addressType = getAddressFromAnsibleHost(&item)
} else {
// we were unable to find an IP or HostName for a node, so we do not go further
return nil
Expand Down Expand Up @@ -132,15 +132,10 @@ func getAddressFromIPSet(item *dataplanev1.NodeSection,
}
}
// if the reservations list is empty, we go find if AnsibleHost exists
return getAddressFromAnsibleHost(item, namespacedName, kubeService, helper)
return getAddressFromAnsibleHost(item)
}

func getAddressFromAnsibleHost(
item *dataplanev1.NodeSection,
namespacedName *types.NamespacedName,
kubeService *dataplanev1.KubeService,
helper *helper.Helper,
) (string, discoveryv1.AddressType) {
func getAddressFromAnsibleHost(item *dataplanev1.NodeSection) (string, discoveryv1.AddressType) {
// check if ansiblehost is an IP
addr := net.ParseIP(item.Ansible.AnsibleHost)
if addr != nil {
Expand All @@ -166,7 +161,6 @@ func service(
helper *helper.Helper,
labels map[string]string,
) (*corev1.Service, error) {

service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: kubeService.Name,
Expand Down Expand Up @@ -204,7 +198,6 @@ func endpointSlice(
helper *helper.Helper,
labels map[string]string,
) (*discoveryv1.EndpointSlice, error) {

if len(addresses) > 100 {
err := fmt.Errorf("an EndpointSlice cannot contain more than 100 endpoint addresses")
return nil, err
Expand Down Expand Up @@ -246,6 +239,6 @@ func endpointSlice(

// isValidDomain returns true if the domain is valid.
func isValidDomain(domain string) bool {
var domainRegexp = regexp.MustCompile(`^(?i)[a-z0-9-]+(\.[a-z0-9-]+)+\.?$`)
domainRegexp := regexp.MustCompile(`^(?i)[a-z0-9-]+(\.[a-z0-9-]+)+\.?$`)
return domainRegexp.MatchString(domain)
}

0 comments on commit 75def08

Please sign in to comment.