@@ -22,14 +22,12 @@ import (
22
22
"fmt"
23
23
"net"
24
24
"net/http"
25
- "reflect"
26
25
"time"
27
26
28
27
"github.com/go-logr/logr"
29
28
coordinationv1 "k8s.io/api/coordination/v1"
30
29
corev1 "k8s.io/api/core/v1"
31
30
"k8s.io/apimachinery/pkg/api/meta"
32
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
33
31
"k8s.io/apimachinery/pkg/runtime"
34
32
"k8s.io/client-go/rest"
35
33
"k8s.io/client-go/tools/leaderelection/resourcelock"
@@ -41,7 +39,6 @@ import (
41
39
"sigs.k8s.io/controller-runtime/pkg/client"
42
40
"sigs.k8s.io/controller-runtime/pkg/cluster"
43
41
"sigs.k8s.io/controller-runtime/pkg/config"
44
- "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
45
42
"sigs.k8s.io/controller-runtime/pkg/healthz"
46
43
intrec "sigs.k8s.io/controller-runtime/pkg/internal/recorder"
47
44
"sigs.k8s.io/controller-runtime/pkg/leaderelection"
@@ -438,126 +435,6 @@ func New(config *rest.Config, options Options) (Manager, error) {
438
435
}, nil
439
436
}
440
437
441
- // AndFrom will use a supplied type and convert to Options
442
- // any options already set on Options will be ignored, this is used to allow
443
- // cli flags to override anything specified in the config file.
444
- //
445
- // Deprecated: This function has been deprecated and will be removed in a future release,
446
- // The Component Configuration package has been unmaintained for over a year and is no longer
447
- // actively developed. Users should migrate to their own configuration format
448
- // and configure Manager.Options directly.
449
- // See https://github.com/kubernetes-sigs/controller-runtime/issues/895
450
- // for more information, feedback, and comments.
451
- func (o Options ) AndFrom (loader config.ControllerManagerConfiguration ) (Options , error ) {
452
- newObj , err := loader .Complete ()
453
- if err != nil {
454
- return o , err
455
- }
456
-
457
- o = o .setLeaderElectionConfig (newObj )
458
-
459
- if o .Cache .SyncPeriod == nil && newObj .SyncPeriod != nil {
460
- o .Cache .SyncPeriod = & newObj .SyncPeriod .Duration
461
- }
462
-
463
- if len (o .Cache .DefaultNamespaces ) == 0 && newObj .CacheNamespace != "" {
464
- o .Cache .DefaultNamespaces = map [string ]cache.Config {newObj .CacheNamespace : {}}
465
- }
466
-
467
- if o .Metrics .BindAddress == "" && newObj .Metrics .BindAddress != "" {
468
- o .Metrics .BindAddress = newObj .Metrics .BindAddress
469
- }
470
-
471
- if o .HealthProbeBindAddress == "" && newObj .Health .HealthProbeBindAddress != "" {
472
- o .HealthProbeBindAddress = newObj .Health .HealthProbeBindAddress
473
- }
474
-
475
- if o .ReadinessEndpointName == "" && newObj .Health .ReadinessEndpointName != "" {
476
- o .ReadinessEndpointName = newObj .Health .ReadinessEndpointName
477
- }
478
-
479
- if o .LivenessEndpointName == "" && newObj .Health .LivenessEndpointName != "" {
480
- o .LivenessEndpointName = newObj .Health .LivenessEndpointName
481
- }
482
-
483
- if o .WebhookServer == nil {
484
- port := 0
485
- if newObj .Webhook .Port != nil {
486
- port = * newObj .Webhook .Port
487
- }
488
- o .WebhookServer = webhook .NewServer (webhook.Options {
489
- Port : port ,
490
- Host : newObj .Webhook .Host ,
491
- CertDir : newObj .Webhook .CertDir ,
492
- })
493
- }
494
-
495
- if newObj .Controller != nil {
496
- if o .Controller .CacheSyncTimeout == 0 && newObj .Controller .CacheSyncTimeout != nil {
497
- o .Controller .CacheSyncTimeout = * newObj .Controller .CacheSyncTimeout
498
- }
499
-
500
- if len (o .Controller .GroupKindConcurrency ) == 0 && len (newObj .Controller .GroupKindConcurrency ) > 0 {
501
- o .Controller .GroupKindConcurrency = newObj .Controller .GroupKindConcurrency
502
- }
503
- }
504
-
505
- return o , nil
506
- }
507
-
508
- // AndFromOrDie will use options.AndFrom() and will panic if there are errors.
509
- //
510
- // Deprecated: This function has been deprecated and will be removed in a future release,
511
- // The Component Configuration package has been unmaintained for over a year and is no longer
512
- // actively developed. Users should migrate to their own configuration format
513
- // and configure Manager.Options directly.
514
- // See https://github.com/kubernetes-sigs/controller-runtime/issues/895
515
- // for more information, feedback, and comments.
516
- func (o Options ) AndFromOrDie (loader config.ControllerManagerConfiguration ) Options {
517
- o , err := o .AndFrom (loader )
518
- if err != nil {
519
- panic (fmt .Sprintf ("could not parse config file: %v" , err ))
520
- }
521
- return o
522
- }
523
-
524
- func (o Options ) setLeaderElectionConfig (obj v1alpha1.ControllerManagerConfigurationSpec ) Options {
525
- if obj .LeaderElection == nil {
526
- // The source does not have any configuration; noop
527
- return o
528
- }
529
-
530
- if ! o .LeaderElection && obj .LeaderElection .LeaderElect != nil {
531
- o .LeaderElection = * obj .LeaderElection .LeaderElect
532
- }
533
-
534
- if o .LeaderElectionResourceLock == "" && obj .LeaderElection .ResourceLock != "" {
535
- o .LeaderElectionResourceLock = obj .LeaderElection .ResourceLock
536
- }
537
-
538
- if o .LeaderElectionNamespace == "" && obj .LeaderElection .ResourceNamespace != "" {
539
- o .LeaderElectionNamespace = obj .LeaderElection .ResourceNamespace
540
- }
541
-
542
- if o .LeaderElectionID == "" && obj .LeaderElection .ResourceName != "" {
543
- o .LeaderElectionID = obj .LeaderElection .ResourceName
544
- }
545
-
546
- if o .LeaseDuration == nil && ! reflect .DeepEqual (obj .LeaderElection .LeaseDuration , metav1.Duration {}) {
547
- o .LeaseDuration = & obj .LeaderElection .LeaseDuration .Duration
548
- }
549
-
550
- if o .RenewDeadline == nil && ! reflect .DeepEqual (obj .LeaderElection .RenewDeadline , metav1.Duration {}) {
551
- o .RenewDeadline = & obj .LeaderElection .RenewDeadline .Duration
552
- }
553
-
554
- if o .RetryPeriod == nil && ! reflect .DeepEqual (obj .LeaderElection .RetryPeriod , metav1.Duration {}) {
555
- o .RetryPeriod = & obj .LeaderElection .RetryPeriod .Duration
556
- }
557
-
558
- return o
559
- }
560
-
561
438
// defaultHealthProbeListener creates the default health probes listener bound to the given address.
562
439
func defaultHealthProbeListener (addr string ) (net.Listener , error ) {
563
440
if addr == "" || addr == "0" {
0 commit comments