func GetLeaderElectionConfig(restConfig *rest.Config, enabled bool) configv1.LeaderElection {

	// Defaults follow conventions
	// https://github.com/openshift/enhancements/blob/master/CONVENTIONS.md#high-availability
	defaultLeaderElection := leaderElectionDefaulting(
		configv1.LeaderElection{
			Disable: !enabled,
		},
		"", "",
	)

	if enabled {
		ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
		defer cancel()
		if infra, err := getClusterInfraStatus(ctx, restConfig); err == nil && infra != nil {
			if infra.ControlPlaneTopology == configv1.SingleReplicaTopologyMode {
				return leaderElectionSNOConfig(defaultLeaderElection)
			}
		} else {
			klog.Warningf("unable to get cluster infrastructure status, using HA cluster values for leader election: %v", err)
		}
	}

	return defaultLeaderElection
}
// GetLeaderElectionConfig returns leader election configs defaults based on the cluster topology
GetLeaderElectionConfig returns leader election configs defaults based on the cluster topology
// GetLeaderElectionConfig returns leader election configs defaults based on the cluster topology
func GetLeaderElectionConfig(restConfig *rest.Config, enabled bool) configv1.LeaderElection {
	defaultLeaderElection := leaderElectionDefaulting(
		configv1.LeaderElection{
			Disable: !enabled,
		},
		"", "",
	)
	if enabled {
		ctx, cancel := context.WithTimeout(context.Background(), time.Second*3)
		defer cancel()
		if infra, err := getClusterInfraStatus(ctx, restConfig); err == nil && infra != nil {
			if infra.ControlPlaneTopology == configv1.SingleReplicaTopologyMode {
				return leaderElectionSNOConfig(defaultLeaderElection)
			}
		} else {
			klog.Warningf("unable to get cluster infrastructure status, using HA cluster values for leader election: %v", err)
		}
	}
	return defaultLeaderElection
}
func GetLeaderElectionConfig ( restConfig * rest . Config , enabled bool ) configv1 . LeaderElection { defaultLeaderElection := leaderElectionDefaulting ( configv1 . LeaderElection { Disable : ! enabled , } , " " , " " , ) if enabled { ctx , cancel := context . WithTimeout ( context . Background ( ) , time . Second * 3 ) defer cancel ( ) if infra , err := getClusterInfraStatus ( ctx , restConfig ) ; err == nil && infra != nil { if infra . ControlPlaneTopology == configv1 . SingleReplicaTopologyMode { return leaderElectionSNOConfig ( defaultLeaderElection ) } } else { klog . Warningf ( " " , err ) } } return defaultLeaderElection }
GetLeaderElectionConfig returns leader election configs defaults based on the cluster topology
GetLeaderElectionConfig returns leader election configs defaults based on the cluster topology
// Defaults follow conventions // https://github.com/openshift/enhancements/blob/master/CONVENTIONS.md#high-availability