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-remotewriteingress-resource (#1646)
Signed-off-by: QuentinBisson <[email protected]>
- Loading branch information
1 parent
ef180bc
commit dcd3069
Showing
9 changed files
with
180 additions
and
119 deletions.
There are no files selected for viewing
29 changes: 0 additions & 29 deletions
29
service/controller/resource/monitoring/remotewriteingress/client.go
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
service/controller/resource/monitoring/remotewriteingress/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 remotewriteingress | ||
|
||
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.toIngress(obj) | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
|
||
r.config.Logger.Debugf(ctx, "creating") | ||
current, err := r.config.K8sClient.K8sClient().NetworkingV1().Ingresses(desired.GetNamespace()).Get(ctx, desired.GetName(), metav1.GetOptions{}) | ||
if apierrors.IsNotFound(err) { | ||
current, err = r.config.K8sClient.K8sClient().NetworkingV1().Ingresses(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().NetworkingV1().Ingresses(desired.GetNamespace()).Update(ctx, desired, metav1.UpdateOptions{}) | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
} | ||
r.config.Logger.Debugf(ctx, "created") | ||
|
||
return nil | ||
} |
27 changes: 27 additions & 0 deletions
27
service/controller/resource/monitoring/remotewriteingress/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,27 @@ | ||
package remotewriteingress | ||
|
||
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, err := r.getObjectMeta(obj) | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
|
||
r.config.Logger.Debugf(ctx, "deleting") | ||
err = r.config.K8sClient.K8sClient().NetworkingV1().Ingresses(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
26 changes: 0 additions & 26 deletions
26
service/controller/resource/monitoring/remotewriteingressauth/client.go
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
service/controller/resource/monitoring/remotewriteingressauth/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 remotewriteingressauth | ||
|
||
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(ctx, obj) | ||
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 | ||
} |
27 changes: 27 additions & 0 deletions
27
service/controller/resource/monitoring/remotewriteingressauth/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,27 @@ | ||
package remotewriteingressauth | ||
|
||
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, err := r.getObjectMeta(obj) | ||
if err != nil { | ||
return microerror.Mask(err) | ||
} | ||
|
||
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 | ||
} |
Oops, something went wrong.