Skip to content

Commit

Permalink
chore: pass linter
Browse files Browse the repository at this point in the history
  • Loading branch information
chenlujjj committed Nov 28, 2024
1 parent d2e09ab commit f604c8d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
15 changes: 10 additions & 5 deletions controllers/controller_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,14 @@ import (
const grafanaFinalizer = "operator.grafana.com/finalizer"

const (
// condition types
conditionNoMatchingInstance = "NoMatchingInstance"
conditionNoMatchingFolder = "NoMatchingFolder"
conditionInvalidSpec = "InvalidSpec"

// condition reasons
conditionApplySuccessful = "ApplySuccessful"
conditionApplyFailed = "ApplyFailed"
)

const annotationAppliedNotificationPolicy = "operator.grafana.com/applied-notificationpolicy"
Expand Down Expand Up @@ -148,7 +153,7 @@ func ReconcilePlugins(ctx context.Context, k8sClient client.Client, scheme *runt
func setNoMatchingInstance(conditions *[]metav1.Condition, generation int64, reason, message string) {
meta.SetStatusCondition(conditions, metav1.Condition{
Type: conditionNoMatchingInstance,
Status: "True",
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
LastTransitionTime: metav1.Time{
Time: time.Now(),
Expand All @@ -165,7 +170,7 @@ func removeNoMatchingInstance(conditions *[]metav1.Condition) {
func setNoMatchingFolder(conditions *[]metav1.Condition, generation int64, reason, message string) {
meta.SetStatusCondition(conditions, metav1.Condition{
Type: conditionNoMatchingFolder,
Status: "True",
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
LastTransitionTime: metav1.Time{
Time: time.Now(),
Expand All @@ -182,7 +187,7 @@ func removeNoMatchingFolder(conditions *[]metav1.Condition) {
func setInvalidSpec(conditions *[]metav1.Condition, generation int64, reason, message string) {
meta.SetStatusCondition(conditions, metav1.Condition{
Type: conditionInvalidSpec,
Status: "True",
Status: metav1.ConditionTrue,
ObservedGeneration: generation,
LastTransitionTime: metav1.Time{
Time: time.Now(),
Expand Down Expand Up @@ -215,11 +220,11 @@ func buildSynchronizedCondition(resource string, syncType string, generation int
}

if len(applyErrors) == 0 {
condition.Status = "True"
condition.Status = metav1.ConditionTrue
condition.Reason = "ApplySuccessful"
condition.Message = fmt.Sprintf("%s was successfully applied to %d instances", resource, total)
} else {
condition.Status = "False"
condition.Status = metav1.ConditionFalse
condition.Reason = "ApplyFailed"

var sb strings.Builder
Expand Down
2 changes: 1 addition & 1 deletion controllers/grafanaalertrulegroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (r *GrafanaAlertRuleGroupReconciler) reconcileWithInstance(ctx context.Cont
return fmt.Errorf("building grafana client: %w", err)
}

trueRef := "true"
trueRef := "true" //nolint:goconst
editable := true
if group.Spec.Editable != nil && !*group.Spec.Editable {
editable = false
Expand Down
8 changes: 4 additions & 4 deletions controllers/grafanacontactpoint_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ func (r *GrafanaContactPointReconciler) Reconcile(ctx context.Context, req ctrl.
}

if len(applyErrors) == 0 {
condition.Status = "True"
condition.Reason = "ApplySuccessful"
condition.Status = metav1.ConditionTrue
condition.Reason = conditionApplySuccessful
condition.Message = fmt.Sprintf("Contact point was successfully applied to %d instances", len(instances))
} else {
condition.Status = "False"
condition.Reason = "ApplyFailed"
condition.Status = metav1.ConditionFalse
condition.Reason = conditionApplyFailed

var sb strings.Builder
for i, err := range applyErrors {
Expand Down
10 changes: 5 additions & 5 deletions controllers/grafananotificationtemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ func (r *GrafanaNotificationTemplateReconciler) Reconcile(ctx context.Context, r
}

if len(applyErrors) == 0 {
condition.Status = "True"
condition.Reason = "ApplySuccessful"
condition.Status = metav1.ConditionTrue
condition.Reason = conditionApplySuccessful
condition.Message = fmt.Sprintf("Notification template was successfully applied to %d instances", len(instances))
} else {
condition.Status = "False"
condition.Reason = "ApplyFailed"
condition.Status = metav1.ConditionFalse
condition.Reason = conditionApplyFailed

var sb strings.Builder
for i, err := range applyErrors {
Expand All @@ -163,7 +163,7 @@ func (r *GrafanaNotificationTemplateReconciler) reconcileWithInstance(ctx contex
return fmt.Errorf("building grafana client: %w", err)
}

trueRef := "true"
trueRef := "true" //nolint:goconst
editable := true
if notificationTemplate.Spec.Editable != nil && !*notificationTemplate.Spec.Editable {
editable = false
Expand Down

0 comments on commit f604c8d

Please sign in to comment.