@@ -45,7 +45,8 @@ import (
4545const leaderElectorName = "liqo-ipam-leaderelection"
4646
4747var (
48- scheme = runtime .NewScheme ()
48+ scheme = runtime .NewScheme ()
49+ options ipam.Options
4950)
5051
5152func init () {
@@ -58,8 +59,6 @@ func init() {
5859// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;
5960// +kubebuilder:rbac:groups=core,resources=pods,verbs=get;list;watch;update;patch
6061
61- var options ipam.Options
62-
6362func main () {
6463 var cmd = cobra.Command {
6564 Use : "liqo-ipam" ,
@@ -69,9 +68,12 @@ func main() {
6968 flagsutils .InitKlogFlags (cmd .Flags ())
7069 restcfg .InitFlags (cmd .Flags ())
7170
72- cmd .Flags ().IntVar (& options .Port , "port" , consts .IpamPort , "The port on which to listen for incoming gRPC requests." )
73- cmd .Flags ().DurationVar (& options .SyncFrequency , "interval" , consts .SyncFrequency ,
71+ // Server options.
72+ cmd .Flags ().IntVar (& options .ServerOpts .Port , "port" , consts .IpamPort , "The port on which to listen for incoming gRPC requests." )
73+ cmd .Flags ().DurationVar (& options .ServerOpts .SyncFrequency , "interval" , consts .SyncFrequency ,
7474 "The interval at which the IPAM will synchronize the IPAM storage." )
75+
76+ // Leader election flags.
7577 cmd .Flags ().BoolVar (& options .EnableLeaderElection , "leader-election" , false , "Enable leader election for IPAM. " +
7678 "Enabling this will ensure there is only one active IPAM." )
7779 cmd .Flags ().StringVar (& options .LeaderElectionNamespace , "leader-election-namespace" , consts .DefaultLiqoNamespace ,
@@ -103,6 +105,8 @@ func run(cmd *cobra.Command, _ []string) error {
103105
104106 // Get the rest config.
105107 cfg := restcfg .SetRateLimiter (ctrl .GetConfigOrDie ())
108+
109+ // Get the client.
106110 cl , err := client .New (cfg , client.Options {
107111 Scheme : scheme ,
108112 })
@@ -128,12 +132,12 @@ func run(cmd *cobra.Command, _ []string) error {
128132 }
129133 }
130134
131- liqoIPAM , err := ipam .New (ctx , cl , cfg , & options )
135+ liqoIPAM , err := ipam .New (ctx , cl , & options . ServerOpts )
132136 if err != nil {
133137 return err
134138 }
135139
136- lis , err := net .Listen ("tcp" , fmt .Sprintf ("0.0.0.0:%d" , options .Port ))
140+ lis , err := net .Listen ("tcp" , fmt .Sprintf ("0.0.0.0:%d" , options .ServerOpts . Port ))
137141 if err != nil {
138142 return err
139143 }
0 commit comments