Skip to content

Commit

Permalink
fix go lint issue
Browse files Browse the repository at this point in the history
fixed go lint issues

Contributes to: submariner-io/submariner#3210

Signed-off-by: Aswin A <[email protected]>
  • Loading branch information
aswinayyolath committed Nov 11, 2024
1 parent a624e3a commit 67f8022
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 0 additions & 1 deletion pkg/discovery/network/canal.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ func discoverCanalFlannelNetwork(ctx context.Context, client controllerClient.Cl

return clusterNetwork, nil
}

13 changes: 9 additions & 4 deletions pkg/discovery/network/flannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ func discoverFlannelNetwork(ctx context.Context, client controllerClient.Client)
volumes := make([]corev1.Volume, 0)

// Find the first DaemonSet with "flannel" in its name and store its reference and volumes.
for _, ds := range daemonsets.Items {
for i := range daemonsets.Items {
ds := &daemonsets.Items[i]
if strings.Contains(ds.Name, "flannel") {
flannelDaemonSet = &ds
flannelDaemonSet = ds
volumes = ds.Spec.Template.Spec.Volumes
break
}
Expand All @@ -61,16 +62,20 @@ func discoverFlannelNetwork(ctx context.Context, client controllerClient.Client)
// Extract the ConfigMap name from the DaemonSet's volumes and check in the same namespace
configMapName := findFlannelConfigMapName(volumes)
clusterNetwork, err := extractCIDRsFromFlannelConfigMap(ctx, client, configMapName, flannelDaemonSet.Namespace)
if err != nil || clusterNetwork == nil {
if err != nil {
return nil, err
}
if clusterNetwork == nil {
return nil, errors.New("cluster network is nil")
}

clusterNetwork.NetworkPlugin = cni.Flannel
return clusterNetwork, nil
}

//nolint:nilnil // Intentional as the purpose is to discover.
func extractCIDRsFromFlannelConfigMap(ctx context.Context, client controllerClient.Client, configMapName, namespace string) (*ClusterNetwork, error) {
func extractCIDRsFromFlannelConfigMap(ctx context.Context, client controllerClient.Client, configMapName, namespace string) (
*ClusterNetwork, error) {
var podCIDR *string

if configMapName == "" {
Expand Down

0 comments on commit 67f8022

Please sign in to comment.