generated from giantswarm/template-operator
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove-generic-resource-from-alertmanager-config (#1641)
* remove-generic-resource-from-alertmanager-config * review Signed-off-by: QuentinBisson <[email protected]> * goimports... --------- Signed-off-by: QuentinBisson <[email protected]>
- Loading branch information
1 parent
668ed6f
commit ef180bc
Showing
16 changed files
with
168 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
service/controller/resource/alerting/alertmanagerconfig/client.go
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
service/controller/resource/alerting/alertmanagerconfig/create.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package alertmanagerconfig | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/giantswarm/microerror" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
||
"github.com/giantswarm/prometheus-meta-operator/v2/service/controller/resource/resourceutils" | ||
) | ||
|
||
func (r *Resource) EnsureCreated(ctx context.Context, obj interface{}) error { | ||
desired, err := r.toSecret() | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
|
||
r.config.Logger.Debugf(ctx, "creating") | ||
current, err := r.config.K8sClient.K8sClient().CoreV1().Secrets(desired.GetNamespace()).Get(ctx, desired.GetName(), metav1.GetOptions{}) | ||
if apierrors.IsNotFound(err) { | ||
current, err = r.config.K8sClient.K8sClient().CoreV1().Secrets(desired.GetNamespace()).Create(ctx, desired, metav1.CreateOptions{}) | ||
} | ||
|
||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
|
||
if r.hasChanged(current, desired) { | ||
resourceutils.UpdateMeta(current, desired) | ||
_, err = r.config.K8sClient.K8sClient().CoreV1().Secrets(desired.GetNamespace()).Update(ctx, desired, metav1.UpdateOptions{}) | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
} | ||
r.config.Logger.Debugf(ctx, "created") | ||
|
||
return nil | ||
} |
24 changes: 24 additions & 0 deletions
24
service/controller/resource/alerting/alertmanagerconfig/delete.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package alertmanagerconfig | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/giantswarm/microerror" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func (r *Resource) EnsureDeleted(ctx context.Context, obj interface{}) error { | ||
object := getObjectMeta() | ||
|
||
r.config.Logger.Debugf(ctx, "deleting") | ||
err := r.config.K8sClient.K8sClient().CoreV1().Secrets(object.GetNamespace()).Delete(ctx, object.GetName(), metav1.DeleteOptions{}) | ||
if apierrors.IsNotFound(err) { | ||
// fall through | ||
} else if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
r.config.Logger.Debugf(ctx, "deleted") | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.