Skip to content

Commit a9d6107

Browse files
authored
Merge pull request #2190 from kubernetes-sigs/revert-2165-deprecate-component-config
🌱 [0.14] Revert deprecation component configuration package
2 parents b9940ed + 5d27848 commit a9d6107

17 files changed

+38
-85
lines changed

alias.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"k8s.io/apimachinery/pkg/runtime/schema"
2222
"sigs.k8s.io/controller-runtime/pkg/builder"
2323
"sigs.k8s.io/controller-runtime/pkg/client/config"
24-
cfg "sigs.k8s.io/controller-runtime/pkg/config" //nolint:staticcheck
24+
cfg "sigs.k8s.io/controller-runtime/pkg/config"
2525
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2626
"sigs.k8s.io/controller-runtime/pkg/log"
2727
"sigs.k8s.io/controller-runtime/pkg/manager"
@@ -99,8 +99,7 @@ var (
9999
// ConfigFile returns the cfg.File function for deferred config file loading,
100100
// this is passed into Options{}.From() to populate the Options fields for
101101
// the manager.
102-
// Deprecated: This is deprecated in favor of using Options directly.
103-
ConfigFile = cfg.File //nolint:staticcheck
102+
ConfigFile = cfg.File
104103

105104
// NewControllerManagedBy returns a new controller builder that will be started by the provided Manager.
106105
NewControllerManagedBy = builder.ControllerManagedBy

pkg/builder/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func (blder *Builder) getControllerName(gvk schema.GroupVersionKind, hasGVK bool
285285
}
286286

287287
func (blder *Builder) doController(r reconcile.Reconciler) error {
288-
globalOpts := blder.mgr.GetControllerOptions() //nolint:staticcheck
288+
globalOpts := blder.mgr.GetControllerOptions()
289289

290290
ctrlOptions := blder.ctrlOptions
291291
if ctrlOptions.Reconciler == nil {

pkg/builder/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636

3737
"sigs.k8s.io/controller-runtime/pkg/cache"
3838
"sigs.k8s.io/controller-runtime/pkg/client"
39-
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
39+
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
4040
"sigs.k8s.io/controller-runtime/pkg/controller"
4141
"sigs.k8s.io/controller-runtime/pkg/event"
4242
"sigs.k8s.io/controller-runtime/pkg/handler"
@@ -235,7 +235,7 @@ var _ = Describe("application", func() {
235235

236236
By("creating a controller manager")
237237
m, err := manager.New(cfg, manager.Options{
238-
Controller: v1alpha1.ControllerConfigurationSpec{ //nolint:staticcheck
238+
Controller: v1alpha1.ControllerConfigurationSpec{
239239
GroupKindConcurrency: map[string]int{
240240
"ReplicaSet.apps": maxConcurrentReconciles,
241241
},

pkg/config/config.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,20 @@ import (
2424
"k8s.io/apimachinery/pkg/runtime"
2525
"k8s.io/apimachinery/pkg/runtime/serializer"
2626
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
27-
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
27+
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
2828
)
2929

3030
// ControllerManagerConfiguration defines the functions necessary to parse a config file
3131
// and to configure the Options struct for the ctrl.Manager.
32-
//
33-
// Deprecated: This package has been deprecated and will be removed in a future release.
3432
type ControllerManagerConfiguration interface {
3533
runtime.Object
3634

3735
// Complete returns the versioned configuration
38-
Complete() (v1alpha1.ControllerManagerConfigurationSpec, error) //nolint:staticcheck
36+
Complete() (v1alpha1.ControllerManagerConfigurationSpec, error)
3937
}
4038

4139
// DeferredFileLoader is used to configure the decoder for loading controller
4240
// runtime component config types.
43-
//
44-
// Deprecated: This package has been deprecated and will be removed in a future release.
4541
type DeferredFileLoader struct {
4642
ControllerManagerConfiguration
4743
path string
@@ -56,8 +52,6 @@ type DeferredFileLoader struct {
5652
// Defaults:
5753
// * Path: "./config.yaml"
5854
// * Kind: GenericControllerManagerConfiguration
59-
//
60-
// Deprecated: This package has been deprecated and will be removed in a future release.
6155
func File() *DeferredFileLoader {
6256
scheme := runtime.NewScheme()
6357
utilruntime.Must(v1alpha1.AddToScheme(scheme))
@@ -69,8 +63,6 @@ func File() *DeferredFileLoader {
6963
}
7064

7165
// Complete will use sync.Once to set the scheme.
72-
//
73-
// Deprecated: This package has been deprecated and will be removed in a future release.
7466
func (d *DeferredFileLoader) Complete() (v1alpha1.ControllerManagerConfigurationSpec, error) {
7567
d.once.Do(d.loadFile)
7668
if d.err != nil {
@@ -79,33 +71,25 @@ func (d *DeferredFileLoader) Complete() (v1alpha1.ControllerManagerConfiguration
7971
return d.ControllerManagerConfiguration.Complete()
8072
}
8173

82-
// AtPath will set the path to load the file for the decoder
83-
//
84-
// Deprecated: This package has been deprecated and will be removed in a future release.
74+
// AtPath will set the path to load the file for the decoder.
8575
func (d *DeferredFileLoader) AtPath(path string) *DeferredFileLoader {
8676
d.path = path
8777
return d
8878
}
8979

9080
// OfKind will set the type to be used for decoding the file into.
91-
//
92-
// Deprecated: This package has been deprecated and will be removed in a future release.
9381
func (d *DeferredFileLoader) OfKind(obj ControllerManagerConfiguration) *DeferredFileLoader {
9482
d.ControllerManagerConfiguration = obj
9583
return d
9684
}
9785

9886
// InjectScheme will configure the scheme to be used for decoding the file.
99-
//
100-
// Deprecated: This package has been deprecated and will be removed in a future release.
10187
func (d *DeferredFileLoader) InjectScheme(scheme *runtime.Scheme) error {
10288
d.scheme = scheme
10389
return nil
10490
}
10591

10692
// loadFile is used from the mutex.Once to load the file.
107-
//
108-
// Deprecated: This package has been deprecated and will be removed in a future release.
10993
func (d *DeferredFileLoader) loadFile() {
11094
if d.scheme == nil {
11195
d.err = fmt.Errorf("scheme not supplied to controller configuration loader")

pkg/config/config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package config_test
1919
import (
2020
. "github.com/onsi/ginkgo/v2"
2121
. "github.com/onsi/gomega"
22-
"sigs.k8s.io/controller-runtime/pkg/config" //nolint:staticcheck
23-
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
22+
"sigs.k8s.io/controller-runtime/pkg/config"
23+
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
2424
)
2525

2626
var _ = Describe("config", func() {
@@ -33,7 +33,7 @@ var _ = Describe("config", func() {
3333
})
3434

3535
It("should load a config from file", func() {
36-
conf := v1alpha1.ControllerManagerConfiguration{} //nolint:staticcheck
36+
conf := v1alpha1.ControllerManagerConfiguration{}
3737
loader := config.File().AtPath("./testdata/config.yaml").OfKind(&conf)
3838
Expect(conf.CacheNamespace).To(Equal(""))
3939

pkg/config/doc.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,4 @@ limitations under the License.
2222
// This uses a deferred file decoding allowing you to chain your configuration
2323
// setup. You can pass this into manager.Options#File and it will load your
2424
// config.
25-
//
26-
// Deprecated: This package has been deprecated and will be removed in a future release.
2725
package config

pkg/config/example_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import (
2121
"os"
2222

2323
"k8s.io/apimachinery/pkg/runtime"
24+
"sigs.k8s.io/controller-runtime/pkg/config"
25+
2426
"sigs.k8s.io/controller-runtime/examples/configfile/custom/v1alpha1"
25-
"sigs.k8s.io/controller-runtime/pkg/config" //nolint:staticcheck
2627
)
2728

2829
var scheme = runtime.NewScheme()

pkg/config/v1alpha1/doc.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,4 @@ limitations under the License.
1717
// Package v1alpha1 provides the ControllerManagerConfiguration used for
1818
// configuring ctrl.Manager
1919
// +kubebuilder:object:generate=true
20-
//
21-
// Deprecated: This package has been deprecated and will be removed in a future release.
2220
package v1alpha1

pkg/config/v1alpha1/register.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,12 @@ import (
2323

2424
var (
2525
// GroupVersion is group version used to register these objects.
26-
//
27-
// Deprecated: This package has been deprecated and will be removed in a future release.
2826
GroupVersion = schema.GroupVersion{Group: "controller-runtime.sigs.k8s.io", Version: "v1alpha1"}
2927

3028
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
31-
//
32-
// Deprecated: This package has been deprecated and will be removed in a future release.
3329
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
3430

3531
// AddToScheme adds the types in this group-version to the given scheme.
36-
//
37-
// Deprecated: This package has been deprecated and will be removed in a future release.
3832
AddToScheme = SchemeBuilder.AddToScheme
3933
)
4034

pkg/config/v1alpha1/types.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import (
2525
)
2626

2727
// ControllerManagerConfigurationSpec defines the desired state of GenericControllerManagerConfiguration.
28-
//
29-
// Deprecated: This package has been deprecated and will be removed in a future release.
3028
type ControllerManagerConfigurationSpec struct {
3129
// SyncPeriod determines the minimum frequency at which watched resources are
3230
// reconciled. A lower period will correct entropy more quickly, but reduce
@@ -77,8 +75,6 @@ type ControllerManagerConfigurationSpec struct {
7775

7876
// ControllerConfigurationSpec defines the global configuration for
7977
// controllers registered with the manager.
80-
//
81-
// Deprecated: This package has been deprecated and will be removed in a future release.
8278
type ControllerConfigurationSpec struct {
8379
// GroupKindConcurrency is a map from a Kind to the number of concurrent reconciliation
8480
// allowed for that controller.
@@ -153,20 +149,14 @@ type ControllerWebhook struct {
153149
// +kubebuilder:object:root=true
154150

155151
// ControllerManagerConfiguration is the Schema for the GenericControllerManagerConfigurations API.
156-
//
157-
// Deprecated: This package has been deprecated and will be removed in a future release.
158152
type ControllerManagerConfiguration struct {
159153
metav1.TypeMeta `json:",inline"`
160154

161155
// ControllerManagerConfiguration returns the contfigurations for controllers
162-
//
163-
// Deprecated: This package has been deprecated and will be removed in a future release.
164156
ControllerManagerConfigurationSpec `json:",inline"`
165157
}
166158

167159
// Complete returns the configuration for controller-runtime.
168-
//
169-
// Deprecated: This package has been deprecated and will be removed in a future release.
170160
func (c *ControllerManagerConfigurationSpec) Complete() (ControllerManagerConfigurationSpec, error) {
171161
return *c, nil
172162
}

pkg/controller/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func NewUnmanaged(name string, mgr manager.Manager, options Options) (Controller
141141
}
142142

143143
if options.RecoverPanic == nil {
144-
options.RecoverPanic = mgr.GetControllerOptions().RecoverPanic //nolint:staticcheck
144+
options.RecoverPanic = mgr.GetControllerOptions().RecoverPanic
145145
}
146146

147147
// Create controller with dependencies set

pkg/controller/controller_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"k8s.io/utils/pointer"
2929

3030
"sigs.k8s.io/controller-runtime/pkg/client"
31-
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
31+
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
3232
"sigs.k8s.io/controller-runtime/pkg/controller"
3333
"sigs.k8s.io/controller-runtime/pkg/event"
3434
"sigs.k8s.io/controller-runtime/pkg/handler"
@@ -147,7 +147,7 @@ var _ = Describe("controller.Controller", func() {
147147
})
148148

149149
It("should default RecoverPanic from the manager", func() {
150-
m, err := manager.New(cfg, manager.Options{Controller: v1alpha1.ControllerConfigurationSpec{RecoverPanic: pointer.Bool(true)}}) //nolint:staticcheck
150+
m, err := manager.New(cfg, manager.Options{Controller: v1alpha1.ControllerConfigurationSpec{RecoverPanic: pointer.Bool(true)}})
151151
Expect(err).NotTo(HaveOccurred())
152152

153153
c, err := controller.New("new-controller", m, controller.Options{
@@ -163,7 +163,7 @@ var _ = Describe("controller.Controller", func() {
163163
})
164164

165165
It("should not override RecoverPanic on the controller", func() {
166-
m, err := manager.New(cfg, manager.Options{Controller: v1alpha1.ControllerConfigurationSpec{RecoverPanic: pointer.Bool(true)}}) //nolint:staticcheck
166+
m, err := manager.New(cfg, manager.Options{Controller: v1alpha1.ControllerConfigurationSpec{RecoverPanic: pointer.Bool(true)}})
167167
Expect(err).NotTo(HaveOccurred())
168168

169169
c, err := controller.New("new-controller", m, controller.Options{

pkg/manager/example_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
"sigs.k8s.io/controller-runtime/pkg/cache"
2424
"sigs.k8s.io/controller-runtime/pkg/client/config"
25-
conf "sigs.k8s.io/controller-runtime/pkg/config" //nolint:staticcheck
25+
conf "sigs.k8s.io/controller-runtime/pkg/config"
2626
logf "sigs.k8s.io/controller-runtime/pkg/log"
2727
"sigs.k8s.io/controller-runtime/pkg/manager"
2828
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
@@ -92,7 +92,7 @@ func ExampleManager_start() {
9292
// using defaults.
9393
func ExampleOptions_andFrom() {
9494
opts := manager.Options{}
95-
if _, err := opts.AndFrom(conf.File()); err != nil { //nolint:staticcheck
95+
if _, err := opts.AndFrom(conf.File()); err != nil {
9696
log.Error(err, "unable to load config")
9797
os.Exit(1)
9898
}
@@ -120,7 +120,7 @@ func ExampleOptions_andFromOrDie() {
120120
os.Exit(1)
121121
}
122122

123-
mgr, err := manager.New(cfg, manager.Options{}.AndFromOrDie(conf.File())) //nolint:staticcheck
123+
mgr, err := manager.New(cfg, manager.Options{}.AndFromOrDie(conf.File()))
124124
if err != nil {
125125
log.Error(err, "unable to set up manager")
126126
os.Exit(1)

pkg/manager/internal.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import (
4141
"sigs.k8s.io/controller-runtime/pkg/cache"
4242
"sigs.k8s.io/controller-runtime/pkg/client"
4343
"sigs.k8s.io/controller-runtime/pkg/cluster"
44-
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
44+
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
4545
"sigs.k8s.io/controller-runtime/pkg/healthz"
4646
"sigs.k8s.io/controller-runtime/pkg/internal/httpserver"
4747
intrec "sigs.k8s.io/controller-runtime/pkg/internal/recorder"
@@ -108,7 +108,7 @@ type controllerManager struct {
108108
healthzHandler *healthz.Handler
109109

110110
// controllerOptions are the global controller options.
111-
controllerOptions v1alpha1.ControllerConfigurationSpec //nolint:staticcheck
111+
controllerOptions v1alpha1.ControllerConfigurationSpec
112112

113113
// Logger is the logger that should be used by this manager.
114114
// If none is set, it defaults to log.Log global logger.
@@ -325,7 +325,7 @@ func (cm *controllerManager) GetLogger() logr.Logger {
325325
return cm.logger
326326
}
327327

328-
func (cm *controllerManager) GetControllerOptions() v1alpha1.ControllerConfigurationSpec { //nolint:staticcheck
328+
func (cm *controllerManager) GetControllerOptions() v1alpha1.ControllerConfigurationSpec {
329329
return cm.controllerOptions
330330
}
331331

pkg/manager/manager.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import (
3636
"sigs.k8s.io/controller-runtime/pkg/cache"
3737
"sigs.k8s.io/controller-runtime/pkg/client"
3838
"sigs.k8s.io/controller-runtime/pkg/cluster"
39-
"sigs.k8s.io/controller-runtime/pkg/config" //nolint:staticcheck
40-
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
39+
"sigs.k8s.io/controller-runtime/pkg/config"
40+
"sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
4141
"sigs.k8s.io/controller-runtime/pkg/healthz"
4242
intrec "sigs.k8s.io/controller-runtime/pkg/internal/recorder"
4343
"sigs.k8s.io/controller-runtime/pkg/leaderelection"
@@ -94,11 +94,7 @@ type Manager interface {
9494
GetLogger() logr.Logger
9595

9696
// GetControllerOptions returns controller global configuration options.
97-
//
98-
// Deprecated: In a future version, the returned value is going to be replaced with a
99-
// different type that doesn't rely on component configuration types.
100-
// This is a temporary warning, and no action is needed as of today.
101-
GetControllerOptions() v1alpha1.ControllerConfigurationSpec //nolint:staticcheck
97+
GetControllerOptions() v1alpha1.ControllerConfigurationSpec
10298
}
10399

104100
// Options are the arguments for creating a new Manager.
@@ -301,11 +297,7 @@ type Options struct {
301297
// Controller contains global configuration options for controllers
302298
// registered within this manager.
303299
// +optional
304-
//
305-
// Deprecated: In a future version, the type of this field is going to be replaced with a
306-
// different struct that doesn't rely on component configuration types.
307-
// This is a temporary warning, and no action is needed as of today.
308-
Controller v1alpha1.ControllerConfigurationSpec //nolint:staticcheck
300+
Controller v1alpha1.ControllerConfigurationSpec
309301

310302
// makeBroadcaster allows deferring the creation of the broadcaster to
311303
// avoid leaking goroutines if we never call Start on this manager. It also
@@ -464,8 +456,6 @@ func New(config *rest.Config, options Options) (Manager, error) {
464456
// AndFrom will use a supplied type and convert to Options
465457
// any options already set on Options will be ignored, this is used to allow
466458
// cli flags to override anything specified in the config file.
467-
//
468-
// Deprecated: This method will be removed in a future release.
469459
func (o Options) AndFrom(loader config.ControllerManagerConfiguration) (Options, error) {
470460
if inj, wantsScheme := loader.(inject.Scheme); wantsScheme {
471461
err := inj.InjectScheme(o.Scheme)
@@ -531,8 +521,6 @@ func (o Options) AndFrom(loader config.ControllerManagerConfiguration) (Options,
531521
}
532522

533523
// AndFromOrDie will use options.AndFrom() and will panic if there are errors.
534-
//
535-
// Deprecated: This method will be removed in a future release.
536524
func (o Options) AndFromOrDie(loader config.ControllerManagerConfiguration) Options {
537525
o, err := o.AndFrom(loader)
538526
if err != nil {
@@ -541,7 +529,7 @@ func (o Options) AndFromOrDie(loader config.ControllerManagerConfiguration) Opti
541529
return o
542530
}
543531

544-
func (o Options) setLeaderElectionConfig(obj v1alpha1.ControllerManagerConfigurationSpec) Options { //nolint:staticcheck
532+
func (o Options) setLeaderElectionConfig(obj v1alpha1.ControllerManagerConfigurationSpec) Options {
545533
if obj.LeaderElection == nil {
546534
// The source does not have any configuration; noop
547535
return o

0 commit comments

Comments
 (0)