Skip to content

Commit

Permalink
feat(alerting): alertmanager config loader edits (#130)
Browse files Browse the repository at this point in the history
* feat(alerting): alertmanager config loader

Signed-off-by: Robin Opletal <[email protected]>

* generated stuff...

Signed-off-by: Robin Opletal <[email protected]>

---------

Signed-off-by: Robin Opletal <[email protected]>
  • Loading branch information
fourstepper authored Oct 6, 2024
1 parent cd377d4 commit 93efcf8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion api/osko/v1alpha1/alertmanagerconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// AlertManagerConfigSpec defines the desired state of AlertManagerConfig
type AlertManagerConfigSpec struct {
SecretRef v1.SecretReference `json:"secretRef,omitempty"`
ConfigSecretRef v1.SecretReference `json:"configSecretRef,omitempty"`
}

// AlertManagerConfigStatus defines the observed state of AlertManagerConfig
Expand Down
2 changes: 1 addition & 1 deletion api/osko/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config/crd/bases/osko.dev_alertmanagerconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ spec:
spec:
description: AlertManagerConfigSpec defines the desired state of AlertManagerConfig
properties:
secretRef:
configSecretRef:
description: |-
SecretReference represents a Secret Reference. It has enough information to retrieve secret
in any namespace
Expand Down
14 changes: 7 additions & 7 deletions internal/controller/osko/alertmanagerconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ func (r *AlertManagerConfigReconciler) Reconcile(ctx context.Context, req ctrl.R
return ctrl.Result{}, err
}

if amc.Spec.SecretRef.Namespace == "" {
amc.Spec.SecretRef.Namespace = req.Namespace
if amc.Spec.ConfigSecretRef.Namespace == "" {
amc.Spec.ConfigSecretRef.Namespace = req.Namespace
}

err = r.Get(ctx, client.ObjectKey{Namespace: amc.Spec.SecretRef.Namespace, Name: amc.Spec.SecretRef.Name}, secret)
err = r.Get(ctx, client.ObjectKey{Namespace: amc.Spec.ConfigSecretRef.Namespace, Name: amc.Spec.ConfigSecretRef.Name}, secret)
if err != nil {
if apierrors.IsNotFound(err) {
if err = utils.UpdateStatus(ctx, amc, r.Client, "Ready", metav1.ConditionFalse, "Secret from secretRef not found"); err != nil {
Expand Down Expand Up @@ -150,12 +150,12 @@ func (r *AlertManagerConfigReconciler) findObjectsForSecret() func(ctx context.C
log.Error(err, errGetAMC)
return []reconcile.Request{}
}
if amc.Spec.SecretRef.Namespace == "" {
amc.Spec.SecretRef.Namespace = a.GetNamespace()
if amc.Spec.ConfigSecretRef.Namespace == "" {
amc.Spec.ConfigSecretRef.Namespace = a.GetNamespace()
}
secretNamespacedName := types.NamespacedName{
Name: amc.Spec.SecretRef.Name,
Namespace: amc.Spec.SecretRef.Namespace,
Name: amc.Spec.ConfigSecretRef.Name,
Namespace: amc.Spec.ConfigSecretRef.Namespace,
}

return []reconcile.Request{{NamespacedName: secretNamespacedName}}
Expand Down

0 comments on commit 93efcf8

Please sign in to comment.