mirror of
https://github.com/external-secrets/external-secrets.git
synced 2024-12-14 11:57:59 +00:00
fix: allow controller to delete
delete externalsecrets (#1670)
When using ClusterExternalSecret the controller needs to delete external-secret resources Signed-off-by: Moritz Johner <beller.moritz@googlemail.com> Signed-off-by: Moritz Johner <beller.moritz@googlemail.com>
This commit is contained in:
parent
d5cc8b3de5
commit
411f03ffe1
2 changed files with 6 additions and 2 deletions
|
@ -91,6 +91,7 @@ rules:
|
||||||
verbs:
|
verbs:
|
||||||
- "create"
|
- "create"
|
||||||
- "update"
|
- "update"
|
||||||
|
- "delete"
|
||||||
---
|
---
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
{{- if and .Values.scopedNamespace .Values.scopedRBAC }}
|
{{- if and .Values.scopedNamespace .Values.scopedRBAC }}
|
||||||
|
|
|
@ -170,7 +170,6 @@ func (r *Reconciler) resolveExternalSecret(ctx context.Context, clusterExternalS
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reconciler) removeExternalSecret(ctx context.Context, esName, namespace string) (string, error) {
|
func (r *Reconciler) removeExternalSecret(ctx context.Context, esName, namespace string) (string, error) {
|
||||||
//
|
|
||||||
var existingES esv1beta1.ExternalSecret
|
var existingES esv1beta1.ExternalSecret
|
||||||
err := r.Get(ctx, types.NamespacedName{
|
err := r.Get(ctx, types.NamespacedName{
|
||||||
Name: esName,
|
Name: esName,
|
||||||
|
@ -205,7 +204,11 @@ func (r *Reconciler) removeOldNamespaces(ctx context.Context, namespaceList v1.N
|
||||||
failedNamespaces := map[string]string{}
|
failedNamespaces := map[string]string{}
|
||||||
// Loop through existing namespaces first to make sure they still have our labels
|
// Loop through existing namespaces first to make sure they still have our labels
|
||||||
for _, namespace := range getRemovedNamespaces(namespaceList, provisionedNamespaces) {
|
for _, namespace := range getRemovedNamespaces(namespaceList, provisionedNamespaces) {
|
||||||
if result, _ := r.removeExternalSecret(ctx, esName, namespace); result != "" {
|
result, err := r.removeExternalSecret(ctx, esName, namespace)
|
||||||
|
if err != nil {
|
||||||
|
r.Log.Error(err, "unable to delete external-secret")
|
||||||
|
}
|
||||||
|
if result != "" {
|
||||||
failedNamespaces[namespace] = result
|
failedNamespaces[namespace] = result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue