Skip to content

Commit

Permalink
chore: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
theSuess committed Feb 16, 2024
1 parent ec7136e commit c68a5f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions controllers/grafanaalertrulegroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (r *GrafanaAlertRuleGroupReconciler) Reconcile(ctx context.Context, req ctr

instances, err := r.GetMatchingInstances(ctx, group.Spec.InstanceSelector, r.Client)
if err != nil {
setNoMatchingInstance(&group.Status.Conditions, group.Generation, "ErrFetchingInstances", fmt.Sprintf("error occured during fetching of instances: %s", err.Error()))
setNoMatchingInstance(&group.Status.Conditions, group.Generation, "ErrFetchingInstances", fmt.Sprintf("error occurred during fetching of instances: %s", err.Error()))
r.Log.Error(err, "could not find matching instances")
return ctrl.Result{RequeueAfter: RequeueDelay}, err
}
Expand Down Expand Up @@ -142,7 +142,7 @@ func (r *GrafanaAlertRuleGroupReconciler) Reconcile(ctx context.Context, req ctr
if len(applyErrors) == 0 {
condition.Status = "True"
condition.Reason = "ApplySuccesfull"
condition.Message = fmt.Sprintf("Alert Rule Group was succesfully applied to %d instances", len(instances.Items))
condition.Message = fmt.Sprintf("Alert Rule Group was successfully applied to %d instances", len(instances.Items))
} else {
condition.Status = "False"
condition.Reason = "ApplyFailed"
Expand All @@ -160,7 +160,7 @@ func (r *GrafanaAlertRuleGroupReconciler) Reconcile(ctx context.Context, req ctr
}

// SetupWithManager sets up the controller with the Manager.
func (r *GrafanaAlertRuleGroupReconciler) SetupWithManager(mgr ctrl.Manager, ctx context.Context) error {
func (r *GrafanaAlertRuleGroupReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&grafanav1beta1.GrafanaAlertRuleGroup{}).
Complete(r)
Expand All @@ -187,6 +187,7 @@ func (r *GrafanaAlertRuleGroupReconciler) reconcileWithInstance(ctx context.Cont
}

for _, rule := range group.Spec.Rules {
rule := rule
apiRule := &models.ProvisionedAlertRule{
Annotations: rule.Annotations,
Condition: &rule.Condition,
Expand Down Expand Up @@ -292,6 +293,7 @@ func (r *GrafanaAlertRuleGroupReconciler) removeFromInstance(ctx context.Context
return fmt.Errorf("fetching alert rule group from instance %s: %w", instance.Status.AdminUrl, err)
}
for _, rule := range remote.Payload.Rules {
rule := rule
params := provisioning.NewDeleteAlertRuleParams().WithUID(rule.UID)
_, err := cl.Provisioning.DeleteAlertRule(params)

Check failure on line 298 in controllers/grafanaalertrulegroup_controller.go

View workflow job for this annotation

GitHub Actions / go-lint

Error return value of `cl.Provisioning.DeleteAlertRule` is not checked (errcheck)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func main() {
if err = (&controllers.GrafanaAlertRuleGroupReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr, ctx); err != nil {
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "GrafanaAlertRuleGroup")
os.Exit(1)
}
Expand Down

0 comments on commit c68a5f4

Please sign in to comment.