Skip to content

Commit

Permalink
Resolving linting issues focused around mixed import type
Browse files Browse the repository at this point in the history
  • Loading branch information
safwank97 committed Oct 10, 2023
1 parent 31f4058 commit abe539e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions cmd/aro/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ func operator(ctx context.Context, log *logrus.Entry) error {
return fmt.Errorf("unable to create controller %s: %v", autosizednodes.ControllerName, err)
}
if err = (machinehealthcheck.NewMachineHealthCheckReconciler(
log.WithField("controller", machinehealthcheck.MHCControllerName),
log.WithField("controller", machinehealthcheck.ControllerName),
client, dh)).SetupWithManager(mgr); err != nil {
return fmt.Errorf("unable to create controller %s: %v", machinehealthcheck.MHCControllerName, err)
return fmt.Errorf("unable to create controller %s: %v", machinehealthcheck.ControllerName, err)
}
if err = (ingress.NewReconciler(
log.WithField("controller", ingress.ControllerName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ var machinehealthcheckYaml []byte
var mhcremediationalertYaml []byte

const (
MHCControllerName string = "MachineHealthCheck"
MHCManaged string = "aro.machinehealthcheck.managed"
MHCEnabled string = "aro.machinehealthcheck.enabled"
ControllerName string = "MachineHealthCheck"
managed string = "aro.machinehealthcheck.managed"
enabled string = "aro.machinehealthcheck.enabled"
)

type MachineHealthCheckReconciler struct {
Expand All @@ -48,7 +48,7 @@ func NewMachineHealthCheckReconciler(log *logrus.Entry, client client.Client, dh
AROController: base.AROController{
Log: log,
Client: client,
Name: MHCControllerName,
Name: ControllerName,
},
dh: dh,
}
Expand All @@ -63,13 +63,13 @@ func (r *MachineHealthCheckReconciler) Reconcile(ctx context.Context, request ct
return reconcile.Result{}, err
}

if !instance.Spec.OperatorFlags.GetSimpleBoolean(MHCEnabled) {
if !instance.Spec.OperatorFlags.GetSimpleBoolean(enabled) {
r.Log.Debug("controller is disabled")
return reconcile.Result{}, nil
}

r.Log.Debug("running")
if !instance.Spec.OperatorFlags.GetSimpleBoolean(MHCManaged) {
if !instance.Spec.OperatorFlags.GetSimpleBoolean(managed) {
r.SetProgressing(ctx, "MHC and it's alerts are disabled because this cluster is not MHC managed.")

err := r.dh.EnsureDeleted(ctx, "MachineHealthCheck", "openshift-machine-api", "aro-machinehealthcheck")
Expand Down Expand Up @@ -141,7 +141,7 @@ func (r *MachineHealthCheckReconciler) SetupWithManager(mgr ctrl.Manager) error

return ctrl.NewControllerManagedBy(mgr).
For(&arov1alpha1.Cluster{}, builder.WithPredicates(aroClusterPredicate)).
Named(MHCControllerName).
Named(ControllerName).
Owns(&machinev1beta1.MachineHealthCheck{}).
Owns(&monitoringv1.PrometheusRule{}).
Complete(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/golang/mock/gomock"
operatorv1 "github.com/openshift/api/operator/v1"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
Expand All @@ -21,15 +22,14 @@ import (
_ "github.com/Azure/ARO-RP/pkg/util/scheme"
utilconditions "github.com/Azure/ARO-RP/test/util/conditions"
utilerror "github.com/Azure/ARO-RP/test/util/error"
operatorv1 "github.com/openshift/api/operator/v1"
)

// Test reconcile function
func TestMachineHealthCheckReconciler(t *testing.T) {
transitionTime := metav1.Time{Time: time.Now()}
defaultAvailable := utilconditions.ControllerDefaultAvailable(MHCControllerName)
defaultProgressing := utilconditions.ControllerDefaultProgressing(MHCControllerName)
defaultDegraded := utilconditions.ControllerDefaultDegraded(MHCControllerName)
defaultAvailable := utilconditions.ControllerDefaultAvailable(ControllerName)
defaultProgressing := utilconditions.ControllerDefaultProgressing(ControllerName)
defaultDegraded := utilconditions.ControllerDefaultDegraded(ControllerName)

defaultConditions := []operatorv1.OperatorCondition{defaultAvailable, defaultProgressing, defaultDegraded}

Expand Down Expand Up @@ -57,7 +57,7 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
},
Spec: arov1alpha1.ClusterSpec{
OperatorFlags: arov1alpha1.OperatorFlags{
MHCEnabled: strconv.FormatBool(false),
enabled: strconv.FormatBool(false),
},
},
Status: arov1alpha1.ClusterStatus{
Expand All @@ -79,8 +79,8 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
},
Spec: arov1alpha1.ClusterSpec{
OperatorFlags: arov1alpha1.OperatorFlags{
MHCEnabled: strconv.FormatBool(true),
MHCManaged: strconv.FormatBool(false),
enabled: strconv.FormatBool(true),
managed: strconv.FormatBool(false),
},
},
Status: arov1alpha1.ClusterStatus{
Expand All @@ -102,8 +102,8 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
},
Spec: arov1alpha1.ClusterSpec{
OperatorFlags: arov1alpha1.OperatorFlags{
MHCEnabled: strconv.FormatBool(true),
MHCManaged: strconv.FormatBool(false),
enabled: strconv.FormatBool(true),
managed: strconv.FormatBool(false),
},
},
Status: arov1alpha1.ClusterStatus{
Expand All @@ -118,7 +118,7 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
defaultAvailable,
defaultProgressing,
{
Type: MHCControllerName + "Controller" + operatorv1.OperatorStatusTypeDegraded,
Type: ControllerName + "Controller" + operatorv1.OperatorStatusTypeDegraded,
Status: operatorv1.ConditionTrue,
LastTransitionTime: transitionTime,
Message: "Could not delete mhc",
Expand All @@ -134,8 +134,8 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
},
Spec: arov1alpha1.ClusterSpec{
OperatorFlags: arov1alpha1.OperatorFlags{
MHCEnabled: strconv.FormatBool(true),
MHCManaged: strconv.FormatBool(false),
enabled: strconv.FormatBool(true),
managed: strconv.FormatBool(false),
},
},
Status: arov1alpha1.ClusterStatus{
Expand All @@ -151,7 +151,7 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
defaultAvailable,
defaultProgressing,
{
Type: MHCControllerName + "Controller" + operatorv1.OperatorStatusTypeDegraded,
Type: ControllerName + "Controller" + operatorv1.OperatorStatusTypeDegraded,
Status: operatorv1.ConditionTrue,
LastTransitionTime: transitionTime,
Message: "Could not delete mhc alert",
Expand All @@ -167,8 +167,8 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
},
Spec: arov1alpha1.ClusterSpec{
OperatorFlags: arov1alpha1.OperatorFlags{
MHCEnabled: strconv.FormatBool(true),
MHCManaged: strconv.FormatBool(true),
enabled: strconv.FormatBool(true),
managed: strconv.FormatBool(true),
},
},
},
Expand All @@ -186,8 +186,8 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
},
Spec: arov1alpha1.ClusterSpec{
OperatorFlags: arov1alpha1.OperatorFlags{
MHCEnabled: strconv.FormatBool(true),
MHCManaged: strconv.FormatBool(true),
enabled: strconv.FormatBool(true),
managed: strconv.FormatBool(true),
},
},
Status: arov1alpha1.ClusterStatus{
Expand All @@ -202,7 +202,7 @@ func TestMachineHealthCheckReconciler(t *testing.T) {
defaultAvailable,
defaultProgressing,
{
Type: MHCControllerName + "Controller" + operatorv1.OperatorStatusTypeDegraded,
Type: ControllerName + "Controller" + operatorv1.OperatorStatusTypeDegraded,
Status: operatorv1.ConditionTrue,
LastTransitionTime: transitionTime,
Message: "failed to ensure",
Expand Down

0 comments on commit abe539e

Please sign in to comment.