Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
chrischdi committed Feb 15, 2024
1 parent b2e33b7 commit 5759ab9
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions internal/webhooks/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ func (webhook *Cluster) validateTopologyVersion(ctx context.Context, fldPath *fi

allErrs := field.ErrorList{}
// minor version cannot be increased if control plane is upgrading or not yet on the current version
if err := validateTopologyControlPlaneVersion(ctx, fldPath, webhook.Client, oldCluster, oldVersion); err != nil {
if err := validateTopologyControlPlaneVersion(ctx, webhook.Client, oldCluster, oldVersion); err != nil {
allErrs = append(allErrs, field.Invalid(
fldPath,
fldValue,
Expand All @@ -438,7 +438,7 @@ func (webhook *Cluster) validateTopologyVersion(ctx context.Context, fldPath *fi
}

// minor version cannot be increased if MachineDeployments are upgrading or not yet on the current version
if err := validateTopologyMachineDeploymentVersions(ctx, fldPath, webhook.Client, oldCluster, oldVersion); err != nil {
if err := validateTopologyMachineDeploymentVersions(ctx, webhook.Client, oldCluster, oldVersion); err != nil {
allErrs = append(allErrs, field.Invalid(
fldPath,
fldValue,
Expand All @@ -447,7 +447,7 @@ func (webhook *Cluster) validateTopologyVersion(ctx context.Context, fldPath *fi
}

// minor version cannot be increased if MachinePools are upgrading or not yet on the current version
if err := validateTopologyMachinePoolVersions(ctx, fldPath, webhook.Client, webhook.Tracker, oldCluster, oldVersion); err != nil {
if err := validateTopologyMachinePoolVersions(ctx, webhook.Client, webhook.Tracker, oldCluster, oldVersion); err != nil {
allErrs = append(allErrs, field.Invalid(
fldPath,
fldValue,
Expand All @@ -462,10 +462,10 @@ func (webhook *Cluster) validateTopologyVersion(ctx context.Context, fldPath *fi
return nil
}

func validateTopologyControlPlaneVersion(ctx context.Context, fldPath *field.Path, ctrlClient client.Reader, oldCluster *clusterv1.Cluster, oldVersion semver.Version) error {
func validateTopologyControlPlaneVersion(ctx context.Context, ctrlClient client.Reader, oldCluster *clusterv1.Cluster, oldVersion semver.Version) error {
cp, err := external.Get(ctx, ctrlClient, oldCluster.Spec.ControlPlaneRef, oldCluster.Namespace)
if err != nil {
return errors.Wrap(err, "failed to to get ControlPlane object")
return errors.Wrap(err, "failed to get ControlPlane object")
}

cpVersionString, err := contract.ControlPlane().Version().Get(cp)
Expand Down Expand Up @@ -503,7 +503,7 @@ func validateTopologyControlPlaneVersion(ctx context.Context, fldPath *field.Pat
return nil
}

func validateTopologyMachineDeploymentVersions(ctx context.Context, fldPath *field.Path, ctrlClient client.Reader, oldCluster *clusterv1.Cluster, oldVersion semver.Version) error {
func validateTopologyMachineDeploymentVersions(ctx context.Context, ctrlClient client.Reader, oldCluster *clusterv1.Cluster, oldVersion semver.Version) error {
// List all the machine deployments in the current cluster and in a managed topology.
mds := &clusterv1.MachineDeploymentList{}
// FROM: desired_state.go getCurrentMachineDeploymentState
Expand All @@ -515,7 +515,7 @@ func validateTopologyMachineDeploymentVersions(ctx context.Context, fldPath *fie
client.InNamespace(oldCluster.Namespace),
)
if err != nil {
return field.InternalError(fldPath, errors.Wrap(err, "failed to read MachineDeployments for managed topology"))
return errors.Wrap(err, "failed to read MachineDeployments for managed topology")
}

if len(mds.Items) == 0 {
Expand All @@ -530,7 +530,7 @@ func validateTopologyMachineDeploymentVersions(ctx context.Context, fldPath *fie
mdVersion, err := semver.ParseTolerant(*md.Spec.Template.Spec.Version)
if err != nil {
// NOTE: this should never happen. Nevertheless, handling this for extra caution.
return field.InternalError(fldPath, errors.Wrapf(err, "failed to parse MachineDeployment's %q version %q", klog.KObj(md), *md.Spec.Template.Spec.Version))
return errors.Wrapf(err, "failed to parse MachineDeployment's %q version %q", klog.KObj(md), *md.Spec.Template.Spec.Version)
}

if mdVersion.NE(oldVersion) {
Expand All @@ -554,7 +554,7 @@ func validateTopologyMachineDeploymentVersions(ctx context.Context, fldPath *fie
return nil
}

func validateTopologyMachinePoolVersions(ctx context.Context, fldPath *field.Path, ctrlClient client.Reader, tracker ClusterCacheTrackerReader, oldCluster *clusterv1.Cluster, oldVersion semver.Version) error {
func validateTopologyMachinePoolVersions(ctx context.Context, ctrlClient client.Reader, tracker ClusterCacheTrackerReader, oldCluster *clusterv1.Cluster, oldVersion semver.Version) error {
// FROM: desired_state.go getCurrentMachinePoolState

// List all the machine pools in the current cluster and in a managed topology.
Expand All @@ -567,7 +567,7 @@ func validateTopologyMachinePoolVersions(ctx context.Context, fldPath *field.Pat
client.InNamespace(oldCluster.Namespace),
)
if err != nil {
return field.InternalError(fldPath, errors.Wrap(err, "failed to read MachinePools for managed topology"))
return errors.Wrap(err, "failed to read MachinePools for managed topology")
}

// Return early
Expand All @@ -577,7 +577,7 @@ func validateTopologyMachinePoolVersions(ctx context.Context, fldPath *field.Pat

wlClient, err := tracker.GetReader(ctx, client.ObjectKeyFromObject(oldCluster))
if err != nil {
return field.InternalError(fldPath, errors.Wrap(err, "unable to get client for workload cluster"))
return errors.Wrap(err, "unable to get client for workload cluster")
}

mpUpgradingNames := []string{}
Expand All @@ -588,7 +588,7 @@ func validateTopologyMachinePoolVersions(ctx context.Context, fldPath *field.Pat
mpVersion, err := semver.ParseTolerant(*mp.Spec.Template.Spec.Version)
if err != nil {
// NOTE: this should never happen. Nevertheless, handling this for extra caution.
return field.InternalError(fldPath, errors.Wrapf(err, "failed to parse MachinePool's %q version %q", klog.KObj(mp), *mp.Spec.Template.Spec.Version))
return errors.Wrapf(err, "failed to parse MachinePool's %q version %q", klog.KObj(mp), *mp.Spec.Template.Spec.Version)
}

if mpVersion.NE(oldVersion) {
Expand Down

0 comments on commit 5759ab9

Please sign in to comment.