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 797c86d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3.7.0
with:
version: "v1.55.2"
version: "v1.56.2"

test:
runs-on: ubuntu-latest
Expand Down
11 changes: 6 additions & 5 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 All @@ -129,7 +129,6 @@ func (r *GrafanaAlertRuleGroupReconciler) Reconcile(ctx context.Context, req ctr
if err != nil {
applyErrors[fmt.Sprintf("%s/%s", grafana.Namespace, grafana.Name)] = err.Error()
}

}
condition := metav1.Condition{
Type: "AlertGroupSynchronized",
Expand All @@ -142,7 +141,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 +159,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 +186,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 @@ -216,7 +216,7 @@ func (r *GrafanaAlertRuleGroupReconciler) reconcileWithInstance(ctx context.Cont
WithBody(apiRule).
WithXDisableProvenance(&strue).
WithUID(rule.UID)
_, err = cl.Provisioning.PutAlertRule(params)
_, err := cl.Provisioning.PutAlertRule(params)

Check failure on line 219 in controllers/grafanaalertrulegroup_controller.go

View workflow job for this annotation

GitHub Actions / go-lint

Error return value of `cl.Provisioning.PutAlertRule` is not checked (errcheck)
if err != nil {
return fmt.Errorf("updating rule: %w", err)
}
Expand Down Expand Up @@ -292,6 +292,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 297 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 797c86d

Please sign in to comment.