Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌱 Add input validations for controllers #11327

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions test/infrastructure/docker/exp/controllers/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package controllers
import (
"context"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
Expand All @@ -32,7 +31,6 @@ import (
// DockerMachinePoolReconciler reconciles a DockerMachinePool object.
type DockerMachinePoolReconciler struct {
Client client.Client
Scheme *runtime.Scheme
ContainerRuntime container.Runtime

// WatchFilterValue is the label value used to filter events prior to reconciliation.
Expand All @@ -43,7 +41,6 @@ type DockerMachinePoolReconciler struct {
func (r *DockerMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
return (&dockermachinepoolcontrollers.DockerMachinePoolReconciler{
Client: r.Client,
Scheme: r.Scheme,
ContainerRuntime: r.ContainerRuntime,
WatchFilterValue: r.WatchFilterValue,
}).SetupWithManager(ctx, mgr, options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"github.com/pkg/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
kerrors "k8s.io/apimachinery/pkg/util/errors"
Expand Down Expand Up @@ -63,7 +62,6 @@ const (
// DockerMachinePoolReconciler reconciles a DockerMachinePool object.
type DockerMachinePoolReconciler struct {
Client client.Client
Scheme *runtime.Scheme
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see its not used in the Reconiler so removed it instead of passing mgr.GetScheme() from main.go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thx for checking!

ContainerRuntime container.Runtime

// WatchFilterValue is the label value used to filter events prior to reconciliation.
Expand Down Expand Up @@ -157,8 +155,8 @@ func (r *DockerMachinePoolReconciler) Reconcile(ctx context.Context, req ctrl.Re

// SetupWithManager will add watches for this controller.
func (r *DockerMachinePoolReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, options controller.Options) error {
if r.Client == nil || r.ContainerRuntime == nil || r.Scheme == nil {
return errors.New("Client, ContainerRuntime and Scheme must not be nil")
if r.Client == nil || r.ContainerRuntime == nil {
return errors.New("Client and ContainerRuntime must not be nil")
}

predicateLog := ctrl.LoggerFrom(ctx).WithValues("controller", "dockermachinepool")
Expand Down