Repository: rancher-sandbox/cluster-api-provider-rke2
Pull request #107 (2023-03-10 12:22:19)

fixed linting issues (first pass)
Linting introduced in PR #52 was showing a lot of errors. This PR aims at fixing that by:
- By fixing the code itself for many linters
- By changing the configuration of `.golangci.yaml` for issues deemed unimportant or non urgent. 

**What this PR does / why we need it**:
In this PR, there is a lot of changed files caused by fixing linting issues, mostly minor ones for lisibility of code such as: 
- wsl (empty lines)
- lll (long lines)
- gci (import organisation)
- gofumpt
- etc.

Some of the more impacting linters (funlen for instance or gosec etc.) were disabled because they would mean a larger effort, to define on a case-by-case basis.

fixed some regressions from refactoring. After this PR, functionality should be equal to v0.1.0-alpha.1.
<!-- Enter a description of the change and why this change is needed -->

**Special notes for your reviewer**:

**Checklist**:
<!-- Put an "X" character inside the brackets of each completed task. Some may be optional depending on the PR in which case these can be deleted -->

- [X] squashed commits into logical changes
- [ ] includes documentation
- [ ] adds unit tests
- [ ] adds or updates e2e tests



Patch:
diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml
index 9fc8ce6..d6435f5 100644
--- a/.github/workflows/golangci-lint.yml
+++ b/.github/workflows/golangci-lint.yml
@@ -25,3 +25,4 @@ jobs:
         with:
           version: v1.50.1
           working-directory: ${{matrix.working-directory}}
+          args: --timeout=5m0s
diff --git a/.golangci.yml b/.golangci.yml
index fbe6b50..89bfe2f 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -5,9 +5,101 @@ run:
     - "zz_generated.*\\.go$"
     - "vendored_openapi\\.go$"
   allow-parallel-runners: true
-linters:
-  enable-all: true
 issues:
   include:
     - EXC0012
     - EXC0014
+  exclude-rules:
+    - path: _test\.go
+      linters:
+        - testpackage
+        - gochecknoglobals
+    - path: controlplane/api/v1alpha1/*
+      linters:
+        - gochecknoglobals
+    - source: "^//\\+kubebuilder:"
+      linters:
+        - lll
+    - path: _webhook\.go
+      linters:
+        - dupl
+        - wrapcheck
+    - text: var-naming
+      linters:
+        - revive
+    - text: ST1003
+      linters: 
+        - stylecheck
+    - text: G114    # Needs further discussion to confirm disabling 
+      linters:
+        - gosec  
+    - text: G402    # Needs futher discussion
+      path: api/v1alpha1
+      linters:
+        - gosec
+    - text: unexported-return
+      path: pkg/rke2
+      linters:
+        - revive
+linters-settings:
+  funlen:
+    lines: 110
+    statements: 60
+  lll:
+    line-length: 150
+  gomnd:
+    ignored-numbers:
+      - "5"
+      - "4"
+      - "3"
+  goimports:
+    local-prefixes: github.com/rancher-sandbox/cluster-api-provider-rke2
+  gci:
+    custom-order: true
+    #local-prefixes: github.com/rancher-sandbox/cluster-api-provider-rke2
+    sections:
+      - "standard" 
+      - "blank"
+      - "dot"
+      - "default"
+      - "prefix(sigs.k8s.io/cluster-api)"
+      - "prefix(github.com/rancher-sandbox/cluster-api-provider-rke2)"
+linters:
+  enable-all: true
+  disable:
+    - nolintlint
+    - tagliatelle
+    - exhaustruct
+    - exhaustive
+    - exhaustivestruct
+    - maligned
+    - funlen
+    - wrapcheck
+    - goerr113  # this one should probably be re-enabled soon
+    - paralleltest
+    - varnamelen
+    - cyclop
+    - gochecknoglobals
+    - gochecknoinits
+    - nonamedreturns
+    - gocritic
+    - ireturn     # Needs further discussion
+    - maintidx    # Needs further discussion
+    - nestif      # Needs further discussion
+    - gocognit    # Needs further discussion
+    - containedctx # Needs further discussion
+    # The following are all deprecated linters
+    - deadcode
+    - ifshort
+    - varcheck
+    - scopelint
+    - interfacer
+    - structcheck
+    - golint
+    - nosnakecase
+    # Disabled because of generics
+    - rowserrcheck
+    - sqlclosecheck
+    - wastedassign
+
+    
diff --git a/bootstrap/api/v1alpha1/condition_consts.go b/bootstrap/api/v1alpha1/condition_consts.go
index af82ed9..96c3a2f 100644
--- a/bootstrap/api/v1alpha1/condition_consts.go
+++ b/bootstrap/api/v1alpha1/condition_consts.go
@@ -25,6 +25,7 @@ const (
 	//
 	// NOTE: When the DataSecret generation starts the process completes immediately and within the
 	// same reconciliation, so the user will always see a transition from Wait to Generated without having
+	// to wait for the next reconciliation.
 	DataSecretAvailableCondition clusterv1.ConditionType = "Available"
 )
 
@@ -37,12 +38,16 @@ const (
 	// WaitingForClusterInfrastructureReason (Severity=Info) document a bootstrap secret generation process
 	// waiting for the cluster infrastructure to be ready.
 	//
-	// NOTE: Having the cluster infrastructure ready is a pre-condition for starting to create machines;
+	// NOTE: Having the cluster infrastructure ready is a pre-condition for starting to create machines.
 	WaitingForClusterInfrastructureReason string = "WaitingForClusterInfrastructure"
 )
 
 const (
+	// CertificatesAvailableCondition documents the status of the certificates generation process.
 	CertificatesAvailableCondition clusterv1.ConditionType = "CertificatesAvailable"
 
+	// CertificatesGenerationFailedReason documents a RKE2Config controller detecting
+	// an error while generating certificates; those kind of errors are usually due to misconfigurations
+	// and user intervention is required to get them fixed.
 	CertificatesGenerationFailedReason string = "CertificateGenerationFailed"
 )
diff --git a/bootstrap/api/v1alpha1/groupversion_info.go b/bootstrap/api/v1alpha1/groupversion_info.go
index fcb2dcd..9a84025 100644
--- a/bootstrap/api/v1alpha1/groupversion_info.go
+++ b/bootstrap/api/v1alpha1/groupversion_info.go
@@ -25,10 +25,10 @@ import (
 )
 
 var (
-	// GroupVersion is group version used to register these objects
+	// GroupVersion is group version used to register these objects.
 	GroupVersion = schema.GroupVersion{Group: "bootstrap.cluster.x-k8s.io", Version: "v1alpha1"}
 
-	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
+	// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
 	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
 
 	// AddToScheme adds the types in this group-version to the given scheme.
diff --git a/bootstrap/api/v1alpha1/rke2config_types.go b/bootstrap/api/v1alpha1/rke2config_types.go
index 912ffc1..93c1316 100644
--- a/bootstrap/api/v1alpha1/rke2config_types.go
+++ b/bootstrap/api/v1alpha1/rke2config_types.go
@@ -19,6 +19,7 @@ package v1alpha1
 import (
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
 	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 )
 
@@ -45,7 +46,7 @@ type RKE2ConfigSpec struct {
 	PrivateRegistriesConfig Registry `json:"privateRegistriesConfig,omitempty"`
 }
 
-// RKE2CommonNodeConfig describes some attributes that are common to agent and server nodes
+// RKE2AgentConfig describes some attributes that are common to agent and server nodes.
 type RKE2AgentConfig struct {
 	// DataDir Folder to hold state.
 	//+optional
@@ -121,7 +122,8 @@ type RKE2AgentConfig struct {
 	//+optional
 	RuntimeImage string `json:"runtimeImage,omitempty"`
 
-	// LoadBalancerPort local port for supervisor client load-balancer. If the supervisor and apiserver are not colocated an additional port 1 less than this port will also be used for the apiserver client load-balancer (default: 6444).
+	// LoadBalancerPort local port for supervisor client load-balancer. If the supervisor and apiserver are
+	// not colocated an additional port 1 less than this port will also be used for the apiserver client load-balancer (default: 6444).
 	//+optional
 	LoadBalancerPort int `json:"loadBalancerPort,omitempty"`
 
@@ -183,12 +185,14 @@ type RKE2Config struct {
 	Status RKE2ConfigStatus `json:"status,omitempty"`
 }
 
-func (c *RKE2Config) GetConditions() clusterv1.Conditions {
-	return c.Status.Conditions
+// GetConditions returns the list of conditions for a RKE2Config.
+func (r *RKE2Config) GetConditions() clusterv1.Conditions {
+	return r.Status.Conditions
 }
 
-func (c *RKE2Config) SetConditions(conditions clusterv1.Conditions) {
-	c.Status.Conditions = conditions
+// SetConditions sets the conditions for a RKE2Config.
+func (r *RKE2Config) SetConditions(conditions clusterv1.Conditions) {
+	r.Status.Conditions = conditions
 }
 
 // +kubebuilder:object:root=true
@@ -204,7 +208,7 @@ type RKE2ConfigList struct {
 type CISProfile string
 
 const (
-	// CIS1_23 references RKE2's CIS Profile "cis-1.23"
+	// CIS1_23 references RKE2's CIS Profile "cis-1.23".
 	CIS1_23 CISProfile = "cis-1.23"
 )
 
@@ -251,11 +255,11 @@ type File struct {
 // Only one field may be populated in any given instance. Developers adding new
 // sources of data for target systems should add them here.
 type FileSource struct {
-	// Secret represents a secret that should populate this file.
+	// SecretFileSource represents a secret that should populate this file.
 	Secret SecretFileSource `json:"secret"`
 }
 
-// Adapts a Secret into a FileSource.
+// SecretFileSource adapts a Secret into a FileSource.
 //
 // The contents of the target Secret's Data field will be presented
 // as files using the keys in the Data field as the file names.
@@ -319,6 +323,7 @@ type TLSConfig struct {
 	InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"`
 }
 
+// ComponentConfig defines the configuration for a Kubernetes Component.
 type ComponentConfig struct {
 	// ExtraEnv is a map of environment variables to pass on to a Kubernetes Component command.
 	//+optional
diff --git a/bootstrap/api/v1alpha1/rke2config_webhook.go b/bootstrap/api/v1alpha1/rke2config_webhook.go
index 94e8855..9f64db2 100644
--- a/bootstrap/api/v1alpha1/rke2config_webhook.go
+++ b/bootstrap/api/v1alpha1/rke2config_webhook.go
@@ -26,6 +26,7 @@ import (
 // log is for logging in this package.
 var rke2configlog = logf.Log.WithName("rke2config-resource")
 
+// SetupWebhookWithManager sets up and registers the webhook with the manager.
 func (r *RKE2Config) SetupWebhookWithManager(mgr ctrl.Manager) error {
 	return ctrl.NewWebhookManagedBy(mgr).
 		For(r).
@@ -36,31 +37,30 @@ func (r *RKE2Config) SetupWebhookWithManager(mgr ctrl.Manager) error {
 
 var _ webhook.Defaulter = &RKE2Config{}
 
-// Default implements webhook.Defaulter so a webhook will be registered for the type
+// Default implements webhook.Defaulter so a webhook will be registered for the type.
 func (r *RKE2Config) Default() {
 	rke2configlog.Info("default", "name", r.Name)
-
 }
 
 //+kubebuilder:webhook:path=/validate-bootstrap-cluster-x-k8s-io-v1alpha1-rke2config,mutating=false,failurePolicy=fail,sideEffects=None,groups=bootstrap.cluster.x-k8s.io,resources=rke2configs,verbs=create;update,versions=v1alpha1,name=vrke2config.kb.io,admissionReviewVersions=v1
 
 var _ webhook.Validator = &RKE2Config{}
 
-// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
+// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2Config) ValidateCreate() error {
 	rke2configlog.Info("validate create", "name", r.Name)
 
 	return nil
 }
 
-// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
+// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2Config) ValidateUpdate(old runtime.Object) error {
 	rke2configlog.Info("validate update", "name", r.Name)
 
 	return nil
 }
 
-// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
+// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2Config) ValidateDelete() error {
 	rke2configlog.Info("validate delete", "name", r.Name)
 
diff --git a/bootstrap/api/v1alpha1/rke2configtemplate_types.go b/bootstrap/api/v1alpha1/rke2configtemplate_types.go
index b223887..812d902 100644
--- a/bootstrap/api/v1alpha1/rke2configtemplate_types.go
+++ b/bootstrap/api/v1alpha1/rke2configtemplate_types.go
@@ -22,8 +22,8 @@ import (
 
 // RKE2ConfigTemplateSpec defines the specification of RKE2ConfigTemplate.
 type RKE2ConfigTemplateSpec struct {
-	// Template references a RKE2ConfigTemplate, which is used to include an RKE2ConfigSpec struct. This is used to include a desired RKE2ConfigSpec configuration
-	// when an RKE2Config resource is generated by a MachineDeployment resource.
+	// Template references a RKE2ConfigTemplate, which is used to include an RKE2ConfigSpec struct.
+	//	This is used to include a desired RKE2ConfigSpec configuration when an RKE2Config resource is generated by a MachineDeployment resource.
 	Template RKE2ConfigTemplateResource `json:"template"`
 }
 
diff --git a/bootstrap/api/v1alpha1/rke2configtemplate_webhook.go b/bootstrap/api/v1alpha1/rke2configtemplate_webhook.go
index 9d58415..59a9dcb 100644
--- a/bootstrap/api/v1alpha1/rke2configtemplate_webhook.go
+++ b/bootstrap/api/v1alpha1/rke2configtemplate_webhook.go
@@ -23,9 +23,10 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/webhook"
 )
 
-// log is for logging in this package.
+// RKE2configtemplatelog is for logging in this package.
 var RKE2configtemplatelog = logf.Log.WithName("RKE2configtemplate-resource")
 
+// SetupWebhookWithManager sets up and registers the webhook with the manager.
 func (r *RKE2ConfigTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
 	return ctrl.NewWebhookManagedBy(mgr).
 		For(r).
@@ -36,31 +37,30 @@ func (r *RKE2ConfigTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
 
 var _ webhook.Defaulter = &RKE2ConfigTemplate{}
 
-// Default implements webhook.Defaulter so a webhook will be registered for the type
+// Default implements webhook.Defaulter so a webhook will be registered for the type.
 func (r *RKE2ConfigTemplate) Default() {
 	RKE2configtemplatelog.Info("default", "name", r.Name)
-
 }
 
 //+kubebuilder:webhook:path=/validate-bootstrap-cluster-x-k8s-io-v1alpha1-rke2configtemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=bootstrap.cluster.x-k8s.io,resources=rke2configtemplates,verbs=create;update,versions=v1alpha1,name=vrke2configtemplate.kb.io,admissionReviewVersions=v1
 
 var _ webhook.Validator = &RKE2ConfigTemplate{}
 
-// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
+// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ConfigTemplate) ValidateCreate() error {
 	RKE2configtemplatelog.Info("validate create", "name", r.Name)
 
 	return nil
 }
 
-// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
+// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ConfigTemplate) ValidateUpdate(old runtime.Object) error {
 	RKE2configtemplatelog.Info("validate update", "name", r.Name)
 
 	return nil
 }
 
-// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
+// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ConfigTemplate) ValidateDelete() error {
 	RKE2configtemplatelog.Info("validate delete", "name", r.Name)
 
diff --git a/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configs.yaml b/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configs.yaml
index 84b7c33..c7a097b 100644
--- a/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configs.yaml
+++ b/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configs.yaml
@@ -266,8 +266,8 @@ spec:
                         populate the file.
                       properties:
                         secret:
-                          description: Secret represents a secret that should populate
-                            this file.
+                          description: SecretFileSource represents a secret that should
+                            populate this file.
                           properties:
                             key:
                               description: Key is the key in the secret's data map
diff --git a/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configtemplates.yaml b/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configtemplates.yaml
index 7bacedb..aa55d90 100644
--- a/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configtemplates.yaml
+++ b/bootstrap/config/crd/bases/bootstrap.cluster.x-k8s.io_rke2configtemplates.yaml
@@ -293,8 +293,8 @@ spec:
                                 to populate the file.
                               properties:
                                 secret:
-                                  description: Secret represents a secret that should
-                                    populate this file.
+                                  description: SecretFileSource represents a secret
+                                    that should populate this file.
                                   properties:
                                     key:
                                       description: Key is the key in the secret's
diff --git a/bootstrap/internal/cloudinit/cloudinit.go b/bootstrap/internal/cloudinit/cloudinit.go
index 57e2964..9cba660 100644
--- a/bootstrap/internal/cloudinit/cloudinit.go
+++ b/bootstrap/internal/cloudinit/cloudinit.go
@@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
+//nolint:gochecknoglobals
 package cloudinit
 
 import (
@@ -22,18 +23,18 @@ import (
 	"text/template"
 
 	"github.com/pkg/errors"
+
 	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
 )
 
-var (
-	defaultTemplateFuncMap = template.FuncMap{
-		"Indent": templateYAMLIndent,
-	}
-)
+var defaultTemplateFuncMap = template.FuncMap{
+	"Indent": templateYAMLIndent,
+}
 
 func templateYAMLIndent(i int, input string) string {
 	split := strings.Split(input, "\n")
 	ident := "\n" + strings.Repeat(" ", i)
+
 	return strings.Repeat(" ", i) + strings.Join(split, ident)
 }
 
diff --git a/bootstrap/internal/cloudinit/controlplane_init.go b/bootstrap/internal/cloudinit/controlplane_init.go
index a4b6a84..1c087d4 100644
--- a/bootstrap/internal/cloudinit/controlplane_init.go
+++ b/bootstrap/internal/cloudinit/controlplane_init.go
@@ -22,13 +22,14 @@ import (
 	"github.com/rancher-sandbox/cluster-api-provider-rke2/pkg/secret"
 )
 
+//nolint:lll
 const (
 	controlPlaneCloudInit = `{{.Header}}
 {{template "files" .WriteFiles}}
 {{template "ntp" .NTPServers}}
 runcmd:
 {{- template "commands" .PreRKE2Commands }}
-  - {{ if .AirGapped }}INSTALL_RKE2_ARTIFACT_PATH=/opt/rke2-artifacts sh /opt/install.sh{{ else }}'curl -sfL https://get.rke2.io | INSTALL_RKE2_VERSION=%[1]s sh -s - server'{{ end }}
+  - {{ if .AirGapped }}INSTALL_RKE2_ARTIFACT_PATH=/opt/rke2-artifacts sh /opt/install.sh{{ else }}'curl -sfL https://get.rke2.io | INSTALL_RKE2_VERSION=%[1]s sh -s - server'{{ end }} 
   - 'systemctl enable rke2-server.service'
   - 'systemctl start rke2-server.service'
   - 'mkdir /run/cluster-api' 
@@ -44,6 +45,8 @@ type ControlPlaneInput struct {
 }
 
 // NewInitControlPlane returns the user data string to be used on a controlplane instance.
+//
+//nolint:gofumpt
 func NewInitControlPlane(input *ControlPlaneInput) ([]byte, error) {
 	input.Header = cloudConfigHeader
 	input.WriteFiles = append(input.WriteFiles, input.Certificates.AsFiles()...)
@@ -51,6 +54,7 @@ func NewInitControlPlane(input *ControlPlaneInput) ([]byte, error) {
 	input.SentinelFileCommand = sentinelFileCommand
 	controlPlaneCloudJoinWithVersion := fmt.Sprintf(controlPlaneCloudInit, input.RKE2Version)
 	userData, err := generate("InitControlplane", controlPlaneCloudJoinWithVersion, input)
+
 	if err != nil {
 		return nil, err
 	}
diff --git a/bootstrap/internal/cloudinit/controlplane_join.go b/bootstrap/internal/cloudinit/controlplane_join.go
index 26d8803..8b7a1ea 100644
--- a/bootstrap/internal/cloudinit/controlplane_join.go
+++ b/bootstrap/internal/cloudinit/controlplane_join.go
@@ -20,13 +20,16 @@ import (
 	"fmt"
 )
 
-// NewInitControlPlane returns the user data string to be used on a controlplane instance.
+// NewJoinControlPlane returns the user data string to be used on a controlplane instance.
+//
+// nolint:gofumpt
 func NewJoinControlPlane(input *ControlPlaneInput) ([]byte, error) {
 	input.Header = cloudConfigHeader
 	input.WriteFiles = append(input.WriteFiles, input.ConfigFile)
 	input.SentinelFileCommand = sentinelFileCommand
 	controlPlaneCloudJoinWithVersion := fmt.Sprintf(controlPlaneCloudInit, input.RKE2Version)
 	userData, err := generate("JoinControlplane", controlPlaneCloudJoinWithVersion, input)
+
 	if err != nil {
 		return nil, err
 	}
diff --git a/bootstrap/internal/cloudinit/worker_join.go b/bootstrap/internal/cloudinit/worker_join.go
index 89438b4..f90c900 100644
--- a/bootstrap/internal/cloudinit/worker_join.go
+++ b/bootstrap/internal/cloudinit/worker_join.go
@@ -20,6 +20,7 @@ import (
 	"fmt"
 )
 
+//nolint:lll
 const (
 	workerCloudInit = `{{.Header}}
 {{template "files" .WriteFiles}}
@@ -35,13 +36,16 @@ runcmd:
 `
 )
 
-// NewInitControlPlane returns the user data string to be used on a controlplane instance.
+// NewJoinWorker returns the user data string to be used on a controlplane instance.
+//
+// nolint:gofumpt
 func NewJoinWorker(input *BaseUserData) ([]byte, error) {
 	input.Header = cloudConfigHeader
 	input.WriteFiles = append(input.WriteFiles, input.ConfigFile)
 	input.SentinelFileCommand = sentinelFileCommand
 	workerCloudJoinWithVersion := fmt.Sprintf(workerCloudInit, input.RKE2Version)
 	userData, err := generate("JoinWorker", workerCloudJoinWithVersion, input)
+
 	if err != nil {
 		return nil, err
 	}
diff --git a/bootstrap/internal/controllers/rke2config_controller.go b/bootstrap/internal/controllers/rke2config_controller.go
index 3746378..6b5473e 100644
--- a/bootstrap/internal/controllers/rke2config_controller.go
+++ b/bootstrap/internal/controllers/rke2config_controller.go
@@ -57,7 +57,7 @@ const (
 	serverURLFormat  string = "https://%v:%v"
 )
 
-// RKE2ConfigReconciler reconciles a Rke2Config object
+// RKE2ConfigReconciler reconciles a Rke2Config object.
 type RKE2ConfigReconciler struct {
 	RKE2InitLock RKE2InitLock
 	client.Client
@@ -65,7 +65,12 @@ type RKE2ConfigReconciler struct {
 }
 
 const (
+	// DefaultManifestDirectory is the default directory to store kubernetes manifests that RKE2 will deploy automatically.
 	DefaultManifestDirectory string = "/var/lib/rancher/rke2/server/manifests"
+
+	// DefaultRequeueAfter is the default requeue time.
+	DefaultRequeueAfter time.Duration = 20 * time.Second
+	defaultTokenLength                = 16
 )
 
 //+kubebuilder:rbac:groups=bootstrap.cluster.x-k8s.io,resources=rke2configs;rke2configs/status;rke2configs/finalizers,verbs=get;list;watch;create;update;patch;delete
@@ -75,143 +80,97 @@ const (
 
 // Reconcile is part of the main kubernetes reconciliation loop which aims to
 // move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the Rke2Config object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.12.2/pkg/reconcile
 func (r *RKE2ConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, rerr error) {
 	logger := log.FromContext(ctx)
 	logger.Info("Reconcile RKE2Config")
 
-	config := &bootstrapv1.RKE2Config{}
-
-	if err := r.Get(ctx, req.NamespacedName, config, &client.GetOptions{}); err != nil {
-		if apierrors.IsNotFound(err) {
-			logger.Error(err, "rke2Config not found", "rke2-config-name", req.NamespacedName)
-			return ctrl.Result{}, err
-		}
-		logger.Error(err, "", "rke2-config-namespaced-name", req.NamespacedName)
-		return ctrl.Result{Requeue: true}, err
-	}
-
-	scope := &Scope{}
-
-	machine, err := util.GetOwnerMachine(ctx, r.Client, config.ObjectMeta)
+	scope, res, err := r.prepareScope(ctx, logger, req)
 	if err != nil {
-		logger.Error(err, "Failed to retrieve owner Machine from the API Server", config.Namespace+"/"+config.Name, "machine", machine.Name)
-		return ctrl.Result{}, err
-	}
-	if machine == nil {
-		logger.Info("Machine Controller has not yet set OwnerRef")
-		return ctrl.Result{Requeue: true}, nil
-	}
-	scope.Machine = machine
-	logger = logger.WithValues(machine.Kind, machine.GetNamespace()+"/"+machine.GetName(), "resourceVersion", machine.GetResourceVersion())
+		if errors.Is(errors.Cause(err), util.ErrNoCluster) {
+			logger.Info(fmt.Sprintf("%s does not belong to a cluster yet, waiting until it's part of a cluster", scope.Machine.Kind))
 
-	// Getting the ControlPlane owner
-	cp, err := bsutil.GetOwnerControlPlane(ctx, r.Client, scope.Machine.ObjectMeta)
-	if err != nil {
-		logger.Error(err, "Failed to retrieve owner ControlPlane from the API Server", config.Namespace+"/"+config.Name, "cluster", cp.Name)
-		return ctrl.Result{}, err
-	}
-	if cp == nil {
-		logger.V(5).Info("This config is for a worker node")
-		scope.HasControlPlaneOwner = false
-	} else {
-		logger.Info("This config is for a ControlPlane node")
-		scope.HasControlPlaneOwner = true
-		scope.ControlPlane = cp
-		logger = logger.WithValues(cp.Kind, cp.GetNamespace()+"/"+cp.GetName(), "resourceVersion", cp.GetResourceVersion())
-	}
-
-	cluster, err := util.GetClusterByName(ctx, r.Client, machine.GetNamespace(), machine.Spec.ClusterName)
-	if err != nil {
-		if errors.Cause(err) == util.ErrNoCluster {
-			logger.Info(fmt.Sprintf("%s does not belong to a cluster yet, waiting until it's part of a cluster", machine.Kind))
-			return ctrl.Result{}, nil
+			return res, nil
 		}
 
 		if apierrors.IsNotFound(err) {
 			logger.Info("Cluster does not exist yet, waiting until it is created")
-			return ctrl.Result{}, nil
+
+			return res, nil
 		}
+
 		logger.Error(err, "Could not get cluster with metadata")
-		return ctrl.Result{}, err
+
+		return res, nil
 	}
 
-	if annotations.IsPaused(cluster, config) {
-		logger.Info("Reconciliation is paused for this object")
-		return ctrl.Result{}, nil
+	if res != (ctrl.Result{}) {
+		return res, nil
 	}
 
-	scope.Cluster = cluster
-	scope.Config = config
-	scope.Logger = logger
 	ctx = ctrl.LoggerInto(ctx, logger)
 
 	// Initialize the patch helper.
-	patchHelper, err := patch.NewHelper(config, r.Client)
+	patchHelper, err := patch.NewHelper(scope.Config, r.Client)
 	if err != nil {
 		return ctrl.Result{}, err
 	}
 
 	// Attempt to Patch the RKE2Config object and status after each reconciliation if no error occurs.
 	defer func() {
-		// always update the readyCondition; the summary is represented using the "1 of x completed" notation.
-		conditions.SetSummary(config,
+		conditions.SetSummary(scope.Config,
 			conditions.WithConditions(
 				bootstrapv1.DataSecretAvailableCondition,
 			),
 		)
-		// Patch ObservedGeneration only if the reconciliation completed successfully
+
 		patchOpts := []patch.Option{}
 		if rerr == nil {
 			patchOpts = append(patchOpts, patch.WithStatusObservedGeneration{})
 		}
-		if err := patchHelper.Patch(ctx, config, patchOpts...); err != nil {
+
+		if err := patchHelper.Patch(ctx, scope.Config, patchOpts...); err != nil {
 			logger.Error(rerr, "Failed to patch config")
+
 			if rerr == nil {
 				rerr = err
 			}
 		}
 	}()
 
-	if !cluster.Status.InfrastructureReady {
+	if !scope.Cluster.Status.InfrastructureReady {
 		logger.Info("Infrastructure machine not yet ready")
-		conditions.MarkFalse(config, bootstrapv1.DataSecretAvailableCondition, bootstrapv1.WaitingForClusterInfrastructureReason, clusterv1.ConditionSeverityInfo, "")
+		conditions.MarkFalse(
+			scope.Config,
+			bootstrapv1.DataSecretAvailableCondition,
+			bootstrapv1.WaitingForClusterInfrastructureReason,
+			clusterv1.ConditionSeverityInfo,
+			"")
+
 		return ctrl.Result{Requeue: true}, nil
 	}
-	// Migrate plaintext data to secret.
-	// if config.Status.BootstrapData != nil && config.Status.DataSecretName == nil {
-	// 	return ctrl.Result{}, r.storeBootstrapData(ctx, scope, config.Status.BootstrapData)
-	// }
-	// Reconcile status for machines that already have a secret reference, but our status isn't up to date.
-	// This case solves the pivoting scenario (or a backup restore) which doesn't preserve the status subresource on objects.
-	if machine.Spec.Bootstrap.DataSecretName != nil && (!config.Status.Ready || config.Status.DataSecretName == nil) {
-		config.Status.Ready = true
-		config.Status.DataSecretName = machine.Spec.Bootstrap.DataSecretName
-		conditions.MarkTrue(config, bootstrapv1.DataSecretAvailableCondition)
+
+	if scope.Machine.Spec.Bootstrap.DataSecretName != nil && (!scope.Config.Status.Ready || scope.Config.Status.DataSecretName == nil) {
+		scope.Config.Status.Ready = true
+		scope.Config.Status.DataSecretName = scope.Machine.Spec.Bootstrap.DataSecretName
+		conditions.MarkTrue(scope.Config, bootstrapv1.DataSecretAvailableCondition)
+
 		return ctrl.Result{}, nil
 	}
 	// Status is ready means a config has been generated.
-	if config.Status.Ready {
+	if scope.Config.Status.Ready {
 		// In any other case just return as the config is already generated and need not be generated again.
-		conditions.MarkTrue(config, bootstrapv1.DataSecretAvailableCondition)
+		conditions.MarkTrue(scope.Config, bootstrapv1.DataSecretAvailableCondition)
+
 		return ctrl.Result{}, nil
 	}
 
 	// Note: can't use IsFalse here because we need to handle the absence of the condition as well as false.
-	if !conditions.IsTrue(cluster, clusterv1.ControlPlaneInitializedCondition) {
+	if !conditions.IsTrue(scope.Cluster, clusterv1.ControlPlaneInitializedCondition) {
 		return r.handleClusterNotInitialized(ctx, scope)
 	}
 
-	// Every other case it's a join scenario
-
 	// Unlock any locks that might have been set during init process
-	r.RKE2InitLock.Unlock(ctx, cluster)
+	r.RKE2InitLock.Unlock(ctx, scope.Cluster)
 
 	// it's a control plane join
 	if scope.HasControlPlaneOwner {
@@ -225,14 +184,92 @@ func (r *RKE2ConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request)
 		Namespace: scope.Cluster.Spec.ControlPlaneRef.Namespace,
 		Name:      scope.Cluster.Spec.ControlPlaneRef.Name,
 	}, &wkControlPlane)
+
 	if err != nil {
 		scope.Logger.Info("Unable to find control plane object for owning Cluster", "error", err)
+
 		return ctrl.Result{Requeue: true}, nil
 	}
+
 	scope.ControlPlane = &wkControlPlane
+
 	return r.joinWorker(ctx, scope)
 }
 
+func (r *RKE2ConfigReconciler) prepareScope(
+	ctx context.Context,
+	logger logr.Logger,
+	req ctrl.Request,
+) (*Scope, ctrl.Result, error) {
+	config := &bootstrapv1.RKE2Config{}
+
+	if err := r.Get(ctx, req.NamespacedName, config, &client.GetOptions{}); err != nil {
+		if apierrors.IsNotFound(err) {
+			logger.Error(err, "rke2Config not found", "rke2-config-name", req.NamespacedName)
+
+			return nil, ctrl.Result{}, err
+		}
+
+		logger.Error(err, "", "rke2-config-namespaced-name", req.NamespacedName)
+
+		return nil, ctrl.Result{Requeue: true}, err
+	}
+
+	machine, err := util.GetOwnerMachine(ctx, r.Client, config.ObjectMeta)
+	if err != nil {
+		logger.Error(err, "Failed to retrieve owner Machine from the API Server", "RKE2Config", config.Namespace+"/"+config.Name)
+
+		return nil, ctrl.Result{}, err
+	}
+
+	if machine == nil {
+		logger.Info("Machine Controller has not yet set OwnerRef")
+
+		return nil, ctrl.Result{Requeue: true}, nil
+	}
+
+	logger = logger.WithValues(machine.Kind, machine.GetNamespace()+"/"+machine.GetName(), "resourceVersion", machine.GetResourceVersion())
+	scope := &Scope{
+		Config:  config,
+		Machine: machine,
+		Logger:  logger,
+	}
+
+	// Getting the ControlPlane owner
+	cp, err := bsutil.GetOwnerControlPlane(ctx, r.Client, scope.Machine.ObjectMeta)
+	if err != nil && cp != nil {
+		logger.Error(err, "Failed to retrieve owner ControlPlane from the API Server", "RKE2Config", config.Namespace+"/"+config.Name)
+
+		return nil, ctrl.Result{RequeueAfter: DefaultRequeueAfter}, err
+	}
+
+	if cp == nil {
+		logger.V(5).Info("This config is for a worker node")
+
+		scope.HasControlPlaneOwner = false
+	} else {
+		logger.Info("This config is for a ControlPlane node")
+		scope.HasControlPlaneOwner = true
+		scope.ControlPlane = cp
+		logger = logger.WithValues(cp.Kind, cp.GetNamespace()+"/"+cp.GetName(), "resourceVersion", cp.GetResourceVersion())
+	}
+
+	cluster, err := util.GetClusterByName(ctx, r.Client, machine.GetNamespace(), machine.Spec.ClusterName)
+	if err != nil {
+		return nil, ctrl.Result{RequeueAfter: DefaultRequeueAfter}, err
+	}
+
+	if annotations.IsPaused(cluster, config) {
+		logger.Info("Reconciliation is paused for this object")
+
+		return nil, ctrl.Result{RequeueAfter: DefaultRequeueAfter}, fmt.Errorf("reconciliation is paused for this object")
+	}
+
+	scope.Cluster = cluster
+
+	return scope, ctrl.Result{}, nil
+}
+
 // Scope is a scoped struct used during reconciliation.
 type Scope struct {
 	Logger               logr.Logger
@@ -245,28 +282,27 @@ type Scope struct {
 
 // SetupWithManager sets up the controller with the Manager.
 func (r *RKE2ConfigReconciler) SetupWithManager(mgr ctrl.Manager) error {
-
 	if r.RKE2InitLock == nil {
 		r.RKE2InitLock = locking.NewControlPlaneInitMutex(mgr.GetClient())
 	}
+
 	return ctrl.NewControllerManagedBy(mgr).
 		For(&bootstrapv1.RKE2Config{}).
 		Complete(r)
 }
 
-// TODO: Implement these functions
-
-// handleClusterNotInitialized handles the first control plane node
-func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context, scope *Scope) (res ctrl.Result, reterr error) {
-
+// handleClusterNotInitialized handles the first control plane node.
+func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context, scope *Scope) (res ctrl.Result, reterr error) { //nolint:funlen
 	if !scope.HasControlPlaneOwner {
 		scope.Logger.Info("Requeuing because this machine is not a Control Plane machine")
-		return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
+
+		return ctrl.Result{RequeueAfter: DefaultRequeueAfter}, nil
 	}
 
 	if !r.RKE2InitLock.Lock(ctx, scope.Cluster, scope.Machine) {
 		scope.Logger.Info("A control plane is already being initialized, requeuing until control plane is ready")
-		return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil
+
+		return ctrl.Result{RequeueAfter: DefaultRequeueAfter}, nil
 	}
 
 	defer func() {
@@ -284,20 +320,29 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
 		util.ObjectKey(scope.Cluster),
 		*metav1.NewControllerRef(scope.Config, bootstrapv1.GroupVersion.WithKind("RKE2Config")),
 	); err != nil {
-		conditions.MarkFalse(scope.Config, bootstrapv1.CertificatesAvailableCondition, bootstrapv1.CertificatesGenerationFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
+		conditions.MarkFalse(
+			scope.Config,
+			bootstrapv1.CertificatesAvailableCondition,
+			bootstrapv1.CertificatesGenerationFailedReason,
+			clusterv1.ConditionSeverityWarning,
+			err.Error())
+
 		return ctrl.Result{}, err
 	}
+
 	conditions.MarkTrue(scope.Config, bootstrapv1.CertificatesAvailableCondition)
 
 	token, err := r.generateAndStoreToken(ctx, scope)
 	if err != nil {
 		scope.Logger.Error(err, "unable to generate and store an RKE2 server token")
+
 		return ctrl.Result{}, err
 	}
+
 	scope.Logger.Info("RKE2 server token generated and stored in Secret!")
 
 	configStruct, configFiles, err := rke2.GenerateInitControlPlaneConfig(
-		rke2.RKE2ServerConfigOpts{
+		rke2.ServerConfigOpts{
 			Cluster:              *scope.Cluster,
 			ControlPlaneEndpoint: scope.Cluster.Spec.ControlPlaneEndpoint.Host,
 			Token:                token,
@@ -307,16 +352,15 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
 			Ctx:                  ctx,
 			Client:               r.Client,
 		})
-
 	if err != nil {
 		return ctrl.Result{}, err
 	}
 
 	b, err := kubeyaml.Marshal(configStruct)
 	if err != nil {
-
 		return ctrl.Result{}, err
 	}
+
 	scope.Logger.Info("Server config marshalled successfully")
 
 	initConfigFile := bootstrapv1.File{
@@ -333,11 +377,17 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
 
 	manifestFiles, err := generateFilesFromManifestConfig(ctx, r.Client, scope.ControlPlane.Spec.ManifestsConfigMapReference)
 	if err != nil {
+		manifestCm := scope.ControlPlane.Spec.ManifestsConfigMapReference.Name
+		ns := scope.ControlPlane.Spec.ManifestsConfigMapReference.Namespace
+
 		if apierrors.IsNotFound(err) {
-			scope.Logger.Error(err, "ConfigMap referenced by manifestsConfigMapReference not found!", "namespace", scope.ControlPlane.Spec.ManifestsConfigMapReference.Namespace, "name", scope.ControlPlane.Spec.ManifestsConfigMapReference.Name)
+			scope.Logger.Error(err, "Manifest ConfigMap referenced!", "namespace", ns, "name", manifestCm)
+
 			return ctrl.Result{}, err
 		}
-		scope.Logger.Error(err, "Problem when getting ConfigMap referenced by manifestsConfigMapReference", "namespace", scope.ControlPlane.Spec.ManifestsConfigMapReference.Namespace, "name", scope.ControlPlane.Spec.ManifestsConfigMapReference.Name)
+
+		scope.Logger.Error(err, "Problem when getting Manifest ConfigMap!", "namespace", ns, "name", manifestCm)
+
 		return ctrl.Result{}, err
 	}
 
@@ -375,25 +425,31 @@ func (r *RKE2ConfigReconciler) handleClusterNotInitialized(ctx context.Context,
 
 // generateFileListIncludingRegistries generates a list of files to be written to disk on the node
 // This list includes a registries.yaml file if the user has provided a PrivateRegistriesConfig
-// and the files fields provided in the RKE2Config
-func (r *RKE2ConfigReconciler) generateFileListIncludingRegistries(ctx context.Context, scope *Scope, configFiles []bootstrapv1.File) ([]bootstrapv1.File, error) {
-	registries, registryFiles, err := rke2.GenerateRegistries(rke2.RKE2ConfigRegistry{
+// and the files fields provided in the RKE2Config.
+func (r *RKE2ConfigReconciler) generateFileListIncludingRegistries(
+	ctx context.Context,
+	scope *Scope,
+	configFiles []bootstrapv1.File,
+) ([]bootstrapv1.File, error) {
+	registries, registryFiles, err := rke2.GenerateRegistries(rke2.RegistryScope{
 		Registry: scope.Config.Spec.PrivateRegistriesConfig,
 		Client:   r.Client,
 		Ctx:      ctx,
 		Logger:   scope.Logger,
 	})
-
 	if err != nil {
 		scope.Logger.Error(err, "unable to generate registries.yaml for Init Control Plane node")
+
 		return nil, err
 	}
 
 	registriesYAML, err := kubeyaml.Marshal(registries)
 	if err != nil {
 		scope.Logger.Error(err, "unable to marshall registries.yaml")
+
 		return nil, err
 	}
+
 	scope.Logger.V(4).Info("Registries.yaml marshalled successfully")
 
 	initRegistriesFile := bootstrapv1.File{
@@ -403,37 +459,47 @@ func (r *RKE2ConfigReconciler) generateFileListIncludingRegistries(ctx context.C
 		Permissions: filePermissions,
 	}
 
-	files := append(configFiles, registryFiles...)
+	files := configFiles
+	files = append(files, registryFiles...)
 	files = append(files, initRegistriesFile)
 	files = append(files, scope.Config.Spec.Files...)
+
 	return files, nil
 }
 
+// RKE2InitLock is an interface for locking/unlocking Machine Creation as soon as an Init Process for the Control Plane
+// has been started.
 type RKE2InitLock interface {
 	Unlock(ctx context.Context, cluster *clusterv1.Cluster) bool
 	Lock(ctx context.Context, cluster *clusterv1.Cluster, machine *clusterv1.Machine) bool
 }
 
 // joinControlPlane implements the part of the Reconciler which bootstraps a secondary
-// Control Plane machine joining a cluster that is already initialized
+// Control Plane machine joining a cluster that is already initialized.
 func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scope) (res ctrl.Result, rerr error) {
-
 	tokenSecret := &corev1.Secret{}
 	if err := r.Client.Get(ctx, types.NamespacedName{Namespace: scope.Cluster.Namespace, Name: scope.Cluster.Name + "-token"}, tokenSecret); err != nil {
-		scope.Logger.Error(err, "Token for already initialized RKE2 Cluster not found", "token-namespace", scope.Cluster.Namespace, "token-name", scope.Cluster.Name+"-token")
+		scope.Logger.Error(
+			err,
+			"Token for already initialized RKE2 Cluster not found", "token-namespace",
+			scope.Cluster.Namespace, "token-name",
+			scope.Cluster.Name+"-token")
+
 		return ctrl.Result{}, err
 	}
+
 	token := string(tokenSecret.Data["value"])
 
 	scope.Logger.Info("RKE2 server token found in Secret!")
 
 	if len(scope.ControlPlane.Status.AvailableServerIPs) == 0 {
 		scope.Logger.V(3).Info("No ControlPlane IP Address found for node registration")
-		return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
+
+		return ctrl.Result{RequeueAfter: DefaultRequeueAfter}, nil
 	}
 
 	configStruct, configFiles, err := rke2.GenerateJoinControlPlaneConfig(
-		rke2.RKE2ServerConfigOpts{
+		rke2.ServerConfigOpts{
 			Cluster:              *scope.Cluster,
 			Token:                token,
 			ControlPlaneEndpoint: scope.Cluster.Spec.ControlPlaneEndpoint.Host,
@@ -444,19 +510,20 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
 			Client:               r.Client,
 		},
 	)
-
 	if err != nil {
 		scope.Logger.Error(err, "unable to generate config.yaml for a Secondary Control Plane node")
+
 		return ctrl.Result{}, err
 	}
 
 	b, err := kubeyaml.Marshal(configStruct)
 
 	scope.Logger.Info("Showing marshalled config.yaml", "config.yaml", string(b))
-	if err != nil {
 
+	if err != nil {
 		return ctrl.Result{}, err
 	}
+
 	scope.Logger.Info("Joining Server config marshalled successfully")
 
 	initConfigFile := bootstrapv1.File{
@@ -473,11 +540,17 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
 
 	manifestFiles, err := generateFilesFromManifestConfig(ctx, r.Client, scope.ControlPlane.Spec.ManifestsConfigMapReference)
 	if err != nil {
+		manifestCm := scope.ControlPlane.Spec.ManifestsConfigMapReference.Name
+		ns := scope.ControlPlane.Spec.ManifestsConfigMapReference.Namespace
+
 		if apierrors.IsNotFound(err) {
-			scope.Logger.Error(err, "ConfigMap referenced by manifestsConfigMapReference not found!", "namespace", scope.ControlPlane.Spec.ManifestsConfigMapReference.Namespace, "name", scope.ControlPlane.Spec.ManifestsConfigMapReference.Name)
+			scope.Logger.Error(err, "Manifest ConfigMap not found!", "namespace", ns, "name", manifestCm)
+
 			return ctrl.Result{}, err
 		}
-		scope.Logger.Error(err, "Problem when getting ConfigMap referenced by manifestsConfigMapReference", "namespace", scope.ControlPlane.Spec.ManifestsConfigMapReference.Namespace, "name", scope.ControlPlane.Spec.ManifestsConfigMapReference.Name)
+
+		scope.Logger.Error(err, "Problem when getting ConfigMap referenced by manifestsConfigMapReference", "namespace", ns, "name", manifestCm)
+
 		return ctrl.Result{}, err
 	}
 
@@ -508,27 +581,38 @@ func (r *RKE2ConfigReconciler) joinControlplane(ctx context.Context, scope *Scop
 	if err := r.storeBootstrapData(ctx, scope, cloudInitData); err != nil {
 		return ctrl.Result{}, err
 	}
+
 	return ctrl.Result{}, nil
 }
 
 // joinWorker implements the part of the Reconciler which bootstraps a worker node
-// after the cluster has been initialized
+// after the cluster has been initialized.
 func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (res ctrl.Result, rerr error) {
 	tokenSecret := &corev1.Secret{}
+
 	if err := r.Client.Get(ctx, types.NamespacedName{Namespace: scope.Cluster.Namespace, Name: scope.Cluster.Name + "-token"}, tokenSecret); err != nil {
-		scope.Logger.Info("Token for already initialized RKE2 Cluster not found", "token-namespace", scope.Cluster.Namespace, "token-name", scope.Cluster.Name+"-token")
+		scope.Logger.Info(
+			"Token for already initialized RKE2 Cluster not found",
+			"token-namespace",
+			scope.Cluster.Namespace,
+			"token-name",
+			scope.Cluster.Name+"-token")
+
 		return ctrl.Result{}, err
 	}
+
 	token := string(tokenSecret.Data["value"])
+
 	scope.Logger.Info("RKE2 server token found in Secret!")
 
 	if len(scope.ControlPlane.Status.AvailableServerIPs) == 0 {
 		scope.Logger.V(3).Info("No ControlPlane IP Address found for node registration")
-		return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
+
+		return ctrl.Result{RequeueAfter: DefaultRequeueAfter}, nil
 	}
 
 	configStruct, configFiles, err := rke2.GenerateWorkerConfig(
-		rke2.RKE2AgentConfigOpts{
+		rke2.AgentConfigOpts{
 			ServerURL:              fmt.Sprintf(serverURLFormat, scope.ControlPlane.Status.AvailableServerIPs[0], registrationPort),
 			Token:                  token,
 			AgentConfig:            scope.Config.Spec.AgentConfig,
@@ -537,16 +621,18 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
 			CloudProviderName:      scope.ControlPlane.Spec.ServerConfig.CloudProviderName,
 			CloudProviderConfigMap: scope.ControlPlane.Spec.ServerConfig.CloudProviderConfigMap,
 		})
-
 	if err != nil {
 		return ctrl.Result{}, err
 	}
+
 	b, err := kubeyaml.Marshal(configStruct)
 
 	scope.Logger.V(5).Info("Showing marshalled config.yaml", "config.yaml", string(b))
+
 	if err != nil {
 		return ctrl.Result{}, err
 	}
+
 	scope.Logger.Info("Joining Worker config marshalled successfully")
 
 	wkJoinConfigFile := bootstrapv1.File{
@@ -566,16 +652,15 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
 		ntpServers = scope.Config.Spec.AgentConfig.NTP.Servers
 	}
 
-	wkInput :=
-		&cloudinit.BaseUserData{
-			PreRKE2Commands:  scope.Config.Spec.PreRKE2Commands,
-			AirGapped:        scope.Config.Spec.AgentConfig.AirGapped,
-			PostRKE2Commands: scope.Config.Spec.PostRKE2Commands,
-			ConfigFile:       wkJoinConfigFile,
-			RKE2Version:      scope.Config.Spec.AgentConfig.Version,
-			WriteFiles:       files,
-			NTPServers:       ntpServers,
-		}
+	wkInput := &cloudinit.BaseUserData{
+		PreRKE2Commands:  scope.Config.Spec.PreRKE2Commands,
+		AirGapped:        scope.Config.Spec.AgentConfig.AirGapped,
+		PostRKE2Commands: scope.Config.Spec.PostRKE2Commands,
+		ConfigFile:       wkJoinConfigFile,
+		RKE2Version:      scope.Config.Spec.AgentConfig.Version,
+		WriteFiles:       files,
+		NTPServers:       ntpServers,
+	}
 
 	cloudInitData, err := cloudinit.NewJoinWorker(wkInput)
 	if err != nil {
@@ -589,9 +674,9 @@ func (r *RKE2ConfigReconciler) joinWorker(ctx context.Context, scope *Scope) (re
 	return ctrl.Result{}, nil
 }
 
-// generateAndStoreToken generates a random token with 16 characters then stores it in a Secret in the API
+// generateAndStoreToken generates a random token with 16 characters then stores it in a Secret in the API.
 func (r *RKE2ConfigReconciler) generateAndStoreToken(ctx context.Context, scope *Scope) (string, error) {
-	token, err := bsutil.Random(16)
+	token, err := bsutil.Random(defaultTokenLength)
 	if err != nil {
 		return "", err
 	}
@@ -621,9 +706,10 @@ func (r *RKE2ConfigReconciler) generateAndStoreToken(ctx context.Context, scope
 		Type: clusterv1.ClusterSecretType,
 	}
 
-	if err := r.createOrUpdateSecretFromObject(*secret, ctx, scope.Logger, "token", *scope.Config); err != nil {
+	if err := r.createOrUpdateSecretFromObject(ctx, *secret, scope.Logger, "token", *scope.Config); err != nil {
 		return "", err
 	}
+
 	return token, nil
 }
 
@@ -653,9 +739,10 @@ func (r *RKE2ConfigReconciler) storeBootstrapData(ctx context.Context, scope *Sc
 		Type: clusterv1.ClusterSecretType,
 	}
 
-	if err := r.createOrUpdateSecretFromObject(*secret, ctx, scope.Logger, "bootstrap data", *scope.Config); err != nil {
+	if err := r.createOrUpdateSecretFromObject(ctx, *secret, scope.Logger, "bootstrap data", *scope.Config); err != nil {
 		return err
 	}
+
 	scope.Config.Status.DataSecretName = pointer.StringPtr(secret.Name)
 	scope.Config.Status.Ready = true
 	//	conditions.MarkTrue(scope.Config, bootstrapv1.DataSecretAvailableCondition)
@@ -663,20 +750,36 @@ func (r *RKE2ConfigReconciler) storeBootstrapData(ctx context.Context, scope *Sc
 }
 
 // createOrUpdateSecret tries to create the given secret in the API, if that secret exists it will update it.
-func (r *RKE2ConfigReconciler) createOrUpdateSecretFromObject(secret corev1.Secret, ctx context.Context, logger logr.Logger, secretType string, config bootstrapv1.RKE2Config) (reterr error) {
+func (r *RKE2ConfigReconciler) createOrUpdateSecretFromObject(
+	ctx context.Context,
+	secret corev1.Secret,
+	logger logr.Logger,
+	secretType string,
+	config bootstrapv1.RKE2Config,
+) (reterr error) {
 	if err := r.Client.Create(ctx, &secret); err != nil {
 		if !apierrors.IsAlreadyExists(err) {
 			return errors.Wrapf(err, "failed to create %s secret for %s: %s/%s", secretType, config.Kind, config.Name, config.Namespace)
 		}
-		logger.Info("%s secret for %s %s already exists, updating", secretType, config.Kind, config.Name)
+
+		logger.Info("Secret for already exists, updating",
+			"secret-type", secretType,
+			"secret-ref", secret.Namespace+"/"+secret.Name,
+			"RKE2Config", config.Name)
+
 		if err := r.Client.Update(ctx, &secret); err != nil {
 			return errors.Wrapf(err, "failed to update %s secret for %s: %s/%s", secretType, config.Kind, config.Namespace, config.Name)
 		}
 	}
+
 	return
 }
 
-func generateFilesFromManifestConfig(ctx context.Context, cl client.Client, manifestConfigMap corev1.ObjectReference) (files []bootstrapv1.File, err error) {
+func generateFilesFromManifestConfig(
+	ctx context.Context,
+	cl client.Client,
+	manifestConfigMap corev1.ObjectReference,
+) (files []bootstrapv1.File, err error) {
 	if (manifestConfigMap == corev1.ObjectReference{}) {
 		return []bootstrapv1.File{}, nil
 	}
@@ -695,8 +798,9 @@ func generateFilesFromManifestConfig(ctx context.Context, cl client.Client, mani
 	for filename, content := range manifestSec.Data {
 		files = append(files, bootstrapv1.File{
 			Path:    DefaultManifestDirectory + "/" + filename,
-			Content: string(content),
+			Content: content,
 		})
 	}
+
 	return
 }
diff --git a/bootstrap/main.go b/bootstrap/main.go
index 157eb53..551aca1 100644
--- a/bootstrap/main.go
+++ b/bootstrap/main.go
@@ -27,9 +27,6 @@ import (
 	// to ensure that exec-entrypoint and run can make use of them.
 	_ "k8s.io/client-go/plugin/pkg/client/auth"
 
-	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
-	"github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/internal/controllers"
-	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
 	"github.com/spf13/pflag"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/runtime"
@@ -37,11 +34,16 @@ import (
 	clientgoscheme "k8s.io/client-go/kubernetes/scheme"
 	"k8s.io/klog/v2"
 	"k8s.io/klog/v2/klogr"
-	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	ctrl "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/healthz"
-	//+kubebuilder:scaffold:imports
+
+	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
+
+	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
+	"github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/internal/controllers"
+	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
+	"github.com/rancher-sandbox/cluster-api-provider-rke2/pkg/consts"
 )
 
 var (
@@ -71,7 +73,7 @@ func init() {
 	utilruntime.Must(controlplanev1.AddToScheme(scheme))
 	utilruntime.Must(clusterv1.AddToScheme(scheme))
 	//+kubebuilder:scaffold:scheme
-}
+} //nolint:wsl
 
 // InitFlags initializes the flags.
 func InitFlags(fs *pflag.FlagSet) {
@@ -81,17 +83,17 @@ func InitFlags(fs *pflag.FlagSet) {
 	fs.BoolVar(&enableLeaderElection, "leader-elect", false,
 		"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
 
-	fs.DurationVar(&leaderElectionLeaseDuration, "leader-elect-lease-duration", 15*time.Second,
+	fs.DurationVar(&leaderElectionLeaseDuration, "leader-elect-lease-duration", consts.DefaultLeaderElectLeaseDuration,
 		"Interval at which non-leader candidates will wait to force acquire leadership (duration string)")
 
-	fs.DurationVar(&leaderElectionRenewDeadline, "leader-elect-renew-deadline", 10*time.Second,
+	fs.DurationVar(&leaderElectionRenewDeadline, "leader-elect-renew-deadline", consts.DefaultLeaderElectRenewDeadline,
 		"Duration that the leading controller manager will retry refreshing leadership before giving up (duration string)")
 
-	fs.DurationVar(&leaderElectionRetryPeriod, "leader-elect-retry-period", 2*time.Second,
+	fs.DurationVar(&leaderElectionRetryPeriod, "leader-elect-retry-period", consts.DefaultLeaderElectRetryPeriod,
 		"Duration the LeaderElector clients should wait between tries of actions (duration string)")
 
 	fs.StringVar(&watchFilterValue, "watch-filter", "",
-		fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))
+		fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel)) //nolint:lll
 
 	fs.StringVar(&profilerAddress, "profiler-address", "",
 		"Bind address to expose the pprof profiler (e.g. localhost:6060)")
@@ -99,10 +101,10 @@ func InitFlags(fs *pflag.FlagSet) {
 	fs.IntVar(&concurrencyNumber, "concurrency", 1,
 		"Number of core resources to process simultaneously")
 
-	fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute,
+	fs.DurationVar(&syncPeriod, "sync-period", consts.DefaultSyncPeriod,
 		"The minimum interval at which watched resources are reconciled (e.g. 15m)")
 
-	fs.IntVar(&webhookPort, "webhook-port", 9443, "Webhook Server port")
+	fs.IntVar(&webhookPort, "webhook-port", consts.DefaultWebhookPort, "Webhook Server port")
 
 	fs.StringVar(&webhookCertDir, "webhook-cert-dir", "/tmp/k8s-webhook-server/serving-certs/",
 		"Webhook cert dir, only used when webhook-port is specified.")
@@ -120,6 +122,7 @@ func main() {
 
 	if profilerAddress != "" {
 		klog.Infof("Profiler listening for requests at %s", profilerAddress)
+
 		go func() {
 			klog.Info(http.ListenAndServe(profilerAddress, nil))
 		}()
@@ -153,6 +156,7 @@ func main() {
 	//+kubebuilder:scaffold:builder
 
 	setupLog.Info("starting manager")
+
 	if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
 		setupLog.Error(err, "problem running manager")
 		os.Exit(1)
@@ -164,6 +168,7 @@ func setupChecks(mgr ctrl.Manager) {
 		setupLog.Error(err, "unable to set up health check")
 		os.Exit(1)
 	}
+
 	if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
 		setupLog.Error(err, "unable to set up ready check")
 		os.Exit(1)
@@ -185,6 +190,7 @@ func setupWebhooks(mgr ctrl.Manager) {
 		setupLog.Error(err, "unable to create webhook", "webhook", "Rke2Config")
 		os.Exit(1)
 	}
+
 	if err := (&bootstrapv1.RKE2ConfigTemplate{}).SetupWebhookWithManager(mgr); err != nil {
 		setupLog.Error(err, "unable to create webhook", "webhook", "Rke2ConfigTemplate")
 		os.Exit(1)
diff --git a/controlplane/api/v1alpha1/condition_consts.go b/controlplane/api/v1alpha1/condition_consts.go
index b93eab9..bd537c8 100644
--- a/controlplane/api/v1alpha1/condition_consts.go
+++ b/controlplane/api/v1alpha1/condition_consts.go
@@ -18,10 +18,10 @@ package v1alpha1
 
 import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 
-// Conditions and condition Reasons for the RKE2ControlPlane object
+// Conditions and condition Reasons for the RKE2ControlPlane object.
 
 const (
-	// MachinesReady reports an aggregate of current status of the machines controlled by the RKE2ControlPlane.
+	// MachinesReadyCondition reports an aggregate of current status of the machines controlled by the RKE2ControlPlane.
 	MachinesReadyCondition clusterv1.ConditionType = "MachinesReady"
 )
 
@@ -97,7 +97,9 @@ const (
 )
 
 const (
+	// CertificatesAvailableCondition documents the overall status of the certificates generated by the RKE2ControlPlane.
 	CertificatesAvailableCondition clusterv1.ConditionType = "CertificatesAvailable"
 
+	// CertificatesGenerationFailedReason documents a failure in generating the certificates.
 	CertificatesGenerationFailedReason string = "CertificateGenerationFailed"
 )
diff --git a/controlplane/api/v1alpha1/groupversion_info.go b/controlplane/api/v1alpha1/groupversion_info.go
index f456ffd..82f8a64 100644
--- a/controlplane/api/v1alpha1/groupversion_info.go
+++ b/controlplane/api/v1alpha1/groupversion_info.go
@@ -25,10 +25,10 @@ import (
 )
 
 var (
-	// GroupVersion is group version used to register these objects
+	// GroupVersion is group version used to register these objects.
 	GroupVersion = schema.GroupVersion{Group: "controlplane.cluster.x-k8s.io", Version: "v1alpha1"}
 
-	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
+	// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
 	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
 
 	// AddToScheme adds the types in this group-version to the given scheme.
diff --git a/controlplane/api/v1alpha1/rke2controlplane_types.go b/controlplane/api/v1alpha1/rke2controlplane_types.go
index 4b3ab0f..20e3615 100644
--- a/controlplane/api/v1alpha1/rke2controlplane_types.go
+++ b/controlplane/api/v1alpha1/rke2controlplane_types.go
@@ -17,13 +17,16 @@ limitations under the License.
 package v1alpha1
 
 import (
-	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
 	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
+
+	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
 )
 
 const (
+	// RKE2ControlPlaneFinalizer allows the controller to clean up resources on delete.
 	RKE2ControlPlaneFinalizer = "rke2.controleplane.cluster.x-k8s.io"
 
 	// RKE2ServerConfigurationAnnotation is a machine annotation that stores the json-marshalled string of RKE2Config
@@ -31,7 +34,7 @@ const (
 	RKE2ServerConfigurationAnnotation = "controlplane.cluster.x-k8s.io/rke2-server-configuration"
 )
 
-// RKE2ControlPlaneSpec defines the desired state of RKE2ControlPlane
+// RKE2ControlPlaneSpec defines the desired state of RKE2ControlPlane.
 type RKE2ControlPlaneSpec struct {
 	// RKE2AgentSpec contains the node spec for the RKE2 Control plane nodes.
 	bootstrapv1.RKE2ConfigSpec `json:",inline"`
@@ -59,6 +62,7 @@ type RKE2ControlPlaneSpec struct {
 	NodeDrainTimeout *metav1.Duration `json:"nodeDrainTimeout,omitempty"`
 }
 
+// RKE2ServerConfig specifies configuration for the agent nodes.
 type RKE2ServerConfig struct {
 	// AuditPolicySecret path to the file that defines the audit policy configuration.
 	//+optional
@@ -92,7 +96,8 @@ type RKE2ServerConfig struct {
 	//+optional
 	DisableComponents DisableComponents `json:"disableComponents,omitempty"`
 
-	// CNI describes the CNI Plugins to deploy, one of none, calico, canal, cilium; optionally with multus as the first value to enable the multus meta-plugin (default: canal).
+	// CNI describes the CNI Plugins to deploy, one of none, calico, canal, cilium;
+	// optionally with multus as the first value to enable the multus meta-plugin (default: canal).
 	// +kubebuilder:validation:Enum=none;calico;canal;cilium
 	//+optional
 	CNI CNI `json:"cni,omitempty"`
@@ -178,7 +183,7 @@ type RKE2ControlPlaneStatus struct {
 //+kubebuilder:object:root=true
 //+kubebuilder:subresource:status
 
-// RKE2ControlPlane is the Schema for the rke2controlplanes API
+// RKE2ControlPlane is the Schema for the rke2controlplanes API.
 type RKE2ControlPlane struct {
 	metav1.TypeMeta   `json:",inline"`
 	metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -189,14 +194,14 @@ type RKE2ControlPlane struct {
 
 //+kubebuilder:object:root=true
 
-// RKE2ControlPlaneList contains a list of RKE2ControlPlane
+// RKE2ControlPlaneList contains a list of RKE2ControlPlane.
 type RKE2ControlPlaneList struct {
 	metav1.TypeMeta `json:",inline"`
 	metav1.ListMeta `json:"metadata,omitempty"`
 	Items           []RKE2ControlPlane `json:"items"`
 }
 
-// EtcdConfig regroups the ETCD-specific configuration of the control plane
+// EtcdConfig regroups the ETCD-specific configuration of the control plane.
 type EtcdConfig struct {
 	// ExposeEtcdMetrics defines the policy for ETCD Metrics exposure.
 	// if value is true, ETCD metrics will be exposed
@@ -214,7 +219,8 @@ type EtcdConfig struct {
 
 // EtcdBackupConfig describes the backup configuration for ETCD.
 type EtcdBackupConfig struct {
-	// DisableAutomaticSnapshots defines the policy for ETCD snapshots. true means automatic snapshots will be scheduled, false means automatic snapshots will not be scheduled.
+	// DisableAutomaticSnapshots defines the policy for ETCD snapshots.
+	// true means automatic snapshots will be scheduled, false means automatic snapshots will not be scheduled.
 	//+optional
 	DisableAutomaticSnapshots *bool `json:"disableAutomaticSnapshots,omitempty"`
 
@@ -230,7 +236,7 @@ type EtcdBackupConfig struct {
 	//+optional
 	Retention string `json:"retention,omitempty"`
 
-	// Directory Directory to save db snapshots.
+	// Directory to save db snapshots.
 	//+optional
 	Directory string `json:"directory,omitempty"`
 
@@ -239,6 +245,7 @@ type EtcdBackupConfig struct {
 	S3 *EtcdS3 `json:"s3,omitempty"`
 }
 
+// EtcdS3 defines the S3 configuration for ETCD snapshots.
 type EtcdS3 struct {
 	// Endpoint S3 endpoint url (default: "s3.amazonaws.com").
 	Endpoint string `json:"endpoint"`
@@ -273,17 +280,17 @@ type EtcdS3 struct {
 type CNI string
 
 const (
-	// Cilium references the RKE2 CNI Plugin "cilium"
+	// Cilium references the RKE2 CNI Plugin "cilium".
 	Cilium CNI = "cilium"
-	// Calico references the RKE2 CNI Plugin "calico"
+	// Calico references the RKE2 CNI Plugin "calico".
 	Calico CNI = "calico"
-	// Canal references the RKE2 CNI Plugin "canal"
+	// Canal references the RKE2 CNI Plugin "canal".
 	Canal CNI = "canal"
 	// None means that no CNI Plugin will be installed with RKE2, letting the operator install his own CNI afterwards.
 	None CNI = "none"
 )
 
-// DisableComponents describes components of RKE2 (Kubernetes components and plugin components) that should be disabled
+// DisableComponents describes components of RKE2 (Kubernetes components and plugin components) that should be disabled.
 type DisableComponents struct {
 	// KubernetesComponents is a list of Kubernetes components to disable.
 	// +kubebuilder:validation:Enum=scheduler;kubeProxy;cloudController
@@ -298,36 +305,38 @@ type DisableComponents struct {
 type DisabledKubernetesComponent string
 
 const (
-	// Scheduler references the Kube Scheduler Kubernetes components of the control plane/server nodes
+	// Scheduler references the Kube Scheduler Kubernetes components of the control plane/server nodes.
 	Scheduler DisabledKubernetesComponent = "scheduler"
 
-	// KubeProxy references the Kube Proxy Kubernetes components on the agents
+	// KubeProxy references the Kube Proxy Kubernetes components on the agents.
 	KubeProxy DisabledKubernetesComponent = "kubeProxy"
 
-	// CloudController references the Cloud Controller Manager Kubernetes Components on the control plane / server nodes
+	// CloudController references the Cloud Controller Manager Kubernetes Components on the control plane / server nodes.
 	CloudController DisabledKubernetesComponent = "cloudController"
 )
 
-// DisabledItem selects a plugin Components to be disabled.
+// DisabledPluginComponent selects a plugin Components to be disabled.
 type DisabledPluginComponent string
 
 const (
-	// CoreDNS references the RKE2 Plugin "rke2-coredns"
+	// CoreDNS references the RKE2 Plugin "rke2-coredns".
 	CoreDNS DisabledPluginComponent = "rke2-coredns"
-	// IngressNginx references the RKE2 Plugin "rke2-ingress-nginx"
+	// IngressNginx references the RKE2 Plugin "rke2-ingress-nginx".
 	IngressNginx DisabledPluginComponent = "rke2-ingress-nginx"
-	// MetricsServer references the RKE2 Plugin "rke2-metrics-server"
+	// MetricsServer references the RKE2 Plugin "rke2-metrics-server".
 	MetricsServer DisabledPluginComponent = "rke2-metrics-server"
 )
 
-func init() {
+func init() { //nolint:gochecknoinits
 	SchemeBuilder.Register(&RKE2ControlPlane{}, &RKE2ControlPlaneList{})
 }
 
-func (c *RKE2ControlPlane) GetConditions() clusterv1.Conditions {
-	return c.Status.Conditions
+// GetConditions returns the list of conditions for a RKE2ControlPlane object.
+func (r *RKE2ControlPlane) GetConditions() clusterv1.Conditions {
+	return r.Status.Conditions
 }
 
-func (c *RKE2ControlPlane) SetConditions(conditions clusterv1.Conditions) {
-	c.Status.Conditions = conditions
+// SetConditions sets the list of conditions for a RKE2ControlPlane object.
+func (r *RKE2ControlPlane) SetConditions(conditions clusterv1.Conditions) {
+	r.Status.Conditions = conditions
 }
diff --git a/controlplane/api/v1alpha1/rke2controlplane_webhook.go b/controlplane/api/v1alpha1/rke2controlplane_webhook.go
index 2fac13c..42af13f 100644
--- a/controlplane/api/v1alpha1/rke2controlplane_webhook.go
+++ b/controlplane/api/v1alpha1/rke2controlplane_webhook.go
@@ -26,6 +26,7 @@ import (
 // log is for logging in this package.
 var rke2controlplanelog = logf.Log.WithName("rke2controlplane-resource")
 
+// SetupWebhookWithManager sets up the Controller Manager for the Webhook for the RKE2ControlPlane resource.
 func (r *RKE2ControlPlane) SetupWebhookWithManager(mgr ctrl.Manager) error {
 	return ctrl.NewWebhookManagedBy(mgr).
 		For(r).
@@ -36,30 +37,30 @@ func (r *RKE2ControlPlane) SetupWebhookWithManager(mgr ctrl.Manager) error {
 
 var _ webhook.Defaulter = &RKE2ControlPlane{}
 
-// Default implements webhook.Defaulter so a webhook will be registered for the type
+// Default implements webhook.Defaulter so a webhook will be registered for the type.
 func (r *RKE2ControlPlane) Default() {
 	rke2controlplanelog.Info("default", "name", r.Name)
-
 }
 
 //+kubebuilder:webhook:path=/validate-controlplane-cluster-x-k8s-io-v1alpha1-rke2controlplane,mutating=false,failurePolicy=fail,sideEffects=None,groups=controlplane.cluster.x-k8s.io,resources=rke2controlplanes,verbs=create;update,versions=v1alpha1,name=vrke2controlplane.kb.io,admissionReviewVersions=v1
 
 var _ webhook.Validator = &RKE2ControlPlane{}
 
-// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
+// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ControlPlane) ValidateCreate() error {
 	rke2controlplanelog.Info("validate create", "name", r.Name)
+
 	return nil
 }
 
-// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
+// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ControlPlane) ValidateUpdate(old runtime.Object) error {
 	rke2controlplanelog.Info("validate update", "name", r.Name)
 
 	return nil
 }
 
-// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
+// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ControlPlane) ValidateDelete() error {
 	rke2controlplanelog.Info("validate delete", "name", r.Name)
 
diff --git a/controlplane/api/v1alpha1/rke2controlplanetemplate_types.go b/controlplane/api/v1alpha1/rke2controlplanetemplate_types.go
index 5d45b52..968a971 100644
--- a/controlplane/api/v1alpha1/rke2controlplanetemplate_types.go
+++ b/controlplane/api/v1alpha1/rke2controlplanetemplate_types.go
@@ -23,7 +23,7 @@ import (
 // EDIT THIS FILE!  THIS IS SCAFFOLDING FOR YOU TO OWN!
 // NOTE: json tags are required.  Any new fields you add must have json tags for the fields to be serialized.
 
-// RKE2ControlPlaneTemplateSpec defines the desired state of RKE2ControlPlaneTemplate
+// RKE2ControlPlaneTemplateSpec defines the desired state of RKE2ControlPlaneTemplate.
 type RKE2ControlPlaneTemplateSpec struct {
 	// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
 	// Important: Run "make" to regenerate code after modifying this file
@@ -32,7 +32,7 @@ type RKE2ControlPlaneTemplateSpec struct {
 	Foo string `json:"foo,omitempty"`
 }
 
-// RKE2ControlPlaneTemplateStatus defines the observed state of RKE2ControlPlaneTemplate
+// RKE2ControlPlaneTemplateStatus defines the observed state of RKE2ControlPlaneTemplate.
 type RKE2ControlPlaneTemplateStatus struct {
 	// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
 	// Important: Run "make" to regenerate code after modifying this file
@@ -41,7 +41,7 @@ type RKE2ControlPlaneTemplateStatus struct {
 //+kubebuilder:object:root=true
 //+kubebuilder:subresource:status
 
-// RKE2ControlPlaneTemplate is the Schema for the rke2controlplanetemplates API
+// RKE2ControlPlaneTemplate is the Schema for the rke2controlplanetemplates API.
 type RKE2ControlPlaneTemplate struct {
 	metav1.TypeMeta   `json:",inline"`
 	metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -52,13 +52,13 @@ type RKE2ControlPlaneTemplate struct {
 
 //+kubebuilder:object:root=true
 
-// RKE2ControlPlaneTemplateList contains a list of RKE2ControlPlaneTemplate
+// RKE2ControlPlaneTemplateList contains a list of RKE2ControlPlaneTemplate.
 type RKE2ControlPlaneTemplateList struct {
 	metav1.TypeMeta `json:",inline"`
 	metav1.ListMeta `json:"metadata,omitempty"`
 	Items           []RKE2ControlPlaneTemplate `json:"items"`
 }
 
-func init() {
+func init() { //nolint:gochecknoinits
 	SchemeBuilder.Register(&RKE2ControlPlaneTemplate{}, &RKE2ControlPlaneTemplateList{})
 }
diff --git a/controlplane/api/v1alpha1/rke2controlplanetemplate_webhook.go b/controlplane/api/v1alpha1/rke2controlplanetemplate_webhook.go
index 985dd98..365f415 100644
--- a/controlplane/api/v1alpha1/rke2controlplanetemplate_webhook.go
+++ b/controlplane/api/v1alpha1/rke2controlplanetemplate_webhook.go
@@ -26,6 +26,7 @@ import (
 // log is for logging in this package.
 var rke2controlplanetemplatelog = logf.Log.WithName("rke2controlplanetemplate-resource")
 
+// SetupWebhookWithManager sets up the Controller Manager for the Webhook for the RKE2ControlPlaneTemplate resource.
 func (r *RKE2ControlPlaneTemplate) SetupWebhookWithManager(mgr ctrl.Manager) error {
 	return ctrl.NewWebhookManagedBy(mgr).
 		For(r).
@@ -36,31 +37,30 @@ func (r *RKE2ControlPlaneTemplate) SetupWebhookWithManager(mgr ctrl.Manager) err
 
 var _ webhook.Defaulter = &RKE2ControlPlaneTemplate{}
 
-// Default implements webhook.Defaulter so a webhook will be registered for the type
+// Default implements webhook.Defaulter so a webhook will be registered for the type.
 func (r *RKE2ControlPlaneTemplate) Default() {
 	rke2controlplanetemplatelog.Info("default", "name", r.Name)
-
 }
 
 //+kubebuilder:webhook:path=/validate-controlplane-cluster-x-k8s-io-v1alpha1-rke2controlplanetemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=controlplane.cluster.x-k8s.io,resources=rke2controlplanetemplates,verbs=create;update,versions=v1alpha1,name=vrke2controlplanetemplate.kb.io,admissionReviewVersions=v1
 
 var _ webhook.Validator = &RKE2ControlPlaneTemplate{}
 
-// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
+// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ControlPlaneTemplate) ValidateCreate() error {
 	rke2controlplanetemplatelog.Info("validate create", "name", r.Name)
 
 	return nil
 }
 
-// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
+// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ControlPlaneTemplate) ValidateUpdate(old runtime.Object) error {
 	rke2controlplanetemplatelog.Info("validate update", "name", r.Name)
 
 	return nil
 }
 
-// ValidateDelete implements webhook.Validator so a webhook will be registered for the type
+// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
 func (r *RKE2ControlPlaneTemplate) ValidateDelete() error {
 	rke2controlplanetemplatelog.Info("validate delete", "name", r.Name)
 
diff --git a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanes.yaml b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanes.yaml
index 97d5399..2dc92b9 100644
--- a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanes.yaml
+++ b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanes.yaml
@@ -18,7 +18,7 @@ spec:
   - name: v1alpha1
     schema:
       openAPIV3Schema:
-        description: RKE2ControlPlane is the Schema for the rke2controlplanes API
+        description: RKE2ControlPlane is the Schema for the rke2controlplanes API.
         properties:
           apiVersion:
             description: 'APIVersion defines the versioned schema of this representation
@@ -33,7 +33,7 @@ spec:
           metadata:
             type: object
           spec:
-            description: RKE2ControlPlaneSpec defines the desired state of RKE2ControlPlane
+            description: RKE2ControlPlaneSpec defines the desired state of RKE2ControlPlane.
             properties:
               agentConfig:
                 description: AgentConfig specifies configuration for the agent nodes.
@@ -266,8 +266,8 @@ spec:
                         populate the file.
                       properties:
                         secret:
-                          description: Secret represents a secret that should populate
-                            this file.
+                          description: SecretFileSource represents a secret that should
+                            populate this file.
                           properties:
                             key:
                               description: Key is the key in the secret's data map
@@ -706,8 +706,8 @@ spec:
                         - rke2-ingress-nginx
                         - rke2-metrics-server
                         items:
-                          description: DisabledItem selects a plugin Components to
-                            be disabled.
+                          description: DisabledPluginComponent selects a plugin Components
+                            to be disabled.
                           type: string
                         type: array
                     type: object
@@ -719,7 +719,7 @@ spec:
                           ETCD: target storage, schedule, etc.'
                         properties:
                           directory:
-                            description: Directory Directory to save db snapshots.
+                            description: Directory to save db snapshots.
                             type: string
                           disableAutomaticSnapshots:
                             description: DisableAutomaticSnapshots defines the policy
diff --git a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanetemplates.yaml b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanetemplates.yaml
index f59f807..e50d67d 100644
--- a/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanetemplates.yaml
+++ b/controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanetemplates.yaml
@@ -19,7 +19,7 @@ spec:
     schema:
       openAPIV3Schema:
         description: RKE2ControlPlaneTemplate is the Schema for the rke2controlplanetemplates
-          API
+          API.
         properties:
           apiVersion:
             description: 'APIVersion defines the versioned schema of this representation
@@ -35,7 +35,7 @@ spec:
             type: object
           spec:
             description: RKE2ControlPlaneTemplateSpec defines the desired state of
-              RKE2ControlPlaneTemplate
+              RKE2ControlPlaneTemplate.
             properties:
               foo:
                 description: Foo is an example field of RKE2ControlPlaneTemplate.
@@ -44,7 +44,7 @@ spec:
             type: object
           status:
             description: RKE2ControlPlaneTemplateStatus defines the observed state
-              of RKE2ControlPlaneTemplate
+              of RKE2ControlPlaneTemplate.
             type: object
         type: object
     served: true
diff --git a/controlplane/internal/controllers/const.go b/controlplane/internal/controllers/const.go
index c29307b..3662c12 100644
--- a/controlplane/internal/controllers/const.go
+++ b/controlplane/internal/controllers/const.go
@@ -24,6 +24,6 @@ const (
 	deleteRequeueAfter = 30 * time.Second
 
 	// preflightFailedRequeueAfter is how long to wait before trying to scale
-	// up/down if some preflight check for those operation has failed
+	// up/down if some preflight check for those operation has failed.
 	preflightFailedRequeueAfter = 15 * time.Second
 )
diff --git a/controlplane/internal/controllers/rke2controlplane_controller.go b/controlplane/internal/controllers/rke2controlplane_controller.go
index a05fa2b..f86a1d0 100644
--- a/controlplane/internal/controllers/rke2controlplane_controller.go
+++ b/controlplane/internal/controllers/rke2controlplane_controller.go
@@ -55,9 +55,12 @@ const (
 	// dependentCertRequeueAfter is how long to wait before checking again to see if
 	// dependent certificates have been created.
 	dependentCertRequeueAfter = 30 * time.Second
+
+	// DefaultRequeueTime is the default requeue time for the controller.
+	DefaultRequeueTime = 20 * time.Second
 )
 
-// RKE2ControlPlaneReconciler reconciles a RKE2ControlPlane object
+// RKE2ControlPlaneReconciler reconciles a RKE2ControlPlane object.
 type RKE2ControlPlaneReconciler struct {
 	Log logr.Logger
 	client.Client
@@ -68,6 +71,7 @@ type RKE2ControlPlaneReconciler struct {
 	controller                controller.Controller
 }
 
+//nolint:lll
 //+kubebuilder:rbac:groups=controlplane.cluster.x-k8s.io,resources=rke2controlplanes,verbs=get;list;watch;create;update;patch;delete
 //+kubebuilder:rbac:groups=controlplane.cluster.x-k8s.io,resources=rke2controlplanes/status,verbs=get;update;patch
 //+kubebuilder:rbac:groups=controlplane.cluster.x-k8s.io,resources=rke2controlplanes/finalizers,verbs=update
@@ -78,21 +82,16 @@ type RKE2ControlPlaneReconciler struct {
 
 // Reconcile is part of the main kubernetes reconciliation loop which aims to
 // move the current state of the cluster closer to the desired state.
-// TODO(user): Modify the Reconcile function to compare the state specified by
-// the RKE2ControlPlane object against the actual cluster state, and then
-// perform operations to make the cluster state reflect the state specified by
-// the user.
-//
-// For more details, check Reconcile and its Result here:
-// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.12.2/pkg/reconcile
 func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, reterr error) {
 	logger := log.FromContext(ctx)
 	r.Log = logger
 	rcp := &controlplanev1.RKE2ControlPlane{}
+
 	if err := r.Get(ctx, req.NamespacedName, rcp); err != nil {
 		if apierrors.IsNotFound(err) {
 			return ctrl.Result{}, err
 		}
+
 		return ctrl.Result{Requeue: true}, err
 	}
 
@@ -100,10 +99,13 @@ func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
 	cluster, err := util.GetOwnerCluster(ctx, r.Client, rcp.ObjectMeta)
 	if err != nil {
 		logger.Error(err, "Failed to retrieve owner Cluster from the API Server")
+
 		return ctrl.Result{}, err
 	}
+
 	if cluster == nil {
 		logger.Info("Cluster Controller has not yet set OwnerRef")
+
 		return ctrl.Result{Requeue: true}, nil
 	}
 
@@ -111,6 +113,7 @@ func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
 
 	if annotations.IsPaused(cluster, rcp) {
 		logger.Info("Reconciliation is paused for this object")
+
 		return ctrl.Result{}, nil
 	}
 
@@ -118,6 +121,7 @@ func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
 	patchHelper, err := patch.NewHelper(rcp, r.Client)
 	if err != nil {
 		logger.Error(err, "Failed to configure the patch helper")
+
 		return ctrl.Result{Requeue: true}, nil
 	}
 
@@ -131,6 +135,7 @@ func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
 		patchOpts := []patch.Option{patch.WithStatusObservedGeneration{}}
 		if err := patchHelper.Patch(ctx, rcp, patchOpts...); err != nil {
 			logger.Error(err, "Failed to patch RKE2ControlPlane to add finalizer")
+
 			return ctrl.Result{}, err
 		}
 
@@ -155,12 +160,13 @@ func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
 			reterr = kerrors.NewAggregate([]error{reterr, err})
 		}
 
-		// TODO: remove this as soon as we have a proper remote cluster cache in place.
-		// Make rcp to requeue in case status is not ready, so we can check for node status without waiting for a full resync (by default 10 minutes).
-		// Only requeue if we are not going in exponential backoff due to error, or if we are not already re-queueing, or if the object has a deletion timestamp.
+		// Make rcp to requeue in case status is not ready, so we can check for node
+		// status without waiting for a full resync (by default 10 minutes).
+		// Only requeue if we are not going in exponential backoff due to error,
+		// or if we are not already re-queueing, or if the object has a deletion timestamp.
 		if reterr == nil && !res.Requeue && res.RequeueAfter <= 0 && rcp.ObjectMeta.DeletionTimestamp.IsZero() {
 			if !rcp.Status.Ready {
-				res = ctrl.Result{RequeueAfter: 20 * time.Second}
+				res = ctrl.Result{RequeueAfter: DefaultRequeueTime}
 			}
 		}
 	}()
@@ -168,11 +174,13 @@ func (r *RKE2ControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.Req
 	if !rcp.ObjectMeta.DeletionTimestamp.IsZero() {
 		// Handle deletion reconciliation loop.
 		res, err = r.reconcileDelete(ctx, cluster, rcp)
+
 		return res, err
 	}
 
 	// Handle normal reconciliation loop.
 	res, err = r.reconcileNormal(ctx, cluster, rcp)
+
 	return res, err
 }
 
@@ -206,10 +214,8 @@ func patchRKE2ControlPlane(ctx context.Context, patchHelper *patch.Helper, rcp *
 
 // SetupWithManager sets up the controller with the Manager.
 func (r *RKE2ControlPlaneReconciler) SetupWithManager(mgr ctrl.Manager) error {
-
 	c, err := ctrl.NewControllerManagedBy(mgr).
 		For(&controlplanev1.RKE2ControlPlane{}).
-		//Owns(&clusterv1.Machine{}).
 		Build(r)
 	if err != nil {
 		return errors.Wrap(err, "failed setting up with a controller manager")
@@ -218,28 +224,32 @@ func (r *RKE2ControlPlaneReconciler) SetupWithManager(mgr ctrl.Manager) error {
 	err = c.Watch(
 		&source.Kind{Type: &clusterv1.Cluster{}},
 		handler.EnqueueRequestsFromMapFunc(r.ClusterToRKE2ControlPlane),
-		//predicates.ClusterUnpausedAndInfrastructureReady(r.Log),
 	)
 	if err != nil {
 		return errors.Wrap(err, "failed adding Watch for Clusters to controller manager")
 	}
-	//r.Scheme = mgr.GetScheme()
+
 	r.controller = c
 	r.recorder = mgr.GetEventRecorderFor("rke2-control-plane-controller")
 
 	if r.managementCluster == nil {
 		r.managementCluster = &rke2.Management{Client: r.Client}
 	}
+
 	if r.managementClusterUncached == nil {
 		r.managementClusterUncached = &rke2.Management{Client: mgr.GetAPIReader()}
 	}
+
 	return nil
 }
 
 func (r *RKE2ControlPlaneReconciler) updateStatus(ctx context.Context, rcp *controlplanev1.RKE2ControlPlane, cluster *clusterv1.Cluster) error {
-
 	logger := log.FromContext(ctx)
-	ownedMachines, err := r.managementCluster.GetMachinesForCluster(ctx, util.ObjectKey(cluster), collections.OwnedMachines(rcp))
+
+	ownedMachines, err := r.managementCluster.GetMachinesForCluster(
+		ctx,
+		util.ObjectKey(cluster),
+		collections.OwnedMachines(rcp))
 	if err != nil {
 		return errors.Wrap(err, "failed to get list of owned machines")
 	}
@@ -252,10 +262,11 @@ func (r *RKE2ControlPlaneReconciler) updateStatus(ctx context.Context, rcp *cont
 	controlPlane, err := rke2.NewControlPlane(ctx, r.Client, cluster, rcp, ownedMachines)
 	if err != nil {
 		logger.Error(err, "failed to initialize control plane")
+
 		return err
 	}
-	rcp.Status.UpdatedReplicas = int32(len(controlPlane.UpToDateMachines()))
 
+	rcp.Status.UpdatedReplicas = int32(len(controlPlane.UpToDateMachines()))
 	replicas := int32(len(ownedMachines))
 	desiredReplicas := *rcp.Spec.Replicas
 
@@ -274,10 +285,26 @@ func (r *RKE2ControlPlaneReconciler) updateStatus(ctx context.Context, rcp *cont
 	switch {
 	// We are scaling up
 	case replicas < desiredReplicas:
-		conditions.MarkFalse(rcp, controlplanev1.ResizedCondition, controlplanev1.ScalingUpReason, clusterv1.ConditionSeverityWarning, "Scaling up control plane to %d replicas (actual %d)", desiredReplicas, replicas)
+		conditions.MarkFalse(
+			rcp,
+			controlplanev1.ResizedCondition,
+			controlplanev1.ScalingUpReason,
+			clusterv1.ConditionSeverityWarning,
+			"Scaling up control plane to %d replicas (actual %d)",
+			desiredReplicas,
+			replicas)
+
 	// We are scaling down
 	case replicas > desiredReplicas:
-		conditions.MarkFalse(rcp, controlplanev1.ResizedCondition, controlplanev1.ScalingDownReason, clusterv1.ConditionSeverityWarning, "Scaling down control plane to %d replicas (actual %d)", desiredReplicas, replicas)
+		conditions.MarkFalse(
+			rcp,
+			controlplanev1.ResizedCondition,
+			controlplanev1.ScalingDownReason,
+			clusterv1.ConditionSeverityWarning,
+			"Scaling down control plane to %d replicas (actual %d)",
+			desiredReplicas,
+			replicas)
+
 	default:
 		// make sure last resize operation is marked as completed.
 		// NOTE: we are checking the number of machines ready so we report resize completed only when the machines
@@ -286,13 +313,16 @@ func (r *RKE2ControlPlaneReconciler) updateStatus(ctx context.Context, rcp *cont
 			conditions.MarkTrue(rcp, controlplanev1.ResizedCondition)
 		}
 	}
+
 	kubeconfigSecret := corev1.Secret{}
 	err = r.Client.Get(ctx, types.NamespacedName{
 		Namespace: cluster.Namespace,
 		Name:      secret.Name(cluster.Name, secret.Kubeconfig),
 	}, &kubeconfigSecret)
+
 	if err != nil {
 		r.Log.Info("Kubeconfig secret does not yet exist")
+
 		return err
 	}
 
@@ -301,8 +331,6 @@ func (r *RKE2ControlPlaneReconciler) updateStatus(ctx context.Context, rcp *cont
 		return fmt.Errorf("unable to find a value entry in the kubeconfig secret")
 	}
 
-	// TODO: Improve this to potentially check kubeconfig validity or even test connectivity to workloadCluster
-	//rcp.Status.ReadyReplicas = status.ReadyNodes
 	rcp.Status.ReadyReplicas = int32(len(readyMachines))
 	rcp.Status.UnavailableReplicas = replicas - rcp.Status.ReadyReplicas
 
@@ -310,18 +338,29 @@ func (r *RKE2ControlPlaneReconciler) updateStatus(ctx context.Context, rcp *cont
 		rcp.Status.Initialized = true
 	}
 
+	if len(ownedMachines) == 0 {
+		return fmt.Errorf("no Control Plane Machines exist for RKE2ControlPlane %s/%s", rcp.Namespace, rcp.Name)
+	}
+
+	if len(readyMachines) == 0 {
+		return fmt.Errorf("no Control Plane Machines are ready for RKE2ControlPlane %s/%s", rcp.Namespace, rcp.Name)
+	}
+
 	availableCPMachines := readyMachines.Filter(collections.Not(collections.HasUnhealthyCondition))
-	validIpAddresses := []string{}
+	validIPAddresses := []string{}
+
 	for _, machine := range availableCPMachines {
 		ipAddress, err := getIPAddress(*machine)
 		if err != nil {
 			break
 		}
+
 		if !conditions.IsFalse(machine, clusterv1.MachineNodeHealthyCondition) {
-			validIpAddresses = append(validIpAddresses, ipAddress)
+			validIPAddresses = append(validIPAddresses, ipAddress)
 		}
 	}
-	rcp.Status.AvailableServerIPs = validIpAddresses
+
+	rcp.Status.AvailableServerIPs = validIPAddresses
 	if len(rcp.Status.AvailableServerIPs) == 0 {
 		return fmt.Errorf("some Control Plane machines exist and are ready but they have no IP Address available")
 	}
@@ -331,77 +370,111 @@ func (r *RKE2ControlPlaneReconciler) updateStatus(ctx context.Context, rcp *cont
 	}
 
 	conditions.MarkTrue(rcp, controlplanev1.AvailableCondition)
+
 	return nil
 }
 
-func (r *RKE2ControlPlaneReconciler) reconcileNormal(ctx context.Context, cluster *clusterv1.Cluster, rcp *controlplanev1.RKE2ControlPlane) (ctrl.Result, error) {
+func (r *RKE2ControlPlaneReconciler) reconcileNormal(
+	ctx context.Context,
+	cluster *clusterv1.Cluster,
+	rcp *controlplanev1.RKE2ControlPlane,
+) (ctrl.Result, error) {
 	logger := log.FromContext(ctx)
 	logger.Info("Reconcile RKE2 Control Plane")
 
 	// Wait for the cluster infrastructure to be ready before creating machines
 	if !cluster.Status.InfrastructureReady {
 		logger.Info("Cluster infrastructure is not ready yet")
+
 		return ctrl.Result{}, nil
 	}
 
 	certificates := secret.NewCertificatesForInitialControlPlane()
 	controllerRef := metav1.NewControllerRef(rcp, controlplanev1.GroupVersion.WithKind("RKE2ControlPlane"))
+
 	if err := certificates.LookupOrGenerate(ctx, r.Client, util.ObjectKey(cluster), *controllerRef); err != nil {
 		logger.Error(err, "unable to lookup or create cluster certificates")
-		conditions.MarkFalse(rcp, controlplanev1.CertificatesAvailableCondition, controlplanev1.CertificatesGenerationFailedReason, clusterv1.ConditionSeverityWarning, err.Error())
+		conditions.MarkFalse(
+			rcp, controlplanev1.CertificatesAvailableCondition,
+			controlplanev1.CertificatesGenerationFailedReason,
+			clusterv1.ConditionSeverityWarning, err.Error())
+
 		return ctrl.Result{}, err
 	}
+
 	conditions.MarkTrue(rcp, controlplanev1.CertificatesAvailableCondition)
 
 	// If ControlPlaneEndpoint is not set, return early
 	if !cluster.Spec.ControlPlaneEndpoint.IsValid() {
 		logger.Info("Cluster does not yet have a ControlPlaneEndpoint defined")
+
 		return ctrl.Result{}, nil
 	}
 
 	// Generate Cluster Kubeconfig if needed
-	if result, err := r.reconcileKubeconfig(ctx, util.ObjectKey(cluster), cluster.Spec.ControlPlaneEndpoint, rcp); err != nil {
+	if result, err := r.reconcileKubeconfig(
+		ctx,
+		util.ObjectKey(cluster),
+		cluster.Spec.ControlPlaneEndpoint,
+		rcp); err != nil {
 		logger.Error(err, "failed to reconcile Kubeconfig")
+
 		return result, err
 	}
 
-	controlPlaneMachines, err := r.managementClusterUncached.GetMachinesForCluster(ctx, util.ObjectKey(cluster), collections.ControlPlaneMachines(cluster.Name))
+	controlPlaneMachines, err := r.managementClusterUncached.GetMachinesForCluster(
+		ctx,
+		util.ObjectKey(cluster),
+		collections.ControlPlaneMachines(cluster.Name))
 	if err != nil {
 		logger.Error(err, "failed to retrieve control plane machines for cluster")
+
 		return ctrl.Result{}, err
 	}
 
-	logger.V(5).Info("Checking on Reconciler 2")
-
 	ownedMachines := controlPlaneMachines.Filter(collections.OwnedMachines(rcp))
 	if len(ownedMachines) != len(controlPlaneMachines) {
-		logger.Info("Not all control plane machines are owned by this RKE2ControlPlane, refusing to operate in mixed management mode")
+		logger.Info("Not all control plane machines are owned by this RKE2ControlPlane, refusing to operate in mixed management mode") //nolint:lll
+
 		return ctrl.Result{}, nil
 	}
 
 	controlPlane, err := rke2.NewControlPlane(ctx, r.Client, cluster, rcp, ownedMachines)
 	if err != nil {
 		logger.Error(err, "failed to initialize control plane")
+
 		return ctrl.Result{}, err
 	}
 
 	// Aggregate the operational state of all the machines; while aggregating we are adding the
 	// source ref (reason@machine/name) so the problem can be easily tracked down to its source machine.
-	conditions.SetAggregate(controlPlane.RCP, controlplanev1.MachinesReadyCondition, ownedMachines.ConditionGetters(), conditions.AddSourceRef(), conditions.WithStepCounterIf(false))
+	conditions.SetAggregate(controlPlane.RCP, controlplanev1.MachinesReadyCondition,
+		ownedMachines.ConditionGetters(),
+		conditions.AddSourceRef(),
+		conditions.WithStepCounterIf(false))
 
 	// Updates conditions reporting the status of static pods and the status of the etcd cluster.
 	// NOTE: Conditions reporting RCP operation progress like e.g. Resized or SpecUpToDate are inlined with the rest of the execution.
 	if result, err := r.reconcileControlPlaneConditions(ctx, controlPlane); err != nil || !result.IsZero() {
 		logger.Error(err, "failed to reconcile Control Plane conditions")
+
 		return result, err
 	}
 
 	// Control plane machines rollout due to configuration changes (e.g. upgrades) takes precedence over other operations.
 	needRollout := controlPlane.MachinesNeedingRollout()
+
 	switch {
 	case len(needRollout) > 0:
 		logger.Info("Rolling out Control Plane machines", "needRollout", needRollout.Names())
-		conditions.MarkFalse(controlPlane.RCP, controlplanev1.MachinesSpecUpToDateCondition, controlplanev1.RollingUpdateInProgressReason, clusterv1.ConditionSeverityWarning, "Rolling %d replicas with outdated spec (%d replicas up to date)", len(needRollout), len(controlPlane.Machines)-len(needRollout))
+		conditions.MarkFalse(controlPlane.RCP,
+			controlplanev1.MachinesSpecUpToDateCondition,
+			controlplanev1.RollingUpdateInProgressReason,
+			clusterv1.ConditionSeverityWarning,
+			"Rolling %d replicas with outdated spec (%d replicas up to date)",
+			len(needRollout),
+			len(controlPlane.Machines)-len(needRollout))
+
 		return r.upgradeControlPlane(ctx, cluster, rcp, controlPlane, needRollout)
 	default:
 		// make sure last upgrade operation is marked as completed.
@@ -421,13 +494,19 @@ func (r *RKE2ControlPlaneReconciler) reconcileNormal(ctx context.Context, cluste
 	case numMachines < desiredReplicas && numMachines == 0:
 		// Create new Machine w/ init
 		logger.Info("Initializing control plane", "Desired", desiredReplicas, "Existing", numMachines)
-		conditions.MarkFalse(controlPlane.RCP, controlplanev1.AvailableCondition, controlplanev1.WaitingForRKE2ServerReason, clusterv1.ConditionSeverityInfo, "")
+		conditions.MarkFalse(controlPlane.RCP,
+			controlplanev1.AvailableCondition,
+			controlplanev1.WaitingForRKE2ServerReason,
+			clusterv1.ConditionSeverityInfo, "")
+
 		return r.initializeControlPlane(ctx, cluster, rcp, controlPlane)
 	// We are scaling up
 	case numMachines < desiredReplicas && numMachines > 0:
 		// Create a new Machine w/ join
 		logger.Info("Scaling up control plane", "Desired", desiredReplicas, "Existing", numMachines)
+
 		return r.scaleUpControlPlane(ctx, cluster, rcp, controlPlane)
+
 	// We are scaling down
 	case numMachines > desiredReplicas:
 		logger.Info("Scaling down control plane", "Desired", desiredReplicas, "Existing", numMachines)
@@ -438,7 +517,10 @@ func (r *RKE2ControlPlaneReconciler) reconcileNormal(ctx context.Context, cluste
 	return ctrl.Result{}, nil
 }
 
-func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context, cluster *clusterv1.Cluster, rcp *controlplanev1.RKE2ControlPlane) (res ctrl.Result, err error) {
+func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context,
+	cluster *clusterv1.Cluster,
+	rcp *controlplanev1.RKE2ControlPlane,
+) (res ctrl.Result, err error) {
 	logger := log.FromContext(ctx)
 
 	// Gets all machines, not just control plane machines.
@@ -446,17 +528,20 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context, cluste
 	if err != nil {
 		return ctrl.Result{}, err
 	}
+
 	ownedMachines := allMachines.Filter(collections.OwnedMachines(rcp))
 
 	// If no control plane machines remain, remove the finalizer
 	if len(ownedMachines) == 0 {
 		controllerutil.RemoveFinalizer(rcp, controlplanev1.RKE2ControlPlaneFinalizer)
+
 		return ctrl.Result{}, nil
 	}
 
 	controlPlane, err := rke2.NewControlPlane(ctx, r.Client, cluster, rcp, ownedMachines)
 	if err != nil {
 		logger.Error(err, "failed to initialize control plane")
+
 		return ctrl.Result{}, err
 	}
 
@@ -470,52 +555,68 @@ func (r *RKE2ControlPlaneReconciler) reconcileDelete(ctx context.Context, cluste
 	// source ref (reason@machine/name) so the problem can be easily tracked down to its source machine.
 	// However, during delete we are hiding the counter (1 of x) because it does not make sense given that
 	// all the machines are deleted in parallel.
-	conditions.SetAggregate(rcp, controlplanev1.MachinesReadyCondition, ownedMachines.ConditionGetters(), conditions.AddSourceRef(), conditions.WithStepCounterIf(false))
+	conditions.SetAggregate(rcp,
+		controlplanev1.MachinesReadyCondition,
+		ownedMachines.ConditionGetters(),
+		conditions.AddSourceRef(),
+		conditions.WithStepCounterIf(false))
 
 	// Verify that only control plane machines remain
 	if len(allMachines) != len(ownedMachines) {
 		logger.Info("Waiting for worker nodes to be deleted first")
-		conditions.MarkFalse(rcp, controlplanev1.ResizedCondition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "Waiting for worker nodes to be deleted first")
+		conditions.MarkFalse(rcp,
+			controlplanev1.ResizedCondition,
+			clusterv1.DeletingReason,
+			clusterv1.ConditionSeverityInfo,
+			"Waiting for worker nodes to be deleted first")
+
 		return ctrl.Result{RequeueAfter: deleteRequeueAfter}, nil
 	}
 
 	// Delete control plane machines in parallel
 	machinesToDelete := ownedMachines.Filter(collections.Not(collections.HasDeletionTimestamp))
+
 	var errs []error
+
 	for i := range machinesToDelete {
 		m := machinesToDelete[i]
 		logger := logger.WithValues("machine", m)
+
 		if err := r.Client.Delete(ctx, machinesToDelete[i]); err != nil && !apierrors.IsNotFound(err) {
 			logger.Error(err, "Failed to cleanup owned machine")
 			errs = append(errs, err)
 		}
 	}
+
 	if len(errs) > 0 {
 		err := kerrors.NewAggregate(errs)
 		r.recorder.Eventf(rcp, corev1.EventTypeWarning, "FailedDelete",
 			"Failed to delete control plane Machines for cluster %s/%s control plane: %v", cluster.Namespace, cluster.Name, err)
+
 		return ctrl.Result{}, err
 	}
+
 	conditions.MarkFalse(rcp, controlplanev1.ResizedCondition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "")
+
 	return ctrl.Result{RequeueAfter: deleteRequeueAfter}, nil
 }
 
-// 	TODO: Issue #76: Improve this part once there are dependencies on the Control Plane Object!
-
 func (r *RKE2ControlPlaneReconciler) reconcileKubeconfig(
 	ctx context.Context,
 	clusterName client.ObjectKey,
 	endpoint clusterv1.APIEndpoint,
-	rcp *controlplanev1.RKE2ControlPlane) (ctrl.Result, error) {
-
+	rcp *controlplanev1.RKE2ControlPlane,
+) (ctrl.Result, error) {
 	logger := ctrl.LoggerFrom(ctx)
 	if endpoint.IsZero() {
 		logger.V(5).Info("API Endpoint not yet known")
-		return ctrl.Result{RequeueAfter: 30 * time.Second}, nil
+
+		return ctrl.Result{RequeueAfter: DefaultRequeueTime}, nil
 	}
 
 	controllerOwnerRef := *metav1.NewControllerRef(rcp, controlplanev1.GroupVersion.WithKind("RKE2ControlPlane"))
 	configSecret, err := secret.GetFromNamespacedName(ctx, r.Client, clusterName, secret.Kubeconfig)
+
 	switch {
 	case apierrors.IsNotFound(errors.Cause(err)):
 		createErr := kubeconfig.CreateSecretWithOwner(
@@ -539,6 +640,7 @@ func (r *RKE2ControlPlaneReconciler) reconcileKubeconfig(
 	if !util.IsControlledBy(configSecret, rcp) {
 		return ctrl.Result{}, nil
 	}
+
 	return ctrl.Result{}, nil
 }
 
@@ -547,6 +649,10 @@ func (r *RKE2ControlPlaneReconciler) reconcileKubeconfig(
 func (r *RKE2ControlPlaneReconciler) reconcileControlPlaneConditions(ctx context.Context, controlPlane *rke2.ControlPlane) (ctrl.Result, error) {
 	logger := log.FromContext(ctx)
 
+	if controlPlane.Machines.Len() == 0 {
+		controlPlane.RCP.Status.Initialized = false
+	}
+
 	// If the cluster is not yet initialized, there is no way to connect to the workload cluster and fetch information
 	// for updating conditions. Return early.
 	if !controlPlane.RCP.Status.Initialized {
@@ -556,6 +662,7 @@ func (r *RKE2ControlPlaneReconciler) reconcileControlPlaneConditions(ctx context
 	workloadCluster, err := r.managementCluster.GetWorkloadCluster(ctx, util.ObjectKey(controlPlane.Cluster))
 	if err != nil {
 		logger.Info("Unable to get Workload cluster")
+
 		return ctrl.Result{}, errors.Wrap(err, "cannot get remote client to workload cluster")
 	}
 
@@ -585,12 +692,14 @@ func (r *RKE2ControlPlaneReconciler) upgradeControlPlane(
 	// for updating conditions. Return early.
 	if !rcp.Status.Initialized {
 		logger.Info("ControlPlane not yet initialized")
+
 		return ctrl.Result{}, nil
 	}
 
 	workloadCluster, err := r.managementCluster.GetWorkloadCluster(ctx, util.ObjectKey(cluster))
 	if err != nil {
 		logger.Error(err, "failed to get remote client for workload cluster", "cluster key", util.ObjectKey(cluster))
+
 		return ctrl.Result{}, err
 	}
 
@@ -603,6 +712,7 @@ func (r *RKE2ControlPlaneReconciler) upgradeControlPlane(
 		// scaleUp ensures that we don't continue scaling up while waiting for Machines to have NodeRefs
 		return r.scaleUpControlPlane(ctx, cluster, rcp, controlPlane)
 	}
+
 	return r.scaleDownControlPlane(ctx, cluster, rcp, controlPlane, machinesRequireUpgrade)
 }
 
@@ -612,6 +722,7 @@ func (r *RKE2ControlPlaneReconciler) ClusterToRKE2ControlPlane(o client.Object)
 	c, ok := o.(*clusterv1.Cluster)
 	if !ok {
 		r.Log.Error(nil, fmt.Sprintf("Expected a Cluster but got a %T", o))
+
 		return nil
 	}
 
@@ -624,7 +735,6 @@ func (r *RKE2ControlPlaneReconciler) ClusterToRKE2ControlPlane(o client.Object)
 }
 
 func getIPAddress(machine clusterv1.Machine) (ip string, err error) {
-
 	for _, address := range machine.Status.Addresses {
 		switch address.Type {
 		case clusterv1.MachineInternalIP:
diff --git a/controlplane/internal/controllers/scale.go b/controlplane/internal/controllers/scale.go
index 56b869d..6736eaa 100644
--- a/controlplane/internal/controllers/scale.go
+++ b/controlplane/internal/controllers/scale.go
@@ -24,27 +24,33 @@ import (
 	"time"
 
 	"github.com/pkg/errors"
-	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
-	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
-
-	rke2 "github.com/rancher-sandbox/cluster-api-provider-rke2/pkg/rke2"
-	bsutil "github.com/rancher-sandbox/cluster-api-provider-rke2/pkg/util"
 	corev1 "k8s.io/api/core/v1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
 	kerrors "k8s.io/apimachinery/pkg/util/errors"
 	"k8s.io/apiserver/pkg/storage/names"
+	ctrl "sigs.k8s.io/controller-runtime"
+	"sigs.k8s.io/controller-runtime/pkg/log"
+
 	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	"sigs.k8s.io/cluster-api/controllers/external"
 	"sigs.k8s.io/cluster-api/util"
 	"sigs.k8s.io/cluster-api/util/collections"
 	"sigs.k8s.io/cluster-api/util/conditions"
-	ctrl "sigs.k8s.io/controller-runtime"
-	"sigs.k8s.io/controller-runtime/pkg/log"
+
+	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
+	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
+	rke2 "github.com/rancher-sandbox/cluster-api-provider-rke2/pkg/rke2"
+	bsutil "github.com/rancher-sandbox/cluster-api-provider-rke2/pkg/util"
 )
 
-func (r *RKE2ControlPlaneReconciler) initializeControlPlane(ctx context.Context, cluster *clusterv1.Cluster, rcp *controlplanev1.RKE2ControlPlane, controlPlane *rke2.ControlPlane) (ctrl.Result, error) {
+func (r *RKE2ControlPlaneReconciler) initializeControlPlane(
+	ctx context.Context,
+	cluster *clusterv1.Cluster,
+	rcp *controlplanev1.RKE2ControlPlane,
+	controlPlane *rke2.ControlPlane,
+) (ctrl.Result, error) {
 	logger := controlPlane.Logger()
 
 	// Perform an uncached read of all the owned machines. This check is in place to make sure
@@ -52,8 +58,10 @@ func (r *RKE2ControlPlaneReconciler) initializeControlPlane(ctx context.Context,
 	ownedMachines, err := r.managementClusterUncached.GetMachinesForCluster(ctx, util.ObjectKey(cluster), collections.OwnedMachines(rcp))
 	if err != nil {
 		logger.Error(err, "failed to perform an uncached read of control plane machines for cluster")
+
 		return ctrl.Result{}, err
 	}
+
 	if len(ownedMachines) > 0 {
 		return ctrl.Result{}, errors.Errorf(
 			"control plane has already been initialized, found %d owned machine for cluster %s/%s: controller cache or management cluster is misbehaving",
@@ -63,9 +71,18 @@ func (r *RKE2ControlPlaneReconciler) initializeControlPlane(ctx context.Context,
 
 	bootstrapSpec := controlPlane.InitialControlPlaneConfig()
 	fd := controlPlane.NextFailureDomainForScaleUp()
+
 	if err := r.cloneConfigsAndGenerateMachine(ctx, cluster, rcp, bootstrapSpec, fd); err != nil {
 		logger.Error(err, "Failed to create initial control plane Machine")
-		r.recorder.Eventf(rcp, corev1.EventTypeWarning, "FailedInitialization", "Failed to create initial control plane Machine for cluster %s/%s control plane: %v", cluster.Namespace, cluster.Name, err)
+		r.recorder.Eventf(
+			rcp,
+			corev1.EventTypeWarning,
+			"FailedInitialization",
+			"Failed to create initial control plane Machine for cluster %s/%s control plane: %v",
+			cluster.Namespace,
+			cluster.Name,
+			err)
+
 		return ctrl.Result{}, err
 	}
 
@@ -73,20 +90,35 @@ func (r *RKE2ControlPlaneReconciler) initializeControlPlane(ctx context.Context,
 	return ctrl.Result{Requeue: true}, nil
 }
 
-func (r *RKE2ControlPlaneReconciler) scaleUpControlPlane(ctx context.Context, cluster *clusterv1.Cluster, rcp *controlplanev1.RKE2ControlPlane, controlPlane *rke2.ControlPlane) (ctrl.Result, error) {
+func (r *RKE2ControlPlaneReconciler) scaleUpControlPlane(
+	ctx context.Context,
+	cluster *clusterv1.Cluster,
+	rcp *controlplanev1.RKE2ControlPlane,
+	controlPlane *rke2.ControlPlane,
+) (ctrl.Result, error) {
 	logger := controlPlane.Logger()
 
 	// Run preflight checks to ensure that the control plane is stable before proceeding with a scale up/scale down operation; if not, wait.
-	if result, err := r.preflightChecks(ctx, controlPlane); err != nil || !result.IsZero() {
-		return result, err
+	if result := r.preflightChecks(ctx, controlPlane); !result.IsZero() {
+		return result, nil
 	}
 
 	// Create the bootstrap configuration
 	bootstrapSpec := controlPlane.JoinControlPlaneConfig()
 	fd := controlPlane.NextFailureDomainForScaleUp()
+
 	if err := r.cloneConfigsAndGenerateMachine(ctx, cluster, rcp, bootstrapSpec, fd); err != nil {
 		logger.Error(err, "Failed to create additional control plane Machine")
-		r.recorder.Eventf(rcp, corev1.EventTypeWarning, "FailedScaleUp", "Failed to create additional control plane Machine for cluster %s/%s control plane: %v", cluster.Namespace, cluster.Name, err)
+		r.recorder.Eventf(
+			rcp,
+			corev1.EventTypeWarning,
+			"FailedScaleUp",
+			"Failed to create additional control plane Machine for cluster %s/%s control plane: %v",
+			cluster.Namespace,
+			cluster.Name,
+			err,
+		)
+
 		return ctrl.Result{}, err
 	}
 
@@ -111,42 +143,22 @@ func (r *RKE2ControlPlaneReconciler) scaleDownControlPlane(
 
 	// Run preflight checks ensuring the control plane is stable before proceeding with a scale up/scale down operation; if not, wait.
 	// Given that we're scaling down, we can exclude the machineToDelete from the preflight checks.
-	if result, err := r.preflightChecks(ctx, controlPlane, machineToDelete); err != nil || !result.IsZero() {
-		return result, err
+	if result := r.preflightChecks(ctx, controlPlane, machineToDelete); !result.IsZero() {
+		return result, nil
 	}
 
-	//workloadCluster, err := r.managementCluster.GetWorkloadCluster(ctx, util.ObjectKey(cluster))
-	//if err != nil {
-	//	logger.Error(err, "Failed to create client to workload cluster")
-	//	return ctrl.Result{}, errors.Wrapf(err, "failed to create client to workload cluster")
-	//}
-
 	if machineToDelete == nil {
 		logger.Info("Failed to pick control plane Machine to delete")
-		return ctrl.Result{}, errors.New("failed to pick control plane Machine to delete")
-	}
 
-	// TODO figure out etcd complexities
-	// If RCP should manage etcd, If etcd leadership is on machine that is about to be deleted, move it to the newest member available.
-	/**
-	if controlPlane.IsEtcdManaged() {
-		etcdLeaderCandidate := controlPlane.Machines.Newest()
-		if err := workloadCluster.ForwardEtcdLeadership(ctx, machineToDelete, etcdLeaderCandidate); err != nil {
-			logger.Error(err, "Failed to move leadership to candidate machine", "candidate", etcdLeaderCandidate.Name)
-			return ctrl.Result{}, err
-		}
-		if err := workloadCluster.RemoveEtcdMemberForMachine(ctx, machineToDelete); err != nil {
-			logger.Error(err, "Failed to remove etcd member for machine")
-			return ctrl.Result{}, err
-		}
+		return ctrl.Result{}, errors.New("failed to pick control plane Machine to delete")
 	}
-	**/
 
 	logger = logger.WithValues("machine", machineToDelete)
 	if err := r.Client.Delete(ctx, machineToDelete); err != nil && !apierrors.IsNotFound(err) {
 		logger.Error(err, "Failed to delete control plane machine")
 		r.recorder.Eventf(rcp, corev1.EventTypeWarning, "FailedScaleDown",
 			"Failed to delete control plane Machine %s for cluster %s/%s control plane: %v", machineToDelete.Name, cluster.Namespace, cluster.Name, err)
+
 		return ctrl.Result{}, err
 	}
 
@@ -162,19 +174,27 @@ func (r *RKE2ControlPlaneReconciler) scaleDownControlPlane(
 // If the control plane is not passing preflight checks, it requeue.
 //
 // NOTE: this func uses RCP conditions, it is required to call reconcileControlPlaneConditions before this.
-func (r *RKE2ControlPlaneReconciler) preflightChecks(ctx context.Context, controlPlane *rke2.ControlPlane, excludeFor ...*clusterv1.Machine) (ctrl.Result, error) { //nolint:unparam
+func (r *RKE2ControlPlaneReconciler) preflightChecks(
+	ctx context.Context,
+	controlPlane *rke2.ControlPlane,
+	excludeFor ...*clusterv1.Machine,
+) ctrl.Result {
 	logger := log.FromContext(ctx)
 
 	// If there is no RCP-owned control-plane machines, then control-plane has not been initialized yet,
 	// so it is considered ok to proceed.
 	if controlPlane.Machines.Len() == 0 {
-		return ctrl.Result{}, nil
+		return ctrl.Result{}
 	}
 
 	// If there are deleting machines, wait for the operation to complete.
 	if controlPlane.HasDeletingMachine() {
-		logger.Info("Waiting for machines to be deleted", "Machines", strings.Join(controlPlane.Machines.Filter(collections.HasDeletionTimestamp).Names(), ", "))
-		return ctrl.Result{RequeueAfter: deleteRequeueAfter}, nil
+		logger.Info("Waiting for machines to be deleted", "Machines",
+			strings.Join(controlPlane.Machines.Filter(collections.HasDeletionTimestamp).Names(),
+				", ",
+			))
+
+		return ctrl.Result{RequeueAfter: deleteRequeueAfter}
 	}
 
 	// Check machine health conditions; if there are conditions with False or Unknown, then wait.
@@ -183,7 +203,6 @@ func (r *RKE2ControlPlaneReconciler) preflightChecks(ctx context.Context, contro
 
 loopmachines:
 	for _, machine := range controlPlane.Machines {
-
 		for _, excluded := range excludeFor {
 			// If this machine should be excluded from the individual
 			// health check, continue the out loop.
@@ -198,35 +217,39 @@ loopmachines:
 			}
 		}
 	}
+
 	if len(machineErrors) > 0 {
 		aggregatedError := kerrors.NewAggregate(machineErrors)
 		r.recorder.Eventf(controlPlane.RCP, corev1.EventTypeWarning, "ControlPlaneUnhealthy",
 			"Waiting for control plane to pass preflight checks to continue reconciliation: %v", aggregatedError)
 		logger.Info("Waiting for control plane to pass preflight checks", "failures", aggregatedError.Error())
 
-		return ctrl.Result{RequeueAfter: preflightFailedRequeueAfter}, nil
+		return ctrl.Result{RequeueAfter: preflightFailedRequeueAfter}
 	}
 
-	return ctrl.Result{}, nil
+	return ctrl.Result{}
 }
 
 func preflightCheckCondition(kind string, obj conditions.Getter, condition clusterv1.ConditionType) error {
-
 	c := conditions.Get(obj, condition)
 	if c == nil {
 		return errors.Errorf("%s %s does not have %s condition", kind, obj.GetName(), condition)
 	}
+
 	if c.Status == corev1.ConditionFalse {
 		return errors.Errorf("%s %s reports %s condition is false (%s, %s)", kind, obj.GetName(), condition, c.Severity, c.Message)
 	}
+
 	if c.Status == corev1.ConditionUnknown {
 		return errors.Errorf("%s %s reports %s condition is unknown (%s)", kind, obj.GetName(), condition, c.Message)
 	}
+
 	return nil
 }
 
 func selectMachineForScaleDown(controlPlane *rke2.ControlPlane, outdatedMachines collections.Machines) (*clusterv1.Machine, error) {
 	machines := controlPlane.Machines
+
 	switch {
 	case controlPlane.MachineWithDeleteAnnotation(outdatedMachines).Len() > 0:
 		machines = controlPlane.MachineWithDeleteAnnotation(outdatedMachines)
@@ -241,10 +264,17 @@ func selectMachineForScaleDown(controlPlane *rke2.ControlPlane, outdatedMachines
 		machines = machines.Filter(collections.Not(collections.IsReady()))
 		controlPlane.Logger().V(5).Info("Inside the IsReady case", "machines", machines.Names())
 	}
+
 	return controlPlane.MachineInFailureDomainWithMostMachines(machines)
 }
 
-func (r *RKE2ControlPlaneReconciler) cloneConfigsAndGenerateMachine(ctx context.Context, cluster *clusterv1.Cluster, rcp *controlplanev1.RKE2ControlPlane, bootstrapSpec *bootstrapv1.RKE2ConfigSpec, failureDomain *string) error {
+func (r *RKE2ControlPlaneReconciler) cloneConfigsAndGenerateMachine(
+	ctx context.Context,
+	cluster *clusterv1.Cluster,
+	rcp *controlplanev1.RKE2ControlPlane,
+	bootstrapSpec *bootstrapv1.RKE2ConfigSpec,
+	failureDomain *string,
+) error {
 	var errs []error
 
 	// Since the cloned resource should eventually have a controller ref for the Machine, we create an
@@ -315,7 +345,12 @@ func (r *RKE2ControlPlaneReconciler) cleanupFromGeneration(ctx context.Context,
 	return kerrors.NewAggregate(errs)
 }
 
-func (r *RKE2ControlPlaneReconciler) generateRKE2Config(ctx context.Context, rcp *controlplanev1.RKE2ControlPlane, cluster *clusterv1.Cluster, spec *bootstrapv1.RKE2ConfigSpec) (*corev1.ObjectReference, error) {
+func (r *RKE2ControlPlaneReconciler) generateRKE2Config(
+	ctx context.Context,
+	rcp *controlplanev1.RKE2ControlPlane,
+	cluster *clusterv1.Cluster,
+	spec *bootstrapv1.RKE2ConfigSpec,
+) (*corev1.ObjectReference, error) {
 	// Create an owner reference without a controller reference because the owning controller is the machine controller
 	owner := metav1.OwnerReference{
 		APIVersion: controlplanev1.GroupVersion.String(),
@@ -349,13 +384,23 @@ func (r *RKE2ControlPlaneReconciler) generateRKE2Config(ctx context.Context, rcp
 	return bootstrapRef, nil
 }
 
-func (r *RKE2ControlPlaneReconciler) generateMachine(ctx context.Context, rcp *controlplanev1.RKE2ControlPlane, cluster *clusterv1.Cluster, infraRef, bootstrapRef *corev1.ObjectReference, failureDomain *string) error {
+func (r *RKE2ControlPlaneReconciler) generateMachine(
+	ctx context.Context,
+	rcp *controlplanev1.RKE2ControlPlane,
+	cluster *clusterv1.Cluster,
+	infraRef,
+	bootstrapRef *corev1.ObjectReference,
+	failureDomain *string,
+) error {
 	newVersion, err := bsutil.Rke2ToKubeVersion(rcp.Spec.AgentConfig.Version)
 	if err != nil {
 		return fmt.Errorf("failed to convert rke2 version to kubernetes version: %w", err)
 	}
+
 	logger := log.FromContext(ctx)
+
 	logger.Info("Version checking...", "rke2-version", rcp.Spec.AgentConfig.Version, "machine-version: ", newVersion)
+
 	machine := &clusterv1.Machine{
 		ObjectMeta: metav1.ObjectMeta{
 			Name:      names.SimpleNameGenerator.GenerateName(rcp.Name + "-"),
@@ -385,10 +430,12 @@ func (r *RKE2ControlPlaneReconciler) generateMachine(ctx context.Context, rcp *c
 	if err != nil {
 		return errors.Wrap(err, "failed to marshal cluster configuration")
 	}
+
 	machine.SetAnnotations(map[string]string{controlplanev1.RKE2ServerConfigurationAnnotation: string(serverConfig)})
 
 	if err := r.Client.Create(ctx, machine); err != nil {
 		return errors.Wrap(err, "failed to create machine")
 	}
+
 	return nil
 }
diff --git a/controlplane/main.go b/controlplane/main.go
index 500c80a..7dc0968 100644
--- a/controlplane/main.go
+++ b/controlplane/main.go
@@ -27,9 +27,6 @@ import (
 	// to ensure that exec-entrypoint and run can make use of them.
 	_ "k8s.io/client-go/plugin/pkg/client/auth"
 
-	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
-	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
-	"github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/internal/controllers"
 	"github.com/spf13/pflag"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/runtime"
@@ -37,11 +34,16 @@ import (
 	clientgoscheme "k8s.io/client-go/kubernetes/scheme"
 	"k8s.io/klog/v2"
 	"k8s.io/klog/v2/klogr"
-	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	ctrl "sigs.k8s.io/controller-runtime"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/healthz"
-	//+kubebuilder:scaffold:imports
+
+	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
+
+	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
+	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
+	"github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/internal/controllers"
+	"github.com/rancher-sandbox/cluster-api-provider-rke2/pkg/consts"
 )
 
 var (
@@ -64,14 +66,13 @@ var (
 )
 
 func init() {
-
 	utilruntime.Must(clientgoscheme.AddToScheme(scheme))
 
 	utilruntime.Must(clusterv1.AddToScheme(scheme))
 	utilruntime.Must(controlplanev1.AddToScheme(scheme))
 	utilruntime.Must(bootstrapv1.AddToScheme(scheme))
 	//+kubebuilder:scaffold:scheme
-}
+} //nolint:wsl
 
 // InitFlags initializes the flags.
 func InitFlags(fs *pflag.FlagSet) {
@@ -81,17 +82,17 @@ func InitFlags(fs *pflag.FlagSet) {
 	fs.BoolVar(&enableLeaderElection, "leader-elect", false,
 		"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")
 
-	fs.DurationVar(&leaderElectionLeaseDuration, "leader-elect-lease-duration", 15*time.Second,
+	fs.DurationVar(&leaderElectionLeaseDuration, "leader-elect-lease-duration", consts.DefaultLeaderElectLeaseDuration,
 		"Interval at which non-leader candidates will wait to force acquire leadership (duration string)")
 
-	fs.DurationVar(&leaderElectionRenewDeadline, "leader-elect-renew-deadline", 10*time.Second,
+	fs.DurationVar(&leaderElectionRenewDeadline, "leader-elect-renew-deadline", consts.DefaultLeaderElectRenewDeadline,
 		"Duration that the leading controller manager will retry refreshing leadership before giving up (duration string)")
 
-	fs.DurationVar(&leaderElectionRetryPeriod, "leader-elect-retry-period", 2*time.Second,
+	fs.DurationVar(&leaderElectionRetryPeriod, "leader-elect-retry-period", consts.DefaultLeaderElectRetryPeriod,
 		"Duration the LeaderElector clients should wait between tries of actions (duration string)")
 
 	fs.StringVar(&watchFilterValue, "watch-filter", "",
-		fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))
+		fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel)) //nolint:lll
 
 	fs.StringVar(&profilerAddress, "profiler-address", "",
 		"Bind address to expose the pprof profiler (e.g. localhost:6060)")
@@ -99,10 +100,10 @@ func InitFlags(fs *pflag.FlagSet) {
 	fs.IntVar(&concurrencyNumber, "concurrency", 1,
 		"Number of core resources to process simultaneously")
 
-	fs.DurationVar(&syncPeriod, "sync-period", 10*time.Minute,
+	fs.DurationVar(&syncPeriod, "sync-period", consts.DefaultSyncPeriod,
 		"The minimum interval at which watched resources are reconciled (e.g. 15m)")
 
-	fs.IntVar(&webhookPort, "webhook-port", 9443, "Webhook Server port")
+	fs.IntVar(&webhookPort, "webhook-port", consts.DefaultWebhookPort, "Webhook Server port")
 
 	fs.StringVar(&webhookCertDir, "webhook-cert-dir", "/tmp/k8s-webhook-server/serving-certs/",
 		"Webhook cert dir, only used when webhook-port is specified.")
@@ -121,6 +122,7 @@ func main() {
 
 	if profilerAddress != "" {
 		klog.Infof("Profiler listening for requests at %s", profilerAddress)
+
 		go func() {
 			klog.Info(http.ListenAndServe(profilerAddress, nil))
 		}()
@@ -154,6 +156,7 @@ func main() {
 	//+kubebuilder:scaffold:builder
 
 	setupLog.Info("starting manager")
+
 	if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
 		setupLog.Error(err, "problem running manager")
 		os.Exit(1)
@@ -161,6 +164,7 @@ func main() {
 
 	//+kubebuilder:scaffold:builder
 	setupLog.Info("starting manager")
+
 	if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil {
 		setupLog.Error(err, "problem running manager")
 		os.Exit(1)
@@ -172,6 +176,7 @@ func setupChecks(mgr ctrl.Manager) {
 		setupLog.Error(err, "unable to set up health check")
 		os.Exit(1)
 	}
+
 	if err := mgr.AddReadyzCheck("readyz", healthz.Ping); err != nil {
 		setupLog.Error(err, "unable to set up ready check")
 		os.Exit(1)
@@ -193,6 +198,7 @@ func setupWebhooks(mgr ctrl.Manager) {
 		setupLog.Error(err, "unable to create webhook", "webhook", "RKE2ControlPlane")
 		os.Exit(1)
 	}
+
 	if err := (&controlplanev1.RKE2ControlPlaneTemplate{}).SetupWebhookWithManager(mgr); err != nil {
 		setupLog.Error(err, "unable to create webhook", "webhook", "RKE2ControlPlaneTemplate")
 		os.Exit(1)
diff --git a/pkg/consts/global_consts.go b/pkg/consts/global_consts.go
new file mode 100644
index 0000000..b81ae2c
--- /dev/null
+++ b/pkg/consts/global_consts.go
@@ -0,0 +1,41 @@
+/*
+Copyright 2022 SUSE.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package consts
+
+import (
+	"time"
+)
+
+const (
+	// DefaultLeaderElectLeaseDuration is the default duration that non-leader candidates will
+	// wait to force acquire leadership.
+	DefaultLeaderElectLeaseDuration = 15 * time.Second
+
+	// DefaultLeaderElectRenewDeadline is the default duration that the acting master will retry
+	// refreshing leadership before giving up.
+	DefaultLeaderElectRenewDeadline = 10 * time.Second
+
+	// DefaultLeaderElectRetryPeriod is the default duration the LeaderElector clients should wait
+	// between tries of actions.
+	DefaultLeaderElectRetryPeriod = 2 * time.Second
+
+	// DefaultWebhookPort is the default port that the webhook server serves at.
+	DefaultWebhookPort = 9443
+
+	// DefaultSyncPeriod is the default resync period for the controller manager's cache.
+	DefaultSyncPeriod = 10 * time.Minute
+)
diff --git a/pkg/kubeconfig/kubeconfig.go b/pkg/kubeconfig/kubeconfig.go
index 033ddf0..a726f0e 100644
--- a/pkg/kubeconfig/kubeconfig.go
+++ b/pkg/kubeconfig/kubeconfig.go
@@ -37,9 +37,9 @@ import (
 	"github.com/rancher-sandbox/cluster-api-provider-rke2/pkg/secret"
 )
 
-var (
-	ErrDependentCertificateNotFound = errors.New("could not find secret ca")
-)
+// ErrDependentCertificateNotFound is returned when the kubeconfig cannot be generated because the
+// dependent certificate is not found.
+var ErrDependentCertificateNotFound = errors.New("could not find secret ca")
 
 func generateKubeconfig(ctx context.Context, c client.Client, clusterName client.ObjectKey, endpoint string) ([]byte, error) {
 	clusterCA, err := secret.GetFromNamespacedName(ctx, c, clusterName, secret.ClusterCA)
@@ -47,6 +47,7 @@ func generateKubeconfig(ctx context.Context, c client.Client, clusterName client
 		if apierrors.IsNotFound(errors.Cause(err)) {
 			return nil, ErrDependentCertificateNotFound
 		}
+
 		return nil, err
 	}
 
@@ -55,6 +56,7 @@ func generateKubeconfig(ctx context.Context, c client.Client, clusterName client
 		if apierrors.IsNotFound(errors.Cause(err)) {
 			return nil, ErrDependentCertificateNotFound
 		}
+
 		return nil, err
 	}
 
@@ -88,12 +90,16 @@ func generateKubeconfig(ctx context.Context, c client.Client, clusterName client
 	if err != nil {
 		return nil, errors.Wrap(err, "failed to serialize config to yaml")
 	}
+
 	return out, nil
 }
 
 // New creates a new Kubeconfig using the cluster name and specified endpoint.
-func New(clusterName, endpoint string, clientCACert *x509.Certificate, clientCAKey crypto.Signer, serverCACert *x509.Certificate) (*api.Config, error) {
-
+func New(
+	clusterName,
+	endpoint string,
+	clientCACert *x509.Certificate, clientCAKey crypto.Signer, serverCACert *x509.Certificate,
+) (*api.Config, error) {
 	cfg := &certs.Config{
 		CommonName:   "kubernetes-admin",
 		Organization: []string{"system:masters"},
@@ -139,6 +145,7 @@ func New(clusterName, endpoint string, clientCACert *x509.Certificate, clientCAK
 // CreateSecret creates the Kubeconfig secret for the given cluster.
 func CreateSecret(ctx context.Context, c client.Client, cluster *clusterv1.Cluster) error {
 	name := util.ObjectKey(cluster)
+
 	return CreateSecretWithOwner(ctx, c, name, cluster.Spec.ControlPlaneEndpoint.String(), metav1.OwnerReference{
 		APIVersion: clusterv1.GroupVersion.String(),
 		Kind:       "Cluster",
@@ -150,6 +157,7 @@ func CreateSecret(ctx context.Context, c client.Client, cluster *clusterv1.Clust
 // CreateSecretWithOwner creates the Kubeconfig secret for the given cluster name, namespace, endpoint, and owner reference.
 func CreateSecretWithOwner(ctx context.Context, c client.Client, clusterName client.ObjectKey, endpoint string, owner metav1.OwnerReference) error {
 	server := fmt.Sprintf("https://%s", endpoint)
+
 	out, err := generateKubeconfig(ctx, c, clusterName, server)
 	if err != nil {
 		return err
@@ -161,6 +169,7 @@ func CreateSecretWithOwner(ctx context.Context, c client.Client, clusterName cli
 // GenerateSecret returns a Kubernetes secret for the given Cluster and kubeconfig data.
 func GenerateSecret(cluster *clusterv1.Cluster, data []byte) *corev1.Secret {
 	name := util.ObjectKey(cluster)
+
 	return GenerateSecretWithOwner(name, data, metav1.OwnerReference{
 		APIVersion: clusterv1.GroupVersion.String(),
 		Kind:       "Cluster",
diff --git a/pkg/locking/control_plane_init_mutex.go b/pkg/locking/control_plane_init_mutex.go
index bcd01bf..96b4caf 100644
--- a/pkg/locking/control_plane_init_mutex.go
+++ b/pkg/locking/control_plane_init_mutex.go
@@ -56,16 +56,19 @@ func (c *ControlPlaneInitMutex) Lock(ctx context.Context, cluster *clusterv1.Clu
 		Namespace: cluster.Namespace,
 		Name:      cmName,
 	}, sema.ConfigMap)
+
 	switch {
 	case apierrors.IsNotFound(err):
 		break
 	case err != nil:
 		log.Error(err, "Failed to acquire init lock")
+
 		return false
 	default: // Successfully found an existing config map.
 		info, err := sema.information()
 		if err != nil {
 			log.Error(err, "Failed to get information about the existing init lock")
+
 			return false
 		}
 		// The machine requesting the lock is the machine that created the lock, therefore the lock is acquired.
@@ -79,11 +82,14 @@ func (c *ControlPlaneInitMutex) Lock(ctx context.Context, cluster *clusterv1.Clu
 			Name:      info.MachineName,
 		}, &clusterv1.Machine{}); err != nil {
 			log.Error(err, "Failed to get machine holding init lock")
+
 			if apierrors.IsNotFound(err) {
 				c.Unlock(ctx, cluster)
 			}
 		}
+
 		log.Info(fmt.Sprintf("Waiting for Machine %s to initialize", info.MachineName))
+
 		return false
 	}
 
@@ -92,17 +98,22 @@ func (c *ControlPlaneInitMutex) Lock(ctx context.Context, cluster *clusterv1.Clu
 	// Adds the additional information
 	if err := sema.setInformation(&information{MachineName: machine.Name}); err != nil {
 		log.Error(err, "Failed to acquire init lock while setting semaphore information")
+
 		return false
 	}
 
 	log.Info("Attempting to acquire the lock")
+
 	err = c.client.Create(ctx, sema.ConfigMap)
+
 	switch {
 	case apierrors.IsAlreadyExists(err):
 		log.Info("Cannot acquire the init lock. The init lock has been acquired by someone else")
+
 		return false
 	case err != nil:
 		log.Error(err, "Error acquiring the init lock")
+
 		return false
 	default:
 		return true
@@ -118,12 +129,15 @@ func (c *ControlPlaneInitMutex) Unlock(ctx context.Context, cluster *clusterv1.C
 		Namespace: cluster.Namespace,
 		Name:      cmName,
 	}, sema.ConfigMap)
+
 	switch {
 	case apierrors.IsNotFound(err):
 		log.Info("Control plane init lock not found, it may have been released already")
+
 		return true
 	case err != nil:
 		log.Error(err, "Error unlocking the control plane init lock")
+
 		return false
 	default:
 		// Delete the config map semaphore if there is no error fetching it
@@ -131,9 +145,12 @@ func (c *ControlPlaneInitMutex) Unlock(ctx context.Context, cluster *clusterv1.C
 			if apierrors.IsNotFound(err) {
 				return true
 			}
+
 			log.Error(err, "Error deleting the config map underlying the control plane init lock")
+
 			return false
 		}
+
 		return true
 	}
 }
@@ -159,6 +176,7 @@ func (s semaphore) information() (*information, error) {
 	if err := json.Unmarshal([]byte(s.Data[semaphoreInformationKey]), li); err != nil {
 		return nil, errors.Wrap(err, "failed to unmarshal semaphore information")
 	}
+
 	return li, nil
 }
 
@@ -167,8 +185,10 @@ func (s semaphore) setInformation(information *information) error {
 	if err != nil {
 		return errors.Wrap(err, "failed to marshal semaphore information")
 	}
+
 	s.Data = map[string]string{}
 	s.Data[semaphoreInformationKey] = string(b)
+
 	return nil
 }
 
diff --git a/pkg/rke2/config.go b/pkg/rke2/config.go
index 1ee0abd..01e50ab 100644
--- a/pkg/rke2/config.go
+++ b/pkg/rke2/config.go
@@ -13,25 +13,32 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
-
+//nolint:tagliatelle
 package rke2
 
 import (
 	"context"
 	"fmt"
 
-	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
-	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
 	corev1 "k8s.io/api/core/v1"
 	"k8s.io/apimachinery/pkg/types"
-	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	"sigs.k8s.io/controller-runtime/pkg/client"
+
+	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
+
+	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
+	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
 )
 
 const (
-	DefaultRKE2ConfigLocation              = "/etc/rancher/rke2/config.yaml"
+	// DefaultRKE2ConfigLocation is the default location for the RKE2 config file.
+	DefaultRKE2ConfigLocation = "/etc/rancher/rke2/config.yaml"
+
+	// DefaultRKE2CloudProviderConfigLocation is the default location for the RKE2 cloud provider config file.
 	DefaultRKE2CloudProviderConfigLocation = "/etc/rancher/rke2/cloud-provider-config"
-	DefaultRKE2JoinPort                    = 9345
+
+	// DefaultRKE2JoinPort is the default port used for joining nodes to the cluster. It is open on the control plane nodes.
+	DefaultRKE2JoinPort = 9345
 )
 
 type rke2ServerConfig struct {
@@ -98,7 +105,8 @@ type rke2ServerConfig struct {
 	rke2AgentConfig `json:",inline"`
 }
 
-type RKE2ServerConfigOpts struct {
+// ServerConfigOpts is a struct that contains the information needed to generate a RKE2 server config.
+type ServerConfigOpts struct {
 	Cluster              clusterv1.Cluster
 	ControlPlaneEndpoint string
 	Token                string
@@ -109,10 +117,11 @@ type RKE2ServerConfigOpts struct {
 	Client               client.Client
 }
 
-func newRKE2ServerConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootstrapv1.File, error) {
+func newRKE2ServerConfig(opts ServerConfigOpts) (*rke2ServerConfig, []bootstrapv1.File, error) {
 	rke2ServerConfig := &rke2ServerConfig{}
 	files := []bootstrapv1.File{}
 	rke2ServerConfig.AdvertiseAddress = opts.ServerConfig.AdvertiseAddress
+
 	if opts.ServerConfig.AuditPolicySecret != nil {
 		auditPolicySecret := &corev1.Secret{}
 		if err := opts.Client.Get(opts.Ctx, types.NamespacedName{
@@ -121,11 +130,14 @@ func newRKE2ServerConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootst
 		}, auditPolicySecret); err != nil {
 			return nil, nil, fmt.Errorf("failed to get audit policy secret: %w", err)
 		}
+
 		auditPolicy, ok := auditPolicySecret.Data["audit-policy.yaml"]
 		if !ok {
 			return nil, nil, fmt.Errorf("audit policy secret is missing audit-policy.yaml key")
 		}
+
 		rke2ServerConfig.AuditPolicyFile = "/etc/rancher/rke2/audit-policy.yaml"
+
 		files = append(files, bootstrapv1.File{
 			Path:        rke2ServerConfig.AuditPolicyFile,
 			Content:     string(auditPolicy),
@@ -133,17 +145,24 @@ func newRKE2ServerConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootst
 			Permissions: "0644",
 		})
 	}
-	if opts.Cluster.Spec.ClusterNetwork != nil && opts.Cluster.Spec.ClusterNetwork.Pods != nil && len(opts.Cluster.Spec.ClusterNetwork.Pods.CIDRBlocks) > 0 {
-		rke2ServerConfig.ClusterCIDR = opts.Cluster.Spec.ClusterNetwork.Pods.CIDRBlocks[0]
 
+	if opts.Cluster.Spec.ClusterNetwork != nil &&
+		opts.Cluster.Spec.ClusterNetwork.Pods != nil &&
+		len(opts.Cluster.Spec.ClusterNetwork.Pods.CIDRBlocks) > 0 {
+		rke2ServerConfig.ClusterCIDR = opts.Cluster.Spec.ClusterNetwork.Pods.CIDRBlocks[0]
 	}
-	if opts.Cluster.Spec.ClusterNetwork != nil && opts.Cluster.Spec.ClusterNetwork.Services != nil && len(opts.Cluster.Spec.ClusterNetwork.Services.CIDRBlocks) > 0 {
+
+	if opts.Cluster.Spec.ClusterNetwork != nil &&
+		opts.Cluster.Spec.ClusterNetwork.Services != nil &&
+		len(opts.Cluster.Spec.ClusterNetwork.Services.CIDRBlocks) > 0 {
 		rke2ServerConfig.ServiceCIDR = opts.Cluster.Spec.ClusterNetwork.Services.CIDRBlocks[0]
 	}
+
 	rke2ServerConfig.BindAddress = opts.ServerConfig.BindAddress
 	rke2ServerConfig.CNI = string(opts.ServerConfig.CNI)
 	rke2ServerConfig.ClusterDNS = opts.ServerConfig.ClusterDNS
 	rke2ServerConfig.ClusterDomain = opts.ServerConfig.ClusterDomain
+
 	if opts.ServerConfig.CloudProviderConfigMap != nil {
 		cloudProviderConfigMap := &corev1.ConfigMap{}
 		if err := opts.Client.Get(opts.Ctx, types.NamespacedName{
@@ -152,11 +171,14 @@ func newRKE2ServerConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootst
 		}, cloudProviderConfigMap); err != nil {
 			return nil, nil, fmt.Errorf("failed to get cloud provider config map: %w", err)
 		}
+
 		cloudProviderConfig, ok := cloudProviderConfigMap.Data["cloud-config"]
 		if !ok {
 			return nil, nil, fmt.Errorf("cloud provider config map is missing cloud-config key")
 		}
+
 		rke2ServerConfig.CloudProviderConfig = "/etc/rancher/rke2/cloud-provider-config"
+
 		files = append(files, bootstrapv1.File{
 			Path:        rke2ServerConfig.CloudProviderConfig,
 			Content:     cloudProviderConfig,
@@ -164,14 +186,17 @@ func newRKE2ServerConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootst
 			Permissions: "0644",
 		})
 	}
+
 	rke2ServerConfig.CloudProviderName = opts.ServerConfig.CloudProviderName
 	rke2ServerConfig.DisableComponents = func() []string {
 		disabled := []string{}
 		for _, plugin := range opts.ServerConfig.DisableComponents.PluginComponents {
 			disabled = append(disabled, string(plugin))
 		}
+
 		return disabled
 	}()
+
 	for _, component := range opts.ServerConfig.DisableComponents.KubernetesComponents {
 		switch component {
 		case controlplanev1.KubeProxy:
@@ -180,32 +205,41 @@ func newRKE2ServerConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootst
 			rke2ServerConfig.DisableScheduler = true
 		}
 	}
+
 	rke2ServerConfig.DisableCloudController = true
-	rke2ServerConfig.EtcdDisableSnapshots = opts.ServerConfig.Etcd.BackupConfig.DisableAutomaticSnapshots // TODO: change API to disable so don't have to negate?
+	rke2ServerConfig.EtcdDisableSnapshots = opts.ServerConfig.Etcd.BackupConfig.DisableAutomaticSnapshots
 	rke2ServerConfig.EtcdExposeMetrics = opts.ServerConfig.Etcd.ExposeMetrics
+
 	if opts.ServerConfig.Etcd.BackupConfig.S3 != nil {
 		rke2ServerConfig.EtcdS3 = true
 		awsCredentialsSecret := &corev1.Secret{}
+
 		if err := opts.Client.Get(opts.Ctx, types.NamespacedName{
 			Name:      opts.ServerConfig.Etcd.BackupConfig.S3.S3CredentialSecret.Name,
 			Namespace: opts.ServerConfig.Etcd.BackupConfig.S3.S3CredentialSecret.Namespace,
 		}, awsCredentialsSecret); err != nil {
 			return nil, nil, fmt.Errorf("failed to get aws credentials secret: %w", err)
 		}
+
 		accessKeyID, ok := awsCredentialsSecret.Data["aws_access_key_id"]
+
 		if !ok {
 			return nil, nil, fmt.Errorf("aws credentials secret is missing aws_access_key_id")
 		}
+
 		secretAccessKey, ok := awsCredentialsSecret.Data["aws_secret_access_key"]
+
 		if !ok {
 			return nil, nil, fmt.Errorf("aws credentials secret is missing aws_secret_access_key")
 		}
+
 		rke2ServerConfig.EtcdS3AccessKey = string(accessKeyID)
 		rke2ServerConfig.EtcdS3SecretKey = string(secretAccessKey)
 		rke2ServerConfig.EtcdS3Bucket = opts.ServerConfig.Etcd.BackupConfig.S3.Bucket
 		rke2ServerConfig.EtcdS3Region = opts.ServerConfig.Etcd.BackupConfig.S3.Region
 		rke2ServerConfig.EtcdS3Folder = opts.ServerConfig.Etcd.BackupConfig.S3.Folder
 		rke2ServerConfig.EtcdS3Endpoint = opts.ServerConfig.Etcd.BackupConfig.S3.Endpoint
+
 		if opts.ServerConfig.Etcd.BackupConfig.S3.EndpointCASecret != nil {
 			endpointCAsecret := &corev1.Secret{}
 			if err := opts.Client.Get(opts.Ctx, types.NamespacedName{
@@ -214,11 +248,14 @@ func newRKE2ServerConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootst
 			}, endpointCAsecret); err != nil {
 				return nil, nil, fmt.Errorf("failed to get aws credentials secret: %w", err)
 			}
+
 			caCert, ok := endpointCAsecret.Data["ca.pem"]
 			if !ok {
 				return nil, nil, fmt.Errorf("endpoint CA secret is missing ca.pem")
 			}
+
 			rke2ServerConfig.EtcdS3EndpointCA = "/etc/rancher/rke2/etcd-s3-ca.crt"
+
 			files = append(files, bootstrapv1.File{
 				Path:        rke2ServerConfig.EtcdS3EndpointCA,
 				Content:     string(caCert),
@@ -226,11 +263,12 @@ func newRKE2ServerConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootst
 				Permissions: "0640",
 			})
 		}
+
 		rke2ServerConfig.EtcdSnapshotDir = opts.ServerConfig.Etcd.BackupConfig.Directory
 		rke2ServerConfig.EtcdSnapshotName = opts.ServerConfig.Etcd.BackupConfig.SnapshotName
 		rke2ServerConfig.EtcdSnapshotRetention = opts.ServerConfig.Etcd.BackupConfig.Retention
 		rke2ServerConfig.EtcdSnapshotScheduleCron = opts.ServerConfig.Etcd.BackupConfig.ScheduleCron
-		rke2ServerConfig.EtcdS3SkipSslVerify = !opts.ServerConfig.Etcd.BackupConfig.S3.EnforceSSLVerify // TODO: change API to skip so don't have to negate?
+		rke2ServerConfig.EtcdS3SkipSslVerify = !opts.ServerConfig.Etcd.BackupConfig.S3.EnforceSSLVerify
 	}
 
 	if opts.ServerConfig.Etcd.CustomConfig != nil {
@@ -299,19 +337,20 @@ type rke2AgentConfig struct {
 	Selinux                       bool              `json:"selinux,omitempty"`
 	Server                        string            `json:"server,omitempty"`
 	Snapshotter                   string            `json:"snapshotter,omitempty"`
-	Token                         string            `json:"token,omitempty"` // TODO: generate the token?
+	Token                         string            `json:"token,omitempty"`
 
 	// We don't expose these in the API
 	PauseImage                     string `json:"pause-image,omitempty"`
 	PodSecurityAdmissionConfigFile string `json:"pod-security-admission-config-file,omitempty"` // new flag, not present in the RKE2 docs yet
 	PrivateRegistry                string `json:"private-registry,omitempty"`
 
-	NodeExternalIp string `json:"node-external-ip,omitempty"` // TODO: infra provider can provider external ip, we should use it here and for TLS SAN.
-	NodeIp         string `json:"node-ip,omitempty"`          // TODO: obtain the node ip from the infra provider
-	NodeName       string `json:"node-name,omitempty"`        // TODO: figure our how to handle this using node name prefix from API
+	NodeExternalIp string `json:"node-external-ip,omitempty"`
+	NodeIp         string `json:"node-ip,omitempty"`
+	NodeName       string `json:"node-name,omitempty"`
 }
 
-type RKE2AgentConfigOpts struct {
+// AgentConfigOpts is a struct that holds the information needed to generate the rke2 server config.
+type AgentConfigOpts struct {
 	ServerURL              string
 	Token                  string
 	AgentConfig            bootstrapv1.RKE2AgentConfig
@@ -321,10 +360,11 @@ type RKE2AgentConfigOpts struct {
 	CloudProviderConfigMap *corev1.ObjectReference
 }
 
-func newRKE2AgentConfig(opts RKE2AgentConfigOpts) (*rke2AgentConfig, []bootstrapv1.File, error) {
+func newRKE2AgentConfig(opts AgentConfigOpts) (*rke2AgentConfig, []bootstrapv1.File, error) {
 	rke2AgentConfig := &rke2AgentConfig{}
 	files := []bootstrapv1.File{}
 	rke2AgentConfig.ContainerRuntimeEndpoint = opts.AgentConfig.ContainerRuntimeEndpoint
+
 	if opts.CloudProviderConfigMap != nil {
 		cloudProviderConfigMap := &corev1.ConfigMap{}
 		if err := opts.Client.Get(opts.Ctx, types.NamespacedName{
@@ -333,11 +373,15 @@ func newRKE2AgentConfig(opts RKE2AgentConfigOpts) (*rke2AgentConfig, []bootstrap
 		}, cloudProviderConfigMap); err != nil {
 			return nil, nil, fmt.Errorf("failed to get cloud provider config map: %w", err)
 		}
+
 		cloudProviderConfig, ok := cloudProviderConfigMap.Data["cloud-config"]
+
 		if !ok {
 			return nil, nil, fmt.Errorf("cloud provider config map is missing cloud-config key")
 		}
+
 		rke2AgentConfig.CloudProviderConfig = DefaultRKE2CloudProviderConfigLocation
+
 		files = append(files, bootstrapv1.File{
 			Path:        rke2AgentConfig.CloudProviderConfig,
 			Content:     cloudProviderConfig,
@@ -345,8 +389,10 @@ func newRKE2AgentConfig(opts RKE2AgentConfigOpts) (*rke2AgentConfig, []bootstrap
 			Permissions: "0644",
 		})
 	}
+
 	rke2AgentConfig.CloudProviderName = opts.CloudProviderName
 	rke2AgentConfig.DataDir = opts.AgentConfig.DataDir
+
 	if opts.AgentConfig.ImageCredentialProviderConfigMap != nil {
 		imageCredentialProviderCM := &corev1.ConfigMap{}
 		if err := opts.Client.Get(opts.Ctx, types.NamespacedName{
@@ -355,16 +401,21 @@ func newRKE2AgentConfig(opts RKE2AgentConfigOpts) (*rke2AgentConfig, []bootstrap
 		}, imageCredentialProviderCM); err != nil {
 			return nil, nil, fmt.Errorf("failed to get image credential provider config map: %w", err)
 		}
+
 		credentialConfig, ok := imageCredentialProviderCM.Data["credential-config.yaml"]
+
 		if !ok {
 			return nil, nil, fmt.Errorf("image credential provider config map is missing config.yaml")
 		}
+
 		credentialProviderBinaries, ok := imageCredentialProviderCM.Data["credential-provider-binaries"]
 		if !ok {
 			return nil, nil, fmt.Errorf("image credential provider config map is missing credential-provider-binaries")
 		}
+
 		rke2AgentConfig.ImageCredentialProviderBinDir = credentialProviderBinaries
 		rke2AgentConfig.ImageCredentialProviderConfig = "/etc/rancher/rke2/credential-config.yaml"
+
 		files = append(files, bootstrapv1.File{
 			Path:        rke2AgentConfig.ImageCredentialProviderConfig,
 			Content:     credentialConfig,
@@ -372,15 +423,18 @@ func newRKE2AgentConfig(opts RKE2AgentConfigOpts) (*rke2AgentConfig, []bootstrap
 			Permissions: "0644",
 		})
 	}
+
 	rke2AgentConfig.KubeletPath = opts.AgentConfig.KubeletPath
 	if opts.AgentConfig.Kubelet != nil {
-		rke2AgentConfig.KubeletArgs = opts.AgentConfig.Kubelet.ExtraArgs // TODO: Add a webhook validation to ensure that only args are used in this struct.
+		rke2AgentConfig.KubeletArgs = opts.AgentConfig.Kubelet.ExtraArgs
 	}
+
 	rke2AgentConfig.LbServerPort = opts.AgentConfig.LoadBalancerPort
 	rke2AgentConfig.NodeLabels = opts.AgentConfig.NodeLabels
 	rke2AgentConfig.NodeTaints = opts.AgentConfig.NodeTaints
 	rke2AgentConfig.Profile = string(opts.AgentConfig.CISProfile)
 	rke2AgentConfig.ProtectKernelDefaults = opts.AgentConfig.ProtectKernelDefaults
+
 	if opts.AgentConfig.ResolvConf != nil {
 		resolvConfCM := &corev1.ConfigMap{}
 		if err := opts.Client.Get(opts.Ctx, types.NamespacedName{
@@ -389,11 +443,14 @@ func newRKE2AgentConfig(opts RKE2AgentConfigOpts) (*rke2AgentConfig, []bootstrap
 		}, resolvConfCM); err != nil {
 			return nil, nil, fmt.Errorf("failed to get resolv.conf config map: %w", err)
 		}
+
 		resolvConf, ok := resolvConfCM.Data["resolv.conf"]
 		if !ok {
 			return nil, nil, fmt.Errorf("resolv conf config map is missing resolv.conf")
 		}
+
 		rke2AgentConfig.ResolvConf = "/etc/rancher/rke2/resolv.conf"
+
 		files = append(files, bootstrapv1.File{
 			Path:        rke2AgentConfig.ResolvConf,
 			Content:     resolvConf,
@@ -401,22 +458,26 @@ func newRKE2AgentConfig(opts RKE2AgentConfigOpts) (*rke2AgentConfig, []bootstrap
 			Permissions: "0644",
 		})
 	}
+
 	rke2AgentConfig.RuntimeImage = opts.AgentConfig.RuntimeImage
 	rke2AgentConfig.Selinux = opts.AgentConfig.EnableContainerdSElinux
 	rke2AgentConfig.Server = opts.ServerURL
 	rke2AgentConfig.Snapshotter = opts.AgentConfig.Snapshotter
+
 	if opts.AgentConfig.KubeProxy != nil {
 		rke2AgentConfig.KubeProxyArgs = opts.AgentConfig.KubeProxy.ExtraArgs
 		rke2AgentConfig.KubeProxyImage = opts.AgentConfig.KubeProxy.OverrideImage
 		rke2AgentConfig.KubeProxyExtraMounts = opts.AgentConfig.KubeProxy.ExtraMounts
 		rke2AgentConfig.KubeProxyExtraEnv = opts.AgentConfig.KubeProxy.ExtraEnv
 	}
+
 	rke2AgentConfig.Token = opts.Token
 
 	return rke2AgentConfig, files, nil
 }
 
-func GenerateInitControlPlaneConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootstrapv1.File, error) {
+// GenerateInitControlPlaneConfig generates the rke2 server and agent config for the init control plane node.
+func GenerateInitControlPlaneConfig(opts ServerConfigOpts) (*rke2ServerConfig, []bootstrapv1.File, error) {
 	if opts.Token == "" {
 		return nil, nil, fmt.Errorf("token is required")
 	}
@@ -426,13 +487,12 @@ func GenerateInitControlPlaneConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfi
 		return nil, nil, fmt.Errorf("failed to generate rke2 server config: %w", err)
 	}
 
-	rke2AgentConfig, agentFiles, err := newRKE2AgentConfig(RKE2AgentConfigOpts{
+	rke2AgentConfig, agentFiles, err := newRKE2AgentConfig(AgentConfigOpts{
 		AgentConfig: opts.AgentConfig,
 		Client:      opts.Client,
 		Ctx:         opts.Ctx,
 		Token:       opts.Token,
 	})
-
 	if err != nil {
 		return nil, nil, fmt.Errorf("failed to generate rke2 agent config: %w", err)
 	}
@@ -442,7 +502,8 @@ func GenerateInitControlPlaneConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfi
 	return rke2ServerConfig, append(serverFiles, agentFiles...), nil
 }
 
-func GenerateJoinControlPlaneConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfig, []bootstrapv1.File, error) {
+// GenerateJoinControlPlaneConfig generates the rke2 agent config for joining a control plane node.
+func GenerateJoinControlPlaneConfig(opts ServerConfigOpts) (*rke2ServerConfig, []bootstrapv1.File, error) {
 	if opts.ServerURL == "" {
 		return nil, nil, fmt.Errorf("server url is required")
 	}
@@ -456,14 +517,13 @@ func GenerateJoinControlPlaneConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfi
 		return nil, nil, fmt.Errorf("failed to generate rke2 server config: %w", err)
 	}
 
-	rke2AgentConfig, agentFiles, err := newRKE2AgentConfig(RKE2AgentConfigOpts{
+	rke2AgentConfig, agentFiles, err := newRKE2AgentConfig(AgentConfigOpts{
 		AgentConfig: opts.AgentConfig,
 		Client:      opts.Client,
 		Ctx:         opts.Ctx,
 		ServerURL:   opts.ServerURL,
 		Token:       opts.Token,
 	})
-
 	if err != nil {
 		return nil, nil, fmt.Errorf("failed to generate rke2 agent config: %w", err)
 	}
@@ -473,7 +533,8 @@ func GenerateJoinControlPlaneConfig(opts RKE2ServerConfigOpts) (*rke2ServerConfi
 	return rke2ServerConfig, append(serverFiles, agentFiles...), nil
 }
 
-func GenerateWorkerConfig(opts RKE2AgentConfigOpts) (*rke2AgentConfig, []bootstrapv1.File, error) {
+// GenerateWorkerConfig generates the rke2 agent config and files.
+func GenerateWorkerConfig(opts AgentConfigOpts) (*rke2AgentConfig, []bootstrapv1.File, error) {
 	if opts.ServerURL == "" {
 		return nil, nil, fmt.Errorf("server url is required")
 	}
diff --git a/pkg/rke2/control_plane.go b/pkg/rke2/control_plane.go
index c58590a..f39db86 100644
--- a/pkg/rke2/control_plane.go
+++ b/pkg/rke2/control_plane.go
@@ -31,13 +31,13 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/client"
 
 	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
+	"sigs.k8s.io/cluster-api/controllers/external"
+	"sigs.k8s.io/cluster-api/util/collections"
 	capifd "sigs.k8s.io/cluster-api/util/failuredomains"
+	"sigs.k8s.io/cluster-api/util/patch"
 
 	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
 	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
-	"sigs.k8s.io/cluster-api/controllers/external"
-	"sigs.k8s.io/cluster-api/util/collections"
-	"sigs.k8s.io/cluster-api/util/patch"
 )
 
 // ControlPlane holds business logic around control planes.
@@ -52,28 +52,36 @@ type ControlPlane struct {
 	// reconciliationTime is the time of the current reconciliation, and should be used for all "now" calculations
 	reconciliationTime metav1.Time
 
-	// TODO: we should see if we can combine these with the Machine objects so we don't have all these separate lookups
-	// See discussion on https://github.com/kubernetes-sigs/cluster-api/pull/3405
 	rke2Configs    map[string]*bootstrapv1.RKE2Config
 	infraResources map[string]*unstructured.Unstructured
 }
 
 // NewControlPlane returns an instantiated ControlPlane.
-func NewControlPlane(ctx context.Context, client client.Client, cluster *clusterv1.Cluster, rcp *controlplanev1.RKE2ControlPlane, ownedMachines collections.Machines) (*ControlPlane, error) {
+func NewControlPlane(
+	ctx context.Context,
+	client client.Client,
+	cluster *clusterv1.Cluster,
+	rcp *controlplanev1.RKE2ControlPlane,
+	ownedMachines collections.Machines,
+) (*ControlPlane, error) {
 	infraObjects, err := getInfraResources(ctx, client, ownedMachines)
 	if err != nil {
 		return nil, err
 	}
+
 	rke2Configs, err := getRKE2Configs(ctx, client, ownedMachines)
 	if err != nil {
 		return nil, err
 	}
+
 	patchHelpers := map[string]*patch.Helper{}
+
 	for _, machine := range ownedMachines {
 		patchHelper, err := patch.NewHelper(machine, client)
 		if err != nil {
 			return nil, errors.Wrapf(err, "failed to create patch helper for machine %s", machine.Name)
 		}
+
 		patchHelpers[machine.Name] = patchHelper
 	}
 
@@ -98,6 +106,7 @@ func (c *ControlPlane) FailureDomains() clusterv1.FailureDomains {
 	if c.Cluster.Status.FailureDomains == nil {
 		return clusterv1.FailureDomains{}
 	}
+
 	return c.Cluster.Status.FailureDomains
 }
 
@@ -106,7 +115,7 @@ func (c *ControlPlane) Version() *string {
 	return &c.RCP.Spec.AgentConfig.Version
 }
 
-// InfrastructureTemplate returns the RKE2ControlPlane's infrastructure template.
+// InfrastructureRef returns the RKE2ControlPlane's infrastructure template.
 func (c *ControlPlane) InfrastructureRef() *corev1.ObjectReference {
 	return &c.RCP.Spec.InfrastructureRef
 }
@@ -126,9 +135,11 @@ func (c *ControlPlane) MachineInFailureDomainWithMostMachines(machines collectio
 	fd := c.FailureDomainWithMostMachines(machines)
 	machinesInFailureDomain := machines.Filter(collections.InFailureDomains(fd))
 	machineToMark := machinesInFailureDomain.Oldest()
+
 	if machineToMark == nil {
 		return nil, errors.New("failed to pick control plane Machine to mark for deletion")
 	}
+
 	return machineToMark, nil
 }
 
@@ -153,6 +164,7 @@ func (c *ControlPlane) FailureDomainWithMostMachines(machines collections.Machin
 		// in the cluster status.
 		return notInFailureDomains.Oldest().Spec.FailureDomain
 	}
+
 	return capifd.PickMost(c.Cluster.Status.FailureDomains.FilterControlPlane(), c.Machines, machines)
 }
 
@@ -161,18 +173,21 @@ func (c *ControlPlane) NextFailureDomainForScaleUp() *string {
 	if len(c.Cluster.Status.FailureDomains.FilterControlPlane()) == 0 {
 		return nil
 	}
+
 	return capifd.PickFewest(c.FailureDomains().FilterControlPlane(), c.UpToDateMachines())
 }
 
 // InitialControlPlaneConfig returns a new RKE2ConfigSpec that is to be used for an initializing control plane.
 func (c *ControlPlane) InitialControlPlaneConfig() *bootstrapv1.RKE2ConfigSpec {
 	bootstrapSpec := c.RCP.Spec.RKE2ConfigSpec.DeepCopy()
+
 	return bootstrapSpec
 }
 
 // JoinControlPlaneConfig returns a new RKE2ConfigSpec that is to be used for joining control planes.
 func (c *ControlPlane) JoinControlPlaneConfig() *bootstrapv1.RKE2ConfigSpec {
 	bootstrapSpec := c.RCP.Spec.RKE2ConfigSpec.DeepCopy()
+
 	return bootstrapSpec
 }
 
@@ -197,6 +212,7 @@ func (c *ControlPlane) GenerateRKE2Config(spec *bootstrapv1.RKE2ConfigSpec) *boo
 		},
 		Spec: *spec,
 	}
+
 	return bootstrapConfig
 }
 
@@ -253,8 +269,6 @@ func (c *ControlPlane) MachinesNeedingRollout() collections.Machines {
 
 	// Return machines if they are scheduled for rollout or if with an outdated configuration.
 	return machines.AnyFilter(
-		// Machines that are scheduled for rollout (RCP.Spec.UpgradeAfter set, the UpgradeAfter deadline is expired, and the machine was created before the deadline).
-		// collections.ShouldRolloutAfter(&c.reconciliationTime, c.RCP.Spec.RolloutAfter), // TODO: Add rollout after field to RKE2ControlPlane if we want to support this.
 		// Machines that do not match with RCP config.
 		collections.Not(matchesRCPConfiguration(c.infraResources, c.rke2Configs, c.RCP)),
 	)
@@ -266,39 +280,50 @@ func (c *ControlPlane) UpToDateMachines() collections.Machines {
 	return c.Machines.Difference(c.MachinesNeedingRollout())
 }
 
-// getInfraResources fetches the external infrastructure resource for each machine in the collection and returns a map of machine.Name -> infraResource.
+// getInfraResources fetches the external infrastructure resource for each machine in the collection
+// and returns a map of machine.Name -> infraResource.
 func getInfraResources(ctx context.Context, cl client.Client, machines collections.Machines) (map[string]*unstructured.Unstructured, error) {
 	result := map[string]*unstructured.Unstructured{}
+
 	for _, m := range machines {
 		infraObj, err := external.Get(ctx, cl, &m.Spec.InfrastructureRef, m.Namespace)
 		if err != nil {
 			if apierrors.IsNotFound(errors.Cause(err)) {
 				continue
 			}
+
 			return nil, errors.Wrapf(err, "failed to retrieve infra obj for machine %q", m.Name)
 		}
+
 		result[m.Name] = infraObj
 	}
+
 	return result, nil
 }
 
 // getRKE2Configs fetches the RKE2 config for each machine in the collection and returns a map of machine.Name -> RKE2Config.
 func getRKE2Configs(ctx context.Context, cl client.Client, machines collections.Machines) (map[string]*bootstrapv1.RKE2Config, error) {
 	result := map[string]*bootstrapv1.RKE2Config{}
+
 	for _, m := range machines {
 		bootstrapRef := m.Spec.Bootstrap.ConfigRef
 		if bootstrapRef == nil {
 			continue
 		}
+
 		machineConfig := &bootstrapv1.RKE2Config{}
+
 		if err := cl.Get(ctx, client.ObjectKey{Name: bootstrapRef.Name, Namespace: m.Namespace}, machineConfig); err != nil {
 			if apierrors.IsNotFound(errors.Cause(err)) {
 				continue
 			}
+
 			return nil, errors.Wrapf(err, "failed to retrieve bootstrap config for machine %q", m.Name)
 		}
+
 		result[m.Name] = machineConfig
 	}
+
 	return result, nil
 }
 
@@ -317,8 +342,10 @@ func (c *ControlPlane) HasUnhealthyMachine() bool {
 	return len(c.UnhealthyMachines()) > 0
 }
 
+// PatchMachines patches the machines in the control plane.
 func (c *ControlPlane) PatchMachines(ctx context.Context) error {
 	errList := []error{}
+
 	for i := range c.Machines {
 		machine := c.Machines[i]
 		if helper, ok := c.machinesPatchHelpers[machine.Name]; ok {
@@ -328,9 +355,12 @@ func (c *ControlPlane) PatchMachines(ctx context.Context) error {
 			}}); err != nil {
 				errList = append(errList, errors.Wrapf(err, "failed to patch machine %s", machine.Name))
 			}
+
 			continue
 		}
+
 		errList = append(errList, errors.Errorf("failed to get patch helper for machine %s", machine.Name))
 	}
+
 	return kerrors.NewAggregate(errList)
 }
diff --git a/pkg/rke2/machine_filters.go b/pkg/rke2/machine_filters.go
index 790ae5e..50eec3d 100644
--- a/pkg/rke2/machine_filters.go
+++ b/pkg/rke2/machine_filters.go
@@ -5,6 +5,7 @@ import (
 	"reflect"
 
 	"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
+
 	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	"sigs.k8s.io/cluster-api/util/collections"
 
@@ -15,7 +16,11 @@ import (
 
 // matchesRCPConfiguration returns a filter to find all machines that matches with RCP config and do not require any rollout.
 // Kubernetes version, infrastructure template, and RKE2Config field need to be equivalent.
-func matchesRCPConfiguration(infraConfigs map[string]*unstructured.Unstructured, machineConfigs map[string]*bootstrapv1.RKE2Config, rcp *controlplanev1.RKE2ControlPlane) func(machine *clusterv1.Machine) bool {
+func matchesRCPConfiguration(
+	infraConfigs map[string]*unstructured.Unstructured,
+	machineConfigs map[string]*bootstrapv1.RKE2Config,
+	rcp *controlplanev1.RKE2ControlPlane,
+) func(machine *clusterv1.Machine) bool {
 	return collections.And(
 		matchesKubernetesVersion(rcp.Spec.AgentConfig.Version),
 		matchesRKE2BootstrapConfig(machineConfigs, rcp),
@@ -26,7 +31,6 @@ func matchesRCPConfiguration(infraConfigs map[string]*unstructured.Unstructured,
 // matchesRKE2BootstrapConfig checks if machine's RKE2ConfigSpec is equivalent with RCP's RKE2ConfigSpec.
 func matchesRKE2BootstrapConfig(machineConfigs map[string]*bootstrapv1.RKE2Config, rcp *controlplanev1.RKE2ControlPlane) collections.Func {
 	return func(machine *clusterv1.Machine) bool {
-
 		if machine == nil {
 			return true
 		}
@@ -55,7 +59,7 @@ func matchesRKE2BootstrapConfig(machineConfigs map[string]*bootstrapv1.RKE2Confi
 	}
 }
 
-// matchServerConfig checks if RKE2Configs in the ControlPlane object and the machine annotation match
+// matchServerConfig checks if RKE2Configs in the ControlPlane object and the machine annotation match.
 func matchServerConfig(rcp *controlplanev1.RKE2ControlPlane, machine *clusterv1.Machine) bool {
 	machineServerConfigStr, ok := machine.GetAnnotations()[controlplanev1.RKE2ServerConfigurationAnnotation]
 	if !ok {
@@ -80,16 +84,15 @@ func matchServerConfig(rcp *controlplanev1.RKE2ControlPlane, machine *clusterv1.
 
 	// Compare and return
 	return reflect.DeepEqual(machineServerConfig, rcpServerConfig)
-
 }
 
 // matchesTemplateClonedFrom returns a filter to find all machines that match a given RCP infra template.
 func matchesTemplateClonedFrom(infraConfigs map[string]*unstructured.Unstructured, rcp *controlplanev1.RKE2ControlPlane) collections.Func {
 	return func(machine *clusterv1.Machine) bool {
-
 		if machine == nil {
 			return false
 		}
+
 		infraObj, found := infraConfigs[machine.Name]
 		if !found {
 			// Return true here because failing to get infrastructure machine should not be considered as unmatching.
@@ -98,6 +101,7 @@ func matchesTemplateClonedFrom(infraConfigs map[string]*unstructured.Unstructure
 
 		clonedFromName, ok1 := infraObj.GetAnnotations()[clusterv1.TemplateClonedFromNameAnnotation]
 		clonedFromGroupKind, ok2 := infraObj.GetAnnotations()[clusterv1.TemplateClonedFromGroupKindAnnotation]
+
 		if !ok1 || !ok2 {
 			// All rcp cloned infra machines should have this annotation.
 			// Missing the annotation may be due to older version machines or adopted machines.
@@ -110,6 +114,7 @@ func matchesTemplateClonedFrom(infraConfigs map[string]*unstructured.Unstructure
 			clonedFromGroupKind != rcp.Spec.InfrastructureRef.GroupVersionKind().GroupKind().String() {
 			return false
 		}
+
 		return true
 	}
 }
@@ -120,6 +125,7 @@ func matchesKubernetesVersion(kubernetesVersion string) func(*clusterv1.Machine)
 		if machine == nil {
 			return false
 		}
+
 		if machine.Spec.Version == nil {
 			return false
 		}
@@ -128,6 +134,7 @@ func matchesKubernetesVersion(kubernetesVersion string) func(*clusterv1.Machine)
 		if err != nil {
 			return true
 		}
+
 		return bsutil.CompareVersions(*machine.Spec.Version, rcpKubeVersion)
 	}
 }
diff --git a/pkg/rke2/management_cluster.go b/pkg/rke2/management_cluster.go
index 6c78ce1..070b2df 100644
--- a/pkg/rke2/management_cluster.go
+++ b/pkg/rke2/management_cluster.go
@@ -22,12 +22,17 @@ import (
 
 	"github.com/pkg/errors"
 	"k8s.io/client-go/kubernetes/scheme"
+	ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
+	"sigs.k8s.io/controller-runtime/pkg/log"
+
 	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	"sigs.k8s.io/cluster-api/controllers/remote"
 	"sigs.k8s.io/cluster-api/util/collections"
+)
 
-	ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
-	"sigs.k8s.io/controller-runtime/pkg/log"
+const (
+	// DefaultWorkloadTimeout is the default timeout for the management cluster.
+	DefaultWorkloadTimeout = 30 * time.Second
 )
 
 // ManagementCluster defines all behaviors necessary for something to function as a management cluster.
@@ -43,7 +48,7 @@ type Management struct {
 	Client ctrlclient.Reader
 }
 
-// RemoteClusterConnectionError represents a failure to connect to a remote cluster
+// RemoteClusterConnectionError represents a failure to connect to a remote cluster.
 type RemoteClusterConnectionError struct {
 	Name string
 	Err  error
@@ -52,29 +57,37 @@ type RemoteClusterConnectionError struct {
 func (e *RemoteClusterConnectionError) Error() string { return e.Name + ": " + e.Err.Error() }
 func (e *RemoteClusterConnectionError) Unwrap() error { return e.Err }
 
-// Get implements ctrlclient.Reader
+// Get implements ctrlclient.Reader.
 func (m *Management) Get(ctx context.Context, key ctrlclient.ObjectKey, obj ctrlclient.Object, opts ...ctrlclient.GetOption) error {
 	return m.Client.Get(ctx, key, obj, opts...)
 }
 
-// List implements ctrlclient.Reader
+// List implements ctrlclient.Reader.
 func (m *Management) List(ctx context.Context, list ctrlclient.ObjectList, opts ...ctrlclient.ListOption) error {
 	return m.Client.List(ctx, list, opts...)
 }
 
 // GetMachinesForCluster returns a list of machines that can be filtered or not.
 // If no filter is supplied then all machines associated with the target cluster are returned.
-func (m *Management) GetMachinesForCluster(ctx context.Context, cluster ctrlclient.ObjectKey, filters ...collections.Func) (collections.Machines, error) {
+func (m *Management) GetMachinesForCluster(
+	ctx context.Context,
+	cluster ctrlclient.ObjectKey,
+	filters ...collections.Func,
+) (collections.Machines, error) {
 	logger := log.FromContext(ctx)
 	selector := map[string]string{
 		clusterv1.ClusterLabelName: cluster.Name,
 	}
 	ml := &clusterv1.MachineList{}
+
 	logger.V(5).Info("Getting List of machines for Cluster")
+
 	if err := m.Client.List(ctx, ml, ctrlclient.InNamespace(cluster.Namespace), ctrlclient.MatchingLabels(selector)); err != nil {
 		return nil, errors.Wrap(err, "failed to list machines")
 	}
+
 	logger.V(5).Info("End of listing machines for cluster")
+
 	machines := collections.FromMachineList(ml)
 
 	return machines.Filter(filters...), nil
@@ -92,7 +105,8 @@ func (m *Management) GetWorkloadCluster(ctx context.Context, clusterKey ctrlclie
 	if err != nil {
 		return nil, err
 	}
-	restConfig.Timeout = 30 * time.Second
+
+	restConfig.Timeout = DefaultWorkloadTimeout
 
 	c, err := ctrlclient.New(restConfig, ctrlclient.Options{Scheme: scheme.Scheme})
 	if err != nil {
diff --git a/pkg/rke2/registries.go b/pkg/rke2/registries.go
index ab56111..8f54b83 100644
--- a/pkg/rke2/registries.go
+++ b/pkg/rke2/registries.go
@@ -24,17 +24,19 @@ import (
 )
 
 const (
+	// DefaultRKE2RegistriesLocation is the default location for the registries.yaml file.
 	DefaultRKE2RegistriesLocation string = "/etc/rancher/rke2/registries.yaml"
-	registryCertsPath             string = "/etc/rancher/rke2/tls"
+
+	registryCertsPath string = "/etc/rancher/rke2/tls"
 )
 
 // GenerateRegistries generates the registries.yaml file and the corresponding
 // files for the TLS certificates.
-func GenerateRegistries(rke2ConfigRegistry RKE2ConfigRegistry) (*Registry, []bootstrapv1.File, error) {
-
+func GenerateRegistries(rke2ConfigRegistry RegistryScope) (*Registry, []bootstrapv1.File, error) {
 	registry := &Registry{}
 	files := []bootstrapv1.File{}
 	registry.Mirrors = make(map[string]Mirror)
+
 	for mirrorName, mirror := range rke2ConfigRegistry.Registry.Mirrors {
 		registry.Mirrors[mirrorName] = Mirror{
 			Endpoint: mirror.Endpoint,
@@ -45,6 +47,7 @@ func GenerateRegistries(rke2ConfigRegistry RKE2ConfigRegistry) (*Registry, []boo
 	for configName, regConfig := range rke2ConfigRegistry.Registry.Configs {
 		tlsSecret := corev1.Secret{}
 		authSecret := corev1.Secret{}
+
 		err := rke2ConfigRegistry.Client.Get(
 			rke2ConfigRegistry.Ctx,
 			types.NamespacedName{
@@ -53,17 +56,19 @@ func GenerateRegistries(rke2ConfigRegistry RKE2ConfigRegistry) (*Registry, []boo
 			},
 			&tlsSecret,
 		)
-
 		if err != nil {
 			rke2ConfigRegistry.Logger.Error(err, "TLS Config Secret for the registry was not found!")
+
 			return &Registry{}, []bootstrapv1.File{}, err
 		}
 
 		for _, secretEntry := range []string{"tls.crt", "tls.key", "ca.crt"} {
 			if tlsSecret.Data[secretEntry] == nil {
 				rke2ConfigRegistry.Logger.Error(err, "TLS Config Secret for the registry is missing entries!", "secret-missing-entry", secretEntry)
+
 				return &Registry{}, []bootstrapv1.File{}, err
 			}
+
 			files = append(files, bootstrapv1.File{
 				Path:    registryCertsPath + "/" + secretEntry,
 				Content: string(tlsSecret.Data[secretEntry]),
@@ -81,6 +86,7 @@ func GenerateRegistries(rke2ConfigRegistry RKE2ConfigRegistry) (*Registry, []boo
 
 		if err != nil {
 			rke2ConfigRegistry.Logger.Error(err, "Auth Config Secret for the registry was not found!")
+
 			return &Registry{}, []bootstrapv1.File{}, err
 		}
 
@@ -90,7 +96,11 @@ func GenerateRegistries(rke2ConfigRegistry RKE2ConfigRegistry) (*Registry, []boo
 		ok := isBasicAuth || isTokenAuth
 
 		if !ok {
-			rke2ConfigRegistry.Logger.Error(err, "Auth Secret for the registry is missing entries! Possible entries are: (\"username\" AND \"password\") OR \"identity-token\" ", "secret-entries", bsutil.GetMapKeysAsString(authSecret.Data))
+			rke2ConfigRegistry.Logger.Error(
+				err,
+				"Auth Secret for the registry is missing entries! Possible entries are: (\"username\" AND \"password\") OR \"identity-token\" ",
+				"secret-entries", bsutil.GetMapKeysAsString(authSecret.Data))
+
 			return &Registry{}, []bootstrapv1.File{}, err
 		}
 
@@ -99,6 +109,7 @@ func GenerateRegistries(rke2ConfigRegistry RKE2ConfigRegistry) (*Registry, []boo
 			authData.Username = string(authSecret.Data["username"])
 			authData.Password = string(authSecret.Data["password"])
 		}
+
 		if isTokenAuth {
 			authData.IdentityToken = string(authSecret.Data["identity-token"])
 		}
@@ -116,5 +127,4 @@ func GenerateRegistries(rke2ConfigRegistry RKE2ConfigRegistry) (*Registry, []boo
 	}
 
 	return registry, files, nil
-
 }
diff --git a/pkg/rke2/registries_types.go b/pkg/rke2/registries_types.go
index 9c7bcca..b05bde4 100644
--- a/pkg/rke2/registries_types.go
+++ b/pkg/rke2/registries_types.go
@@ -19,11 +19,12 @@ import (
 	"context"
 
 	"github.com/go-logr/logr"
-	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
 	"sigs.k8s.io/controller-runtime/pkg/client"
+
+	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
 )
 
-// Mirror contains the config related to the registry mirror
+// Mirror contains the config related to the registry mirror.
 type Mirror struct {
 	// Endpoints are endpoints for a namespace. CRI plugin will try the endpoints
 	// one by one until a working one is found. The endpoint must be a valid url
@@ -37,7 +38,7 @@ type Mirror struct {
 	Rewrite map[string]string `toml:"rewrite" yaml:"rewrite,omitempty"`
 }
 
-// AuthConfig contains the config related to authentication to a specific registry
+// AuthConfig contains the config related to authentication to a specific registry.
 type AuthConfig struct {
 	// Username is the username to login the registry.
 	Username string `toml:"username" yaml:"username,omitempty"`
@@ -51,7 +52,7 @@ type AuthConfig struct {
 	IdentityToken string `toml:"identitytoken" yaml:"identity_token,omitempty"`
 }
 
-// TLSConfig contains the CA/Cert/Key used for a registry
+// TLSConfig contains the CA/Cert/Key used for a registry.
 type TLSConfig struct {
 	CAFile             string `toml:"ca_file" yaml:"ca_file"`
 	CertFile           string `toml:"cert_file" yaml:"cert_file"`
@@ -59,7 +60,7 @@ type TLSConfig struct {
 	InsecureSkipVerify bool   `toml:"insecure_skip_verify" yaml:"insecure_skip_verify"`
 }
 
-// Registry is registry settings including mirrors, TLS, and credentials
+// Registry is registry settings including mirrors, TLS, and credentials.
 type Registry struct {
 	// Mirrors are namespace to mirror mapping for all namespaces.
 	Mirrors map[string]Mirror `toml:"mirrors" yaml:"mirrors"`
@@ -77,9 +78,9 @@ type RegistryConfig struct {
 	TLS *TLSConfig `toml:"tls" yaml:"tls,omitempty"`
 }
 
-// RKE2ConfigRegistry is a wrapper around the Registry struct to provide
-// the client, context and a logger to the Registry struct
-type RKE2ConfigRegistry struct {
+// RegistryScope is a wrapper around the Registry struct to provide
+// the client, context and a logger to the Registry struct.
+type RegistryScope struct {
 	Registry bootstrapv1.Registry
 	Client   client.Client
 	Ctx      context.Context
diff --git a/pkg/rke2/workload_cluster.go b/pkg/rke2/workload_cluster.go
index a27e7fd..f2a20e6 100644
--- a/pkg/rke2/workload_cluster.go
+++ b/pkg/rke2/workload_cluster.go
@@ -22,31 +22,28 @@ import (
 	"strings"
 
 	"github.com/pkg/errors"
-	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
 	corev1 "k8s.io/api/core/v1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/util/sets"
+	ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
+
 	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	"sigs.k8s.io/cluster-api/util"
 	"sigs.k8s.io/cluster-api/util/collections"
 	"sigs.k8s.io/cluster-api/util/conditions"
-	ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
+
+	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
 )
 
 const (
-	kubeProxyKey              = "kube-proxy"
-	rke2ConfigKey             = "rke2-config"
 	labelNodeRoleControlPlane = "node-role.kubernetes.io/master"
 )
 
-var (
-	ErrControlPlaneMinNodes = errors.New("cluster has fewer than 2 control plane nodes; removing an etcd member is not supported")
-)
+// ErrControlPlaneMinNodes is returned when the control plane has fewer than 2 nodes.
+var ErrControlPlaneMinNodes = errors.New("cluster has fewer than 2 control plane nodes; removing an etcd member is not supported")
 
-// WorkloadCluster defines all behaviors necessary to upgrade kubernetes on a workload cluster
-//
-// TODO: Add a detailed description to each of these method definitions.
+// WorkloadCluster defines all behaviors necessary to upgrade kubernetes on a workload cluster.
 type WorkloadCluster interface {
 	// Basic health and status checks.
 	ClusterStatus(ctx context.Context) (ClusterStatus, error)
@@ -66,7 +63,6 @@ type WorkloadCluster interface {
 // Workload defines operations on workload clusters.
 type Workload struct {
 	Client ctrlclient.Client
-	//etcdClientGenerator etcdClientFor
 }
 
 // ClusterStatus holds stats information about the cluster.
@@ -82,9 +78,11 @@ func (w *Workload) getControlPlaneNodes(ctx context.Context) (*corev1.NodeList,
 	labels := map[string]string{
 		labelNodeRoleControlPlane: "true",
 	}
+
 	if err := w.Client.List(ctx, nodes, ctrlclient.MatchingLabels(labels)); err != nil {
 		return nil, err
 	}
+
 	return nodes, nil
 }
 
@@ -101,6 +99,7 @@ func (w *Workload) ClusterStatus(ctx context.Context) (ClusterStatus, error) {
 	for _, node := range nodes.Items {
 		nodeCopy := node
 		status.Nodes++
+
 		if util.IsNodeReady(&nodeCopy) {
 			status.ReadyNodes++
 		}
@@ -115,6 +114,7 @@ func hasProvisioningMachine(machines collections.Machines) bool {
 			return true
 		}
 	}
+
 	return false
 }
 
@@ -125,6 +125,7 @@ func nodeHasUnreachableTaint(node corev1.Node) bool {
 			return true
 		}
 	}
+
 	return false
 }
 
@@ -136,22 +137,14 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 		controlplanev1.MachineAgentHealthyCondition,
 	}
 
-	/** TODO: figure out etcd
-	if controlPlane.IsEtcdManaged() {
-		allMachinePodConditions = append(allMachinePodConditions, controlplanev1.MachineEtcdPodHealthyCondition)
-	}
-	**/
-
 	// NOTE: this fun uses control plane nodes from the workload cluster as a source of truth for the current state.
 	controlPlaneNodes, err := w.getControlPlaneNodes(ctx)
 	if err != nil {
-		//for i := range controlPlane.Machines {
-		//machine := controlPlane.Machines[i]
-		//for _, condition := range allMachinePodConditions {
-		//conditions.MarkUnknown(machine, condition, controlplanev1.PodInspectionFailedReason, "Failed to get the node which is hosting this component")
-		//}
-		//}
-		conditions.MarkUnknown(controlPlane.RCP, controlplanev1.ControlPlaneComponentsHealthyCondition, controlplanev1.ControlPlaneComponentsInspectionFailedReason, "Failed to list nodes which are hosting control plane components")
+		conditions.MarkUnknown(
+			controlPlane.RCP,
+			controlplanev1.ControlPlaneComponentsHealthyCondition,
+			controlplanev1.ControlPlaneComponentsInspectionFailedReason, "Failed to list nodes which are hosting control plane components")
+
 		return
 	}
 
@@ -161,9 +154,11 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 	for _, node := range controlPlaneNodes.Items {
 		// Search for the machine corresponding to the node.
 		var machine *clusterv1.Machine
+
 		for _, m := range controlPlane.Machines {
 			if m.Status.NodeRef != nil && m.Status.NodeRef.Name == node.Name {
 				machine = m
+
 				break
 			}
 		}
@@ -175,7 +170,9 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 			if hasProvisioningMachine(controlPlane.Machines) {
 				continue
 			}
+
 			rcpErrors = append(rcpErrors, fmt.Sprintf("Control plane node %s does not have a corresponding machine", node.Name))
+
 			continue
 		}
 
@@ -184,6 +181,7 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 			for _, condition := range allMachinePodConditions {
 				conditions.MarkFalse(machine, condition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "")
 			}
+
 			continue
 		}
 
@@ -194,6 +192,7 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 			for _, condition := range allMachinePodConditions {
 				conditions.MarkUnknown(machine, condition, controlplanev1.PodInspectionFailedReason, "Node is unreachable")
 			}
+
 			continue
 		}
 
@@ -206,11 +205,19 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 		if err := w.Client.Get(ctx, nodeKey, &targetnode); err != nil {
 			// If there is an error getting the Pod, do not set any conditions.
 			if apierrors.IsNotFound(err) {
-				conditions.MarkFalse(machine, controlplanev1.MachineAgentHealthyCondition, controlplanev1.PodMissingReason, clusterv1.ConditionSeverityError, "Node %s is missing", nodeKey.Name)
+				conditions.MarkFalse(machine,
+					controlplanev1.MachineAgentHealthyCondition,
+					controlplanev1.PodMissingReason,
+					clusterv1.ConditionSeverityError,
+					"Node %s is missing", nodeKey.Name)
 
 				return
 			}
-			conditions.MarkUnknown(machine, controlplanev1.MachineAgentHealthyCondition, controlplanev1.PodInspectionFailedReason, "Failed to get node status")
+
+			conditions.MarkUnknown(machine,
+				controlplanev1.MachineAgentHealthyCondition,
+				controlplanev1.PodInspectionFailedReason, "Failed to get node status")
+
 			return
 		}
 
@@ -219,7 +226,6 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 				conditions.MarkTrue(machine, controlplanev1.MachineAgentHealthyCondition)
 			}
 		}
-
 	}
 
 	// If there are provisioned machines without corresponding nodes, report this as a failing conditions with SeverityError.
@@ -228,13 +234,17 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 		if machine.Status.NodeRef == nil {
 			continue
 		}
+
 		found := false
+
 		for _, node := range controlPlaneNodes.Items {
 			if machine.Status.NodeRef.Name == node.Name {
 				found = true
+
 				break
 			}
 		}
+
 		if !found {
 			for _, condition := range allMachinePodConditions {
 				conditions.MarkFalse(machine, condition, controlplanev1.PodFailedReason, clusterv1.ConditionSeverityError, "Missing node")
@@ -254,14 +264,6 @@ func (w *Workload) UpdateAgentConditions(ctx context.Context, controlPlane *Cont
 	})
 }
 
-// updateStaticPodCondition is responsible for updating machine conditions reflecting the status of a component running
-// in a static pod generated by RKE2. This operation is best effort, in the sense that in case of problems
-// in retrieving the pod status, it sets the condition to Unknown state without returning any error.
-//func (w *Workload) updateStaticPodCondition(ctx context.Context, machine *clusterv1.Machine, node corev1.Node, component string, staticPodCondition clusterv1.ConditionType) {
-//// not really needed for rke2 so just set true
-//conditions.MarkTrue(machine, staticPodCondition)
-//}
-
 type aggregateFromMachinesToRCPInput struct {
 	controlPlane      *ControlPlane
 	machineConditions []clusterv1.ConditionType
@@ -309,39 +311,68 @@ func aggregateFromMachinesToRCP(input aggregateFromMachinesToRCPInput) {
 
 	// In case of at least one machine with errors or RCP level errors (nodes without machines), report false, error.
 	if len(rcpMachinesWithErrors) > 0 {
-		input.rcpErrors = append(input.rcpErrors, fmt.Sprintf("Following machines are reporting %s errors: %s", input.note, strings.Join(rcpMachinesWithErrors.List(), ", ")))
+		input.rcpErrors = append(
+			input.rcpErrors,
+			fmt.Sprintf("Following machines are reporting %s errors: %s",
+				input.note,
+				strings.Join(rcpMachinesWithErrors.List(), ", ")))
 	}
+
 	if len(input.rcpErrors) > 0 {
-		conditions.MarkFalse(input.controlPlane.RCP, input.condition, input.unhealthyReason, clusterv1.ConditionSeverityError, strings.Join(input.rcpErrors, "; "))
+		conditions.MarkFalse(
+			input.controlPlane.RCP,
+			input.condition,
+			input.unhealthyReason,
+			clusterv1.ConditionSeverityError,
+			strings.Join(input.rcpErrors, "; "))
+
 		return
 	}
 
 	// In case of no errors and at least one machine with warnings, report false, warnings.
 	if len(rcpMachinesWithWarnings) > 0 {
-		conditions.MarkFalse(input.controlPlane.RCP, input.condition, input.unhealthyReason, clusterv1.ConditionSeverityWarning, "Following machines are reporting %s warnings: %s", input.note, strings.Join(rcpMachinesWithWarnings.List(), ", "))
+		conditions.MarkFalse(
+			input.controlPlane.RCP,
+			input.condition,
+			input.unhealthyReason,
+			clusterv1.ConditionSeverityWarning,
+			"Following machines are reporting %s warnings: %s",
+			input.note,
+			strings.Join(rcpMachinesWithWarnings.List(), ", "))
+
 		return
 	}
 
 	// In case of no errors, no warning, and at least one machine with info, report false, info.
 	if len(rcpMachinesWithWarnings) > 0 {
-		conditions.MarkFalse(input.controlPlane.RCP, input.condition, input.unhealthyReason, clusterv1.ConditionSeverityWarning, "Following machines are reporting %s info: %s", input.note, strings.Join(rcpMachinesWithInfo.List(), ", "))
+		conditions.MarkFalse(
+			input.controlPlane.RCP,
+			input.condition,
+			input.unhealthyReason,
+			clusterv1.ConditionSeverityWarning,
+			"Following machines are reporting %s info: %s",
+			input.note, strings.Join(rcpMachinesWithInfo.List(), ", "))
+
 		return
 	}
 
 	// In case of no errors, no warning, no Info, and at least one machine with true conditions, report true.
 	if len(rcpMachinesWithTrue) > 0 {
 		conditions.MarkTrue(input.controlPlane.RCP, input.condition)
+
 		return
 	}
 
 	// Otherwise, if there is at least one machine with unknown, report unknown.
 	if len(rcpMachinesWithUnknown) > 0 {
-		conditions.MarkUnknown(input.controlPlane.RCP, input.condition, input.unknownReason, "Following machines are reporting unknown %s status: %s", input.note, strings.Join(rcpMachinesWithUnknown.List(), ", "))
+		conditions.MarkUnknown(
+			input.controlPlane.RCP,
+			input.condition,
+			input.unknownReason,
+			"Following machines are reporting unknown %s status: %s", input.note, strings.Join(rcpMachinesWithUnknown.List(), ", "))
+
 		return
 	}
-
-	// This last case should happen only if there are no provisioned machines, and thus without conditions.
-	// So there will be no condition at RCP level too.
 }
 
 // UpdateEtcdConditions is responsible for updating machine conditions reflecting the status of all the etcd members.
@@ -356,15 +387,23 @@ func (w *Workload) updateManagedEtcdConditions(ctx context.Context, controlPlane
 	// as ultimate source of truth for the list of members and for their health.
 	controlPlaneNodes, err := w.getControlPlaneNodes(ctx)
 	if err != nil {
-		conditions.MarkUnknown(controlPlane.RCP, controlplanev1.EtcdClusterHealthyCondition, controlplanev1.EtcdClusterInspectionFailedReason, "Failed to list nodes which are hosting the etcd members")
+		conditions.MarkUnknown(
+			controlPlane.RCP,
+			controlplanev1.EtcdClusterHealthyCondition,
+			controlplanev1.EtcdClusterInspectionFailedReason, "Failed to list nodes which are hosting the etcd members")
+
 		for _, m := range controlPlane.Machines {
-			conditions.MarkUnknown(m, controlplanev1.MachineEtcdMemberHealthyCondition, controlplanev1.EtcdMemberInspectionFailedReason, "Failed to get the node which is hosting the etcd member")
+			conditions.MarkUnknown(m,
+				controlplanev1.MachineEtcdMemberHealthyCondition,
+				controlplanev1.EtcdMemberInspectionFailedReason, "Failed to get the node which is hosting the etcd member")
 		}
+
 		return
 	}
 
 	for _, node := range controlPlaneNodes.Items {
 		var machine *clusterv1.Machine
+
 		for _, m := range controlPlane.Machines {
 			if m.Status.NodeRef != nil && m.Status.NodeRef.Name == node.Name {
 				machine = m
@@ -377,16 +416,17 @@ func (w *Workload) updateManagedEtcdConditions(ctx context.Context, controlPlane
 			if hasProvisioningMachine(controlPlane.Machines) {
 				continue
 			}
+
 			continue
 		}
 
 		// If the machine is deleting, report all the conditions as deleting
 		if !machine.ObjectMeta.DeletionTimestamp.IsZero() {
 			conditions.MarkFalse(machine, controlplanev1.MachineEtcdMemberHealthyCondition, clusterv1.DeletingReason, clusterv1.ConditionSeverityInfo, "")
+
 			continue
 		}
 
 		conditions.MarkTrue(machine, controlplanev1.MachineEtcdMemberHealthyCondition)
 	}
-
 }
diff --git a/pkg/secret/certificates.go b/pkg/secret/certificates.go
index bfa82a6..8e8ff9f 100644
--- a/pkg/secret/certificates.go
+++ b/pkg/secret/certificates.go
@@ -40,7 +40,7 @@ import (
 )
 
 const (
-	// rootOwnerValue is the Certificate Root Owner for creating new Certificate Authority
+	// rootOwnerValue is the Certificate Root Owner for creating new Certificate Authority.
 	rootOwnerValue = "root:root"
 
 	// DefaultCertificatesDir is the default location (file path) where the provider will put the certificates, this location will then
@@ -50,10 +50,10 @@ const (
 	// Kubeconfig is the secret name suffix storing the Cluster Kubeconfig.
 	Kubeconfig = Purpose("kubeconfig")
 
-	// KubeconfigDataName is the data entry name for the Kubeconfig file content
+	// KubeconfigDataName is the data entry name for the Kubeconfig file content.
 	KubeconfigDataName string = "value"
 
-	// EtcdCA is the secret name suffix for the Etcd CA
+	// EtcdCA is the secret name suffix for the Etcd CA.
 	EtcdCA Purpose = "etcd"
 
 	// ClusterCA is the secret name suffix for APIServer CA.
@@ -68,11 +68,14 @@ const (
 	// TLSCrtDataName is the key used to store a TLS certificate in the secret's data field.
 	TLSCrtDataName = "tls.crt"
 
-	// APIServerEtcdClient is the secret name of user-supplied secret containing the apiserver-etcd-client key/cert
+	// APIServerEtcdClient is the secret name of user-supplied secret containing the apiserver-etcd-client key/cert.
 	APIServerEtcdClient Purpose = "apiserver-etcd-client"
 
-	// ServiceAccount is the secret name suffix for the Service Account keys
+	// ServiceAccount is the secret name suffix for the Service Account keys.
 	ServiceAccount Purpose = "sa"
+
+	// TenYears is the duration of one year.
+	TenYears = time.Hour * 24 * 365 * 10
 )
 
 // Purpose is the name to append to the secret generated for a cluster.
@@ -90,7 +93,7 @@ type Certificate struct {
 // Certificates are the certificates necessary to bootstrap a cluster.
 type Certificates []*Certificate
 
-// NewCertificatesForInitialControlPlane returns a list of certificates configured for a control plane node
+// NewCertificatesForInitialControlPlane returns a list of certificates configured for a control plane node.
 func NewCertificatesForInitialControlPlane() Certificates {
 	certificatesDir := DefaultCertificatesDir
 
@@ -118,6 +121,7 @@ func (c Certificates) GetByPurpose(purpose Purpose) *Certificate {
 			return certificate
 		}
 	}
+
 	return nil
 }
 
@@ -130,13 +134,16 @@ func (c Certificates) Lookup(ctx context.Context, ctrlclient client.Client, clus
 			Name:      Name(clusterName.Name, certificate.Purpose),
 			Namespace: clusterName.Namespace,
 		}
+
 		if err := ctrlclient.Get(ctx, key, s); err != nil {
 			if apierrors.IsNotFound(err) {
 				if certificate.External {
 					return errors.WithMessage(err, "external certificate not found")
 				}
+
 				continue
 			}
+
 			return errors.WithStack(err)
 		}
 		// If a user has a badly formatted secret it will prevent the cluster from working.
@@ -144,11 +151,14 @@ func (c Certificates) Lookup(ctx context.Context, ctrlclient client.Client, clus
 		if err != nil {
 			return err
 		}
+
 		certificate.KeyPair = kp
 	}
+
 	return nil
 }
 
+// Generate will generate any certificates that do not have KeyPair data.
 func (c *Certificate) Generate() error {
 	// Do not generate the APIServerEtcdClient key pair. It is user supplied
 	if c.Purpose == APIServerEtcdClient {
@@ -164,6 +174,7 @@ func (c *Certificate) Generate() error {
 	if err != nil {
 		return err
 	}
+
 	c.KeyPair = kp
 	c.Generated = true
 
@@ -180,6 +191,7 @@ func (c Certificates) Generate() error {
 			}
 		}
 	}
+
 	return nil
 }
 
@@ -189,16 +201,23 @@ func (c Certificates) SaveGenerated(ctx context.Context, ctrlclient client.Clien
 		if !certificate.Generated {
 			continue
 		}
+
 		s := certificate.AsSecret(clusterName, owner)
 		if err := ctrlclient.Create(ctx, s); err != nil {
 			return errors.WithStack(err)
 		}
 	}
+
 	return nil
 }
 
 // LookupOrGenerate is a convenience function that wraps cluster bootstrap certificate behavior.
-func (c Certificates) LookupOrGenerate(ctx context.Context, ctrlclient client.Client, clusterName client.ObjectKey, owner metav1.OwnerReference) error {
+func (c Certificates) LookupOrGenerate(
+	ctx context.Context,
+	ctrlclient client.Client,
+	clusterName client.ObjectKey,
+	owner metav1.OwnerReference,
+) error {
 	// Find the certificates that exist
 	if err := c.Lookup(ctx, ctrlclient, clusterName); err != nil {
 		return err
@@ -237,6 +256,7 @@ func (c *Certificate) AsSecret(clusterName client.ObjectKey, owner metav1.OwnerR
 	if c.Generated {
 		s.OwnerReferences = []metav1.OwnerReference{owner}
 	}
+
 	return s
 }
 
@@ -251,6 +271,7 @@ func (c *Certificate) AsFiles() []bootstrapv1.File {
 			Content:     string(c.KeyPair.Cert),
 		})
 	}
+
 	if len(c.KeyPair.Key) > 0 {
 		out = append(out, bootstrapv1.File{
 			Path:        c.KeyFile,
@@ -259,6 +280,7 @@ func (c *Certificate) AsFiles() []bootstrapv1.File {
 			Content:     string(c.KeyPair.Key),
 		})
 	}
+
 	return out
 }
 
@@ -278,9 +300,11 @@ func (c Certificates) AsFiles() []bootstrapv1.File {
 	if clusterCA != nil {
 		certFiles = append(certFiles, clusterCA.AsFiles()...)
 	}
+
 	if clientClusterCA != nil {
 		certFiles = append(certFiles, clientClusterCA.AsFiles()...)
 	}
+
 	if etcdCA != nil {
 		certFiles = append(certFiles, etcdCA.AsFiles()...)
 	}
@@ -294,7 +318,7 @@ func (c Certificates) AsFiles() []bootstrapv1.File {
 	return certFiles
 }
 
-// secretToKeyPair gets a Certificate Keypair from a data entry in a secret
+// secretToKeyPair gets a Certificate Keypair from a data entry in a secret.
 func secretToKeyPair(s *corev1.Secret) (*certs.KeyPair, error) {
 	c, exists := s.Data[TLSCrtDataName]
 	if !exists {
@@ -302,7 +326,6 @@ func secretToKeyPair(s *corev1.Secret) (*certs.KeyPair, error) {
 	}
 
 	// In some cases (external etcd) it's ok if the etcd.key does not exist.
-	// TODO: some other function should ensure that the certificates we need exist.
 	key, exists := s.Data[TLSKeyDataName]
 	if !exists {
 		key = []byte("")
@@ -319,13 +342,14 @@ func generateCACert() (*certs.KeyPair, error) {
 	if err != nil {
 		return nil, err
 	}
+
 	return &certs.KeyPair{
 		Cert: certs.EncodeCertPEM(x509Cert),
 		Key:  certs.EncodePrivateKeyPEM(privKey),
 	}, nil
 }
 
-// newCertificateAuthority creates new certificate and private key for the certificate authority
+// newCertificateAuthority creates new certificate and private key for the certificate authority.
 func newCertificateAuthority() (*x509.Certificate, *rsa.PrivateKey, error) {
 	key, err := certs.NewPrivateKey()
 	if err != nil {
@@ -355,7 +379,7 @@ func newSelfSignedCACert(key *rsa.PrivateKey) (*x509.Certificate, error) {
 			Organization: cfg.Organization,
 		},
 		NotBefore:             now.Add(time.Minute * -5),
-		NotAfter:              now.Add(time.Hour * 24 * 365 * 10), // 10 years
+		NotAfter:              now.Add(TenYears), // 10 years
 		KeyUsage:              x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
 		MaxPathLenZero:        true,
 		BasicConstraintsValid: true,
@@ -369,6 +393,7 @@ func newSelfSignedCACert(key *rsa.PrivateKey) (*x509.Certificate, error) {
 	}
 
 	c, err := x509.ParseCertificate(b)
+
 	return c, errors.WithStack(err)
 }
 
@@ -377,10 +402,12 @@ func generateServiceAccountKeys() (*certs.KeyPair, error) {
 	if err != nil {
 		return nil, err
 	}
+
 	saPub, err := certs.EncodePublicKeyPEM(&saCreds.PublicKey)
 	if err != nil {
 		return nil, err
 	}
+
 	return &certs.KeyPair{
 		Cert: saPub,
 		Key:  certs.EncodePrivateKeyPEM(saCreds),
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 5473b54..12285bc 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -23,96 +23,122 @@ import (
 	"fmt"
 	"regexp"
 
-	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	"sigs.k8s.io/controller-runtime/pkg/client"
 	"sigs.k8s.io/controller-runtime/pkg/log"
+
+	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
+
+	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
 )
 
+// ErrControlPlaneNotFound is returned when a control plane is not found.
+var ErrControlPlaneNotFound = fmt.Errorf("control plane not found")
+
+// GetOwnerControlPlane returns the RKE2ControlPlane object that owns the object passed as parameter.
 func GetOwnerControlPlane(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*controlplanev1.RKE2ControlPlane, error) {
 	logger := log.FromContext(ctx)
 
 	ownerRefs := obj.OwnerReferences
+
 	var cpOwnerRef metav1.OwnerReference
+
 	for _, ownerRef := range ownerRefs {
-		logger.V(5).Info("Inside GetOwnerControlPlane", "ownerRef.APIVersion", ownerRef.APIVersion, "ownerRef.Kind", ownerRef.Kind, "cpv1.GroupVersion.Group", controlplanev1.GroupVersion.Group)
+		logger.V(5).Info(
+			"Inside GetOwnerControlPlane",
+			"ownerRef.APIVersion", ownerRef.APIVersion,
+			"ownerRef.Kind", ownerRef.Kind,
+			"cpv1.GroupVersion.Group", controlplanev1.GroupVersion.Group)
+
 		if ownerRef.APIVersion == controlplanev1.GroupVersion.Group+"/"+controlplanev1.GroupVersion.Version && ownerRef.Kind == "RKE2ControlPlane" {
 			cpOwnerRef = ownerRef
 		}
 	}
 
 	logger.V(5).Info("GetOwnerControlPlane result:", "cpOwnerRef", cpOwnerRef)
+
 	if (cpOwnerRef != metav1.OwnerReference{}) {
 		return GetControlPlaneByName(ctx, c, obj.Namespace, cpOwnerRef.Name)
 	}
 
-	return nil, nil
+	return nil, ErrControlPlaneNotFound
 }
 
 // GetControlPlaneByName finds and return a ControlPlane object using the specified params.
 func GetControlPlaneByName(ctx context.Context, c client.Client, namespace, name string) (*controlplanev1.RKE2ControlPlane, error) {
 	m := &controlplanev1.RKE2ControlPlane{}
+
 	key := client.ObjectKey{Name: name, Namespace: namespace}
 	if err := c.Get(ctx, key, m); err != nil {
 		return nil, err
 	}
+
 	return m, nil
 }
 
 // GetClusterByName finds and return a Cluster object using the specified params.
 func GetClusterByName(ctx context.Context, c client.Client, namespace, name string) (*clusterv1.Cluster, error) {
 	m := &clusterv1.Cluster{}
+
 	key := client.ObjectKey{Name: name, Namespace: namespace}
 	if err := c.Get(ctx, key, m); err != nil {
 		return nil, err
 	}
+
 	return m, nil
 }
 
-// Random generates a random string with length size
+// Random generates a random string with length size.
 func Random(size int) (string, error) {
 	token := make([]byte, size)
+
 	_, err := rand.Read(token)
 	if err != nil {
 		return "", err
 	}
+
 	return hex.EncodeToString(token), err
 }
 
-// TokenName returns a token name from the cluster name
+// TokenName returns a token name from the cluster name.
 func TokenName(clusterName string) string {
 	return fmt.Sprintf("%s-token", clusterName)
 }
 
-// Rke2ToKubeVersion converts an RKE2 version to a Kubernetes version
+// Rke2ToKubeVersion converts an RKE2 version to a Kubernetes version.
 func Rke2ToKubeVersion(rk2Version string) (kubeVersion string, err error) {
-	var regexStr string = "v(\\d\\.\\d{2}\\.\\d)\\+rke2r\\d"
+	regexStr := "v(\\d\\.\\d{2}\\.\\d)\\+rke2r\\d"
+
 	var regex *regexp.Regexp
+
 	regex, err = regexp.Compile(regexStr)
 	if err != nil {
 		return "", err
 	}
+
 	kubeVersion = string(regex.ReplaceAll([]byte(rk2Version), []byte("$1")))
 
 	return kubeVersion, nil
 }
 
-// AppendIfNotPresent appends a string to a slice only if the value does not already exist
+// AppendIfNotPresent appends a string to a slice only if the value does not already exist.
 func AppendIfNotPresent(origSlice []string, strItem string) (resultSlice []string) {
 	present := false
+
 	for _, item := range origSlice {
 		if item == strItem {
 			present = true
 		}
 	}
+
 	if !present {
 		return append(origSlice, strItem)
 	}
+
 	return origSlice
 }
 
-// CompareVersions compares two string version supposing those would begin with 'v' or not
+// CompareVersions compares two string version supposing those would begin with 'v' or not.
 func CompareVersions(v1 string, v2 string) bool {
 	if string(v1[0]) != "v" {
 		v1 = "v" + v1
@@ -121,15 +147,17 @@ func CompareVersions(v1 string, v2 string) bool {
 	if string(v2[0]) != "v" {
 		v2 = "v" + v2
 	}
+
 	return v1 == v2
 }
 
-// GetMapKeysAsString returns a comma separated string of keys from a map
+// GetMapKeysAsString returns a comma separated string of keys from a map.
 func GetMapKeysAsString(m map[string][]byte) (keys string) {
 	for k := range m {
 		keys = keys + k + ","
 	}
 	// remove last comma
 	keys = keys[:len(keys)-1]
+
 	return
 }
diff --git a/version/version.go b/version/version.go
index 30bb50c..ce28769 100644
--- a/version/version.go
+++ b/version/version.go
@@ -36,9 +36,11 @@ const (
 	MinimumKubernetesVersionClusterTopology = "v1.22.0"
 )
 
-// CheckKubernetesVersion return an error if the Kubernetes version in a cluster is lower than the specified minK8sVersion.
+// CheckKubernetesVersion return an error if the Kubernetes version in a cluster
+// is lower than the specified minK8sVersion.
 func CheckKubernetesVersion(config *rest.Config, minK8sVersion string) error {
 	client := discovery.NewDiscoveryClientForConfigOrDie(config)
+
 	serverVersion, err := client.ServerVersion()
 	if err != nil {
 		return errors.Wrap(err, "failed to get the Kubernetes version")
@@ -50,8 +52,10 @@ func CheckKubernetesVersion(config *rest.Config, minK8sVersion string) error {
 	}
 
 	if compareResult == -1 {
-		return errors.Errorf("unsupported management cluster server version: %s - minimum required version is %s", serverVersion.String(), minK8sVersion)
+		return errors.Errorf("unsupported management cluster server version: %s - minimum required version is %s",
+			serverVersion.String(), minK8sVersion)
 	}
+
 	return nil
 }
 


Test patch:
diff --git a/bootstrap/api/v1alpha1/webhook_suite_test.go b/bootstrap/api/v1alpha1/webhook_suite_test.go
index c3292dc..30ebecd 100644
--- a/bootstrap/api/v1alpha1/webhook_suite_test.go
+++ b/bootstrap/api/v1alpha1/webhook_suite_test.go
@@ -40,11 +40,13 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/log/zap"
 )
 
-var cfg *rest.Config
-var k8sClient client.Client
-var testEnv *envtest.Environment
-var ctx context.Context
-var cancel context.CancelFunc
+var (
+	cfg       *rest.Config
+	k8sClient client.Client
+	testEnv   *envtest.Environment
+	ctx       context.Context
+	cancel    context.CancelFunc
+)
 
 func TestAPIs(t *testing.T) {
 	RegisterFailHandler(Fail)
@@ -122,9 +124,9 @@ var _ = BeforeSuite(func() {
 			return err
 		}
 		conn.Close()
+
 		return nil
 	}).Should(Succeed())
-
 }, 60)
 
 var _ = AfterSuite(func() {
diff --git a/bootstrap/internal/cloudinit/cloudinit_suite_test.go b/bootstrap/internal/cloudinit/cloudinit_suite_test.go
index 28d1fb0..0abe41e 100644
--- a/bootstrap/internal/cloudinit/cloudinit_suite_test.go
+++ b/bootstrap/internal/cloudinit/cloudinit_suite_test.go
@@ -23,7 +23,6 @@ import (
 	. "github.com/onsi/gomega"
 
 	"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
-	//+kubebuilder:scaffold:imports
 )
 
 func TestCloudInit(t *testing.T) {
@@ -32,5 +31,4 @@ func TestCloudInit(t *testing.T) {
 	RunSpecsWithDefaultAndCustomReporters(t,
 		"CloudInit Suite",
 		[]Reporter{printer.NewlineReporter{}})
-
 }
diff --git a/bootstrap/internal/controllers/suite_test.go b/bootstrap/internal/controllers/suite_test.go
index e5a6f1e..c435cd9 100644
--- a/bootstrap/internal/controllers/suite_test.go
+++ b/bootstrap/internal/controllers/suite_test.go
@@ -32,15 +32,16 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/log/zap"
 
 	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
-	//+kubebuilder:scaffold:imports
 )
 
 // These tests use Ginkgo (BDD-style Go testing framework). Refer to
 // http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
 
-var cfg *rest.Config
-var k8sClient client.Client
-var testEnv *envtest.Environment
+var (
+	cfg       *rest.Config
+	k8sClient client.Client
+	testEnv   *envtest.Environment
+)
 
 func TestAPIs(t *testing.T) {
 	RegisterFailHandler(Fail)
@@ -73,7 +74,6 @@ var _ = BeforeSuite(func() {
 	k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
 	Expect(err).NotTo(HaveOccurred())
 	Expect(k8sClient).NotTo(BeNil())
-
 }, 60)
 
 var _ = AfterSuite(func() {
diff --git a/controlplane/api/v1alpha1/webhook_suite_test.go b/controlplane/api/v1alpha1/webhook_suite_test.go
index b1dd83b..ef4422a 100644
--- a/controlplane/api/v1alpha1/webhook_suite_test.go
+++ b/controlplane/api/v1alpha1/webhook_suite_test.go
@@ -43,11 +43,13 @@ import (
 // These tests use Ginkgo (BDD-style Go testing framework). Refer to
 // http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
 
-var cfg *rest.Config
-var k8sClient client.Client
-var testEnv *envtest.Environment
-var ctx context.Context
-var cancel context.CancelFunc
+var (
+	cfg       *rest.Config
+	k8sClient client.Client
+	testEnv   *envtest.Environment
+	ctx       context.Context
+	cancel    context.CancelFunc
+)
 
 func TestAPIs(t *testing.T) {
 	RegisterFailHandler(Fail)
@@ -125,9 +127,9 @@ var _ = BeforeSuite(func() {
 			return err
 		}
 		conn.Close()
+
 		return nil
 	}).Should(Succeed())
-
 }, 60)
 
 var _ = AfterSuite(func() {
diff --git a/controlplane/internal/controllers/suite_test.go b/controlplane/internal/controllers/suite_test.go
index 38f8de0..a1363d1 100644
--- a/controlplane/internal/controllers/suite_test.go
+++ b/controlplane/internal/controllers/suite_test.go
@@ -32,15 +32,16 @@ import (
 	"sigs.k8s.io/controller-runtime/pkg/log/zap"
 
 	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
-	//+kubebuilder:scaffold:imports
 )
 
 // These tests use Ginkgo (BDD-style Go testing framework). Refer to
 // http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
 
-var cfg *rest.Config
-var k8sClient client.Client
-var testEnv *envtest.Environment
+var (
+	cfg       *rest.Config
+	k8sClient client.Client
+	testEnv   *envtest.Environment
+)
 
 func TestAPIs(t *testing.T) {
 	RegisterFailHandler(Fail)
@@ -73,7 +74,6 @@ var _ = BeforeSuite(func() {
 	k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme})
 	Expect(err).NotTo(HaveOccurred())
 	Expect(k8sClient).NotTo(BeNil())
-
 }, 60)
 
 var _ = AfterSuite(func() {
diff --git a/pkg/locking/control_plane_init_mutex_test.go b/pkg/locking/control_plane_init_mutex_test.go
index c8174f7..60b585a 100644
--- a/pkg/locking/control_plane_init_mutex_test.go
+++ b/pkg/locking/control_plane_init_mutex_test.go
@@ -23,6 +23,7 @@ import (
 	"testing"
 
 	. "github.com/onsi/gomega"
+
 	corev1 "k8s.io/api/core/v1"
 	apierrors "k8s.io/apimachinery/pkg/api/errors"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -41,9 +42,7 @@ const (
 	clusterNamespace = "test-namespace"
 )
 
-var (
-	ctx = ctrl.SetupSignalHandler()
-)
+var ctx = ctrl.SetupSignalHandler()
 
 func TestControlPlaneInitMutex_Lock(t *testing.T) {
 	g := NewWithT(t)
@@ -145,10 +144,12 @@ func TestControlPlaneInitMutex_LockWithMachineDeletion(t *testing.T) {
 					&corev1.ConfigMap{
 						ObjectMeta: metav1.ObjectMeta{
 							Name:      configMapName(clusterName),
-							Namespace: clusterNamespace},
+							Namespace: clusterNamespace,
+						},
 						Data: map[string]string{
 							"lock-information": "{\"machineName\":\"existent-machine\"}",
-						}},
+						},
+					},
 					&clusterv1.Machine{
 						ObjectMeta: metav1.ObjectMeta{
 							Name:      "existent-machine",
@@ -166,15 +167,18 @@ func TestControlPlaneInitMutex_LockWithMachineDeletion(t *testing.T) {
 					&corev1.ConfigMap{
 						ObjectMeta: metav1.ObjectMeta{
 							Name:      configMapName(clusterName),
-							Namespace: clusterNamespace},
+							Namespace: clusterNamespace,
+						},
 						Data: map[string]string{
 							"lock-information": "{\"machineName\":\"non-existent-machine\"}",
-						}},
+						},
+					},
 				).Build(),
 			},
 			expectedMachineName: newMachineName,
 		},
 	}
+
 	for _, tc := range tests {
 		t.Run(tc.name, func(t *testing.T) {
 			l := &ControlPlaneInitMutex{
@@ -206,6 +210,7 @@ func TestControlPlaneInitMutex_LockWithMachineDeletion(t *testing.T) {
 				g.Expect(err).To(BeNil())
 
 				g.Expect(info.MachineName).To(Equal(tc.expectedMachineName))
+
 				return nil
 			}, "20s").Should(Succeed())
 		})
@@ -291,6 +296,7 @@ func (fc *fakeClient) Get(ctx context.Context, key client.ObjectKey, obj client.
 	if fc.getError != nil {
 		return fc.getError
 	}
+
 	return fc.Client.Get(ctx, key, obj, opts...)
 }
 
@@ -298,6 +304,7 @@ func (fc *fakeClient) Create(ctx context.Context, obj client.Object, opts ...cli
 	if fc.createError != nil {
 		return fc.createError
 	}
+
 	return fc.Client.Create(ctx, obj, opts...)
 }
 
@@ -305,5 +312,6 @@ func (fc *fakeClient) Delete(ctx context.Context, obj client.Object, opts ...cli
 	if fc.deleteError != nil {
 		return fc.deleteError
 	}
+
 	return fc.Client.Delete(ctx, obj, opts...)
 }
diff --git a/pkg/rke2/config_test.go b/pkg/rke2/config_test.go
index b1dd7c9..3d6b18e 100644
--- a/pkg/rke2/config_test.go
+++ b/pkg/rke2/config_test.go
@@ -20,19 +20,22 @@ import (
 
 	. "github.com/onsi/ginkgo"
 	. "github.com/onsi/gomega"
-	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
-	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
+
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
-	"sigs.k8s.io/cluster-api/api/v1beta1"
 	"sigs.k8s.io/controller-runtime/pkg/client/fake"
+
+	"sigs.k8s.io/cluster-api/api/v1beta1"
+
+	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
+	controlplanev1 "github.com/rancher-sandbox/cluster-api-provider-rke2/controlplane/api/v1alpha1"
 )
 
 var _ = Describe("RKE2ServerConfig", func() {
-	var opts *RKE2ServerConfigOpts
+	var opts *ServerConfigOpts
 
 	BeforeEach(func() {
-		opts = &RKE2ServerConfigOpts{
+		opts = &ServerConfigOpts{
 			Cluster: v1beta1.Cluster{
 				Spec: v1beta1.ClusterSpec{
 					ClusterNetwork: &v1beta1.ClusterNetwork{
@@ -181,7 +184,7 @@ var _ = Describe("RKE2ServerConfig", func() {
 		Expect(rke2ServerConfig.DisableKubeProxy).To(BeTrue())
 		Expect(rke2ServerConfig.DisableCloudController).To(BeTrue())
 		Expect(rke2ServerConfig.DisableScheduler).To(BeTrue())
-		//Expect(rke2ServerConfig.EtcdDisableSnapshots).To(BeFalse())
+		// Expect(rke2ServerConfig.EtcdDisableSnapshots).To(BeFalse())
 		Expect(rke2ServerConfig.EtcdExposeMetrics).To(Equal(serverConfig.Etcd.ExposeMetrics))
 		Expect(rke2ServerConfig.EtcdS3).To(BeTrue())
 		Expect(rke2ServerConfig.EtcdS3AccessKey).To(Equal("test_id"))
@@ -237,10 +240,10 @@ var _ = Describe("RKE2ServerConfig", func() {
 })
 
 var _ = Describe("RKE2 Agent Config", func() {
-	var opts *RKE2AgentConfigOpts
+	var opts *AgentConfigOpts
 
 	BeforeEach(func() {
-		opts = &RKE2AgentConfigOpts{
+		opts = &AgentConfigOpts{
 			ServerURL: "testurl",
 			Ctx:       context.Background(),
 			Token:     "testtoken",
@@ -271,7 +274,7 @@ var _ = Describe("RKE2 Agent Config", func() {
 				LoadBalancerPort:      1234,
 				NodeLabels:            []string{"testlabel"},
 				NodeTaints:            []string{"testtaint"},
-				CISProfile:            bootstrapv1.CIS1_23,
+				CISProfile:            bootstrapv1.CIS1_23, //nolint:nosnakecase
 				ProtectKernelDefaults: true,
 				ResolvConf: &corev1.ObjectReference{
 					Name:      "test",
diff --git a/pkg/rke2/machine_filters_test.go b/pkg/rke2/machine_filters_test.go
index 4da4f62..78d128e 100644
--- a/pkg/rke2/machine_filters_test.go
+++ b/pkg/rke2/machine_filters_test.go
@@ -3,8 +3,10 @@ package rke2
 import (
 	. "github.com/onsi/ginkgo"
 	. "github.com/onsi/gomega"
+
 	corev1 "k8s.io/api/core/v1"
 	v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+
 	clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
 	"sigs.k8s.io/cluster-api/util/collections"
 
@@ -31,8 +33,11 @@ var rcp = controlplanev1.RKE2ControlPlane{
 		},
 	},
 }
-var machineVersion = "v1.24.6"
-var regionEuCentral1 = "eu-central-1"
+
+var (
+	machineVersion   = "v1.24.6"
+	regionEuCentral1 = "eu-central-1"
+)
 
 var machine = clusterv1.Machine{
 	ObjectMeta: v1.ObjectMeta{
@@ -58,7 +63,6 @@ var machine = clusterv1.Machine{
 }
 
 var _ = Describe("ServerConfigMatching", func() {
-
 	It("should match the machine annotation", func() {
 		res := matchServerConfig(&rcp, &machine)
 		Expect(res).To(BeTrue())
@@ -92,7 +96,7 @@ var _ = Describe("matchAgentConfig", func() {
 	)
 })
 
-var _ = Describe("maching Kubernetes Version", func() {
+var _ = Describe("matching Kubernetes Version", func() {
 	It("should match version", func() {
 		machineCollection := collections.FromMachines(&machine)
 		matches := machineCollection.AnyFilter(matchesKubernetesVersion(rcp.Spec.AgentConfig.Version))
diff --git a/pkg/rke2/registries_test.go b/pkg/rke2/registries_test.go
index 004b30c..849f66b 100644
--- a/pkg/rke2/registries_test.go
+++ b/pkg/rke2/registries_test.go
@@ -21,15 +21,17 @@ import (
 
 	. "github.com/onsi/ginkgo"
 	. "github.com/onsi/gomega"
-	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
+
 	corev1 "k8s.io/api/core/v1"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"sigs.k8s.io/controller-runtime/pkg/client/fake"
 	"sigs.k8s.io/controller-runtime/pkg/log"
+
+	bootstrapv1 "github.com/rancher-sandbox/cluster-api-provider-rke2/bootstrap/api/v1alpha1"
 )
 
 var _ = Describe("RKE2RegistryConfig", func() {
-	var rke2ConfigReg RKE2ConfigRegistry
+	var rke2ConfigReg RegistryScope
 	BeforeEach(func() {
 		rke2RegistryConfig := bootstrapv1.Registry{
 			Mirrors: map[string]bootstrapv1.Mirror{
@@ -63,7 +65,7 @@ var _ = Describe("RKE2RegistryConfig", func() {
 			},
 		}
 
-		rke2ConfigReg = RKE2ConfigRegistry{
+		rke2ConfigReg = RegistryScope{
 			Registry: rke2RegistryConfig,
 			Client: fake.NewClientBuilder().WithObjects(
 				&corev1.Secret{
@@ -113,7 +115,7 @@ var _ = Describe("RKE2RegistryConfig", func() {
 		fileNameArray := []string{"tls.crt", "tls.key", "ca.crt"}
 		for _, file := range files {
 
-			var found bool = false
+			found := false
 			var position int
 			for i, filename := range fileNameArray {
 				pathSlice := strings.Split(file.Path, "/")
@@ -121,6 +123,7 @@ var _ = Describe("RKE2RegistryConfig", func() {
 				if origFilename == filename {
 					found = true
 					position = i
+
 					break
 				}
 			}
@@ -137,16 +140,15 @@ var _ = Describe("RKE2RegistryConfig", func() {
 		Expect(registryResult.Configs["https://test-registry"].TLS.CertFile).To(Equal(registryCertsPath + "/" + "tls.crt"))
 		Expect(registryResult.Configs["https://test-registry"].TLS.KeyFile).To(Equal(registryCertsPath + "/" + "tls.key"))
 		Expect(registryResult.Configs["https://test-registry"].TLS.InsecureSkipVerify).To(BeTrue())
-
 	})
 },
 )
 
 var _ = Describe("RKE2RegistryConfig is empty", func() {
-	var rke2ConfigReg RKE2ConfigRegistry
+	var rke2ConfigReg RegistryScope
 	BeforeEach(func() {
 		rke2RegistryConfig := bootstrapv1.Registry{}
-		rke2ConfigReg = RKE2ConfigRegistry{
+		rke2ConfigReg = RegistryScope{
 			Registry: rke2RegistryConfig,
 			Client:   fake.NewClientBuilder().Build(),
 			Ctx:      context.Background(),
@@ -165,9 +167,9 @@ var _ = Describe("RKE2RegistryConfig is empty", func() {
 })
 
 var _ = Describe("RKE2RegistryConfig is nil", func() {
-	var rke2ConfigReg RKE2ConfigRegistry
+	var rke2ConfigReg RegistryScope
 	BeforeEach(func() {
-		rke2ConfigReg = RKE2ConfigRegistry{
+		rke2ConfigReg = RegistryScope{
 			Client: fake.NewClientBuilder().Build(),
 			Ctx:    context.Background(),
 			Logger: log.FromContext(context.Background()),
diff --git a/pkg/rke2/suite_test.go b/pkg/rke2/suite_test.go
index 2958124..716b5c1 100644
--- a/pkg/rke2/suite_test.go
+++ b/pkg/rke2/suite_test.go
@@ -7,7 +7,6 @@ import (
 	. "github.com/onsi/gomega"
 
 	"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
-	//+kubebuilder:scaffold:imports
 )
 
 func TestAPIs(t *testing.T) {
diff --git a/pkg/util/suite_test.go b/pkg/util/suite_test.go
index 087b932..bf81566 100644
--- a/pkg/util/suite_test.go
+++ b/pkg/util/suite_test.go
@@ -23,7 +23,6 @@ import (
 	. "github.com/onsi/gomega"
 
 	"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
-	//+kubebuilder:scaffold:imports
 )
 
 func TestUtil(t *testing.T) {
@@ -32,5 +31,4 @@ func TestUtil(t *testing.T) {
 	RunSpecsWithDefaultAndCustomReporters(t,
 		"Util Suite",
 		[]Reporter{printer.NewlineReporter{}})
-
 }
diff --git a/pkg/util/util_test.go b/pkg/util/util_test.go
index d367042..79994c3 100644
--- a/pkg/util/util_test.go
+++ b/pkg/util/util_test.go
@@ -6,7 +6,6 @@ import (
 )
 
 var _ = Describe("Testing RKE2 to Kubernetes Version conversion", func() {
-
 	machineVersion := "1.24.6"
 	rke2Version := "v1.24.6+rke2r1"
 	It("Should match RKE2 and Kubernetes version", func() {
@@ -14,7 +13,6 @@ var _ = Describe("Testing RKE2 to Kubernetes Version conversion", func() {
 		Expect(err).ToNot(HaveOccurred())
 		Expect(cpKubeVersion).To(Equal(machineVersion))
 	})
-
 })
 
 var _ = Describe(("Testing GetMapKeysAsString"), func() {